Beispiel #1
0
        public void Singin_NotAuthenticated()
        {
            Mock <IAuthenticationService> authServiceMock = new Mock <IAuthenticationService>();

            authServiceMock.Setup(x => x.SignIn(It.IsAny <String>(), It.IsAny <String>()))
            .Returns(new AuthenticationToken()
            {
                AccessToken = null
            });

            AuthenticationApplicationService appService = new AuthenticationApplicationService(authServiceMock.Object);

            var result = appService.SignIn(new AuthenticationView()
            {
                Username = "******",
                Password = "******"
            });

            Assert.NotNull(result);
            Assert.False(result.IsAuthenticated);
        }
Beispiel #2
0
        public void Singin_Success()
        {
            Mock <IAuthenticationService> authServiceMock = new Mock <IAuthenticationService>();

            authServiceMock.Setup(x => x.SignIn(It.IsAny <String>(), It.IsAny <String>()))
            .Returns(new AuthenticationToken()
            {
                AccessToken = "wVN1EwuzSnTgRAiLxx24kg2uH132uSxMWiEq-sZNlf20Lh5ir5l_kBzY5cdjpuRp9jMnEgWXxcxoPXcwGI0OnoNpuGMrX1fBAr9qfWyXrUzXKrumwcU4Bn5emSc22f2L5lgpfArwCbla15MJAII9QrgdXh7wqp6fzPNOZvaSJpI0shSv2HJU5dDGT6QtIekuQXWCP-bMs7V0wi8OWeVMoUO25wzwIP0wYYsCTteSxvQ"
            });

            AuthenticationApplicationService appService = new AuthenticationApplicationService(authServiceMock.Object);

            var result = appService.SignIn(new AuthenticationView()
            {
                Username = "******",
                Password = "******"
            });

            Assert.NotNull(result);
            Assert.True(result.IsAuthenticated);
        }
Beispiel #3
0
        public void Signin_Fail_UserAndPassword_Empty()
        {
            Mock <IAuthenticationService> authServiceMock = new Mock <IAuthenticationService>();

            authServiceMock.Setup(x => x.SignIn(It.IsAny <String>(), It.IsAny <String>()))
            .Returns(new AuthenticationToken()
            {
                AccessToken = "wVN1EwuzSnTgRAiLxx24kg2uH132uSxMWiEq-sZNlf20Lh5ir5l_kBzY5cdjpuRp9jMnEgWXxcxoPXcwGI0OnoNpuGMrX1fBAr9qfWyXrUzXKrumwcU4Bn5emSc22f2L5lgpfArwCbla15MJAII9QrgdXh7wqp6fzPNOZvaSJpI0shSv2HJU5dDGT6QtIekuQXWCP-bMs7V0wi8OWeVMoUO25wzwIP0wYYsCTteSxvQ"
            });

            AuthenticationApplicationService appService = new AuthenticationApplicationService(authServiceMock.Object);

            var ex = Assert.Throws <ArgumentException>(() =>
            {
                var result = appService.SignIn(new AuthenticationView()
                {
                    Username = "",
                    Password = ""
                });
            });

            Assert.Equal("Please inform username and password.", ex.Message);
        }