Skip to content

Commit

Permalink
Do not modify shared options in Notifications test
Browse files Browse the repository at this point in the history
These tests were modifying a shared options object and causing
indeterminate results based on current running of other tests. I'm not
sure what changed (.Net 4.8? Visual Studio 2019?) to make them fail now
but not before.
  • Loading branch information
explunit committed Oct 29, 2019
1 parent 353c015 commit abab13f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Tests/Tests.Shared/WebSSO/SignInCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ public void SignInCommand_Run_Calls_NotificationForAbsoluteUrl()
var httpRequest = new HttpRequestData("GET", new Uri($"http://localhost/signin?ReturnUrl={absoluteUri}"));
var validateAbsoluteReturnUrlCalled = false;

Options.FromConfiguration.Notifications.ValidateAbsoluteReturnUrl =
var options = StubFactory.CreateOptions();
options.Notifications.ValidateAbsoluteReturnUrl =
(url) =>
{
validateAbsoluteReturnUrlCalled = true;
return true;
};

Action a = () => new SignInCommand().Run(httpRequest, Options.FromConfiguration);
Action a = () => new SignInCommand().Run(httpRequest, options);

a.Should().NotThrow<InvalidOperationException>("the ValidateAbsoluteReturnUrl notification returns true");
validateAbsoluteReturnUrlCalled.Should().BeTrue("the ValidateAbsoluteReturnUrl notification should have been called");
Expand All @@ -100,14 +101,15 @@ public void SignInCommand_Run_DoNotCalls_NotificationForRelativeUrl()
var httpRequest = new HttpRequestData("GET", new Uri($"http://localhost/signin?ReturnUrl={relativeUri}"));
var validateAbsoluteReturnUrlCalled = false;

Options.FromConfiguration.Notifications.ValidateAbsoluteReturnUrl =
var options = StubFactory.CreateOptions();
options.Notifications.ValidateAbsoluteReturnUrl =
(url) =>
{
validateAbsoluteReturnUrlCalled = true;
return true;
};

Action a = () => new SignInCommand().Run(httpRequest, Options.FromConfiguration);
Action a = () => new SignInCommand().Run(httpRequest, options);

a.Should().NotThrow<InvalidOperationException>("the ReturnUrl is relative");
validateAbsoluteReturnUrlCalled.Should().BeFalse("the ValidateAbsoluteReturnUrl notification should not have been called");
Expand Down

0 comments on commit abab13f

Please sign in to comment.