public void ValidRequest_IsValid() { var input = new GetCurrentUserRequest { SecurityContext = A.Dummy<ISecurityContext>() }; var actualResult = _sut.Validate(input); Assert.That(actualResult.IsValid, Is.True); }
public void NullContext_IsInvalid() { var input = new GetCurrentUserRequest { SecurityContext = null }; var actualResult = _sut.Validate(input); Assert.That(actualResult.IsValid, Is.False); }
public void GivenContextWithoutUser_ReturnsNull() { ConfigureSecurityContext_ToReturn(null); var request = new GetCurrentUserRequest { SecurityContext = _securityContext }; var actual = _sut.Handle(request).Result; Assert.That(actual, Is.Null); }
public void GivenContextWithValidUser_ReturnsUser() { var user = new User {Login = new Login {Value = "JohnD"}}; ConfigureSecurityContext_ToReturn(user); var request = new GetCurrentUserRequest { SecurityContext = _securityContext }; var actual = _sut.Handle(request).Result; Assert.That(actual, Is.Not.Null); Assert.That(actual, Is.EqualTo(user)); }
public void ShouldReturnCurrentLoggedInUser() { var securityContext = A.Fake<ISecurityContext>(); ConfigureSecurityContextFactory_ToReturn(securityContext); var expectedRequest = new GetCurrentUserRequest { SecurityContext = securityContext }; A.CallTo(() => _getCurrentUserHandler.Handle(A<GetCurrentUserRequest>.That.HasSamePropertyValuesAs(expectedRequest))).Returns(_authenticatedUser); var actual = Get(); Assert.That(actual.StatusCode, Is.EqualTo(HttpStatusCode.OK)); var actualDeserialized = actual.Body.DeserializeJson<User>(); Assert.That(actualDeserialized.HasSamePropertyValuesAs(_authenticatedUser)); A.CallTo(() => _getCurrentUserHandler .Handle(A<GetCurrentUserRequest>.That.Matches(req => req.HasSamePropertyValuesAs(expectedRequest)))) .MustHaveHappened(Repeated.Exactly.Once); }