コード例 #1
0
 public void ValidRequest_IsValid()
 {
     var input = new GetCurrentUserRequest {
     SecurityContext = A.Dummy<ISecurityContext>()
       };
       var actualResult = _sut.Validate(input);
       Assert.That(actualResult.IsValid, Is.True);
 }
コード例 #2
0
 public void NullContext_IsInvalid()
 {
     var input = new GetCurrentUserRequest {
     SecurityContext = null
       };
       var actualResult = _sut.Validate(input);
       Assert.That(actualResult.IsValid, Is.False);
 }
コード例 #3
0
        public void GivenContextWithoutUser_ReturnsNull()
        {
            ConfigureSecurityContext_ToReturn(null);
              var request = new GetCurrentUserRequest {
            SecurityContext = _securityContext
              };

              var actual = _sut.Handle(request).Result;

              Assert.That(actual, Is.Null);
        }
コード例 #4
0
        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));
        }
コード例 #5
0
            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);
            }