Пример #1
0
        public void ValidCommand_IsValid()
        {
            var input = new LoginLocalUserRequest {
                Login           = "******",
                Password        = "******",
                SecurityContext = A.Dummy <ISecurityContext>()
            };
            var actualResult = _sut.Validate(input);

            Assert.That(actualResult.IsValid, Is.True);
        }
Пример #2
0
        public void NullPassword_IsInvalid()
        {
            var input = new LoginLocalUserRequest {
                Login           = "******",
                Password        = null,
                SecurityContext = A.Dummy <ISecurityContext>()
            };
            var actualResult = _sut.Validate(input);

            Assert.That(actualResult.IsValid, Is.False);
        }
Пример #3
0
            public void ParsesRequestCorrectly()
            {
                LoginLocalUserRequest interceptedRequest = null;

                A.CallTo(() => _loginLocalUserHandler.Handle(A <LoginLocalUserRequest> ._))
                .Invokes(call => interceptedRequest = call.GetArgument <LoginLocalUserRequest>(0))
                .Returns(true);

                var securityContext = A.Fake <ISecurityContext>();

                ConfigureSecurityContextFactory_ToReturn(securityContext);

                Post();

                var expected = new LoginLocalUserRequest {
                    Login           = "******",
                    Password        = "******",
                    SecurityContext = securityContext
                };

                interceptedRequest.ShouldBeEquivalentTo(expected);
            }
Пример #4
0
            public void GivenMissingBodyInRequest_CallsInnerHandlerWithEmptyRequest()
            {
                LoginLocalUserRequest interceptedRequest = null;

                A.CallTo(() => _loginLocalUserHandler.Handle(A <LoginLocalUserRequest> ._))
                .Invokes(call => interceptedRequest = call.GetArgument <LoginLocalUserRequest>(0))
                .Returns(true);

                var securityContext = A.Fake <ISecurityContext>();

                ConfigureSecurityContextFactory_ToReturn(securityContext);

                var response = Post(null);

                Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                var expected = new LoginLocalUserRequest {
                    Login           = null,
                    Password        = null,
                    SecurityContext = securityContext
                };

                interceptedRequest.ShouldBeEquivalentTo(expected);
            }