Пример #1
0
        public void Authentication_GetSessionByWrongToken_ReturnsEmptySession()
        {
            //Arrange
            var token = Guid.NewGuid();

            mock.Setup(repo => repo.GetSessionByToken(token)).Returns(new Model.Authentication.ActiveSession {
                DateTimeInitiated = DateTime.UtcNow, Token = new Guid()
            });
            session = new BusinessConcrete.Session(mock.Object);

            //Act
            var underTest = session.GetSessionByToken(token.ToString());

            //Assert
            Assert.IsTrue(underTest != null);
            Assert.AreEqual(underTest.Token, new Guid());
        }
Пример #2
0
        public void Authentication_UserLogsInWithWrongCredentials_ServerReturnsUnAuthorizedException()
        {
            //Arrange
            var credentials = new UserCredentials {
                Username = "******", Password = "******"
            };

            mock.Setup(repo => repo.Login(credentials)).Returns(new Model.Authentication.ActiveSession {
                DateTimeInitiated = DateTime.UtcNow, Token = new Guid()
            });
            session = new BusinessConcrete.Session(mock.Object);

            //Act
            var underTest = session.Create(credentials);

            //Assert
            Assert.IsTrue(underTest != null);
            Assert.AreEqual(underTest.Token, new Guid());
        }
        public void Account_UserLogsInWithWrongCredentials_ReturnsUnauthorizedError()
        {
            //Arrange
            var credentials = new UserCredentials {
                Username = "******", Password = "******"
            };

            mock.Setup(repo => repo.Login(credentials)).Returns(new Model.Authentication.ActiveSession {
                DateTimeInitiated = DateTime.UtcNow, Token = new Guid()
            });
            session = new BusinessConcrete.Session(mock.Object);
            AccountController accountController = new AccountController(mock.Object, session);

            accountController.Request = request;

            //Act
            var res = accountController.Login(credentials);

            //Assert
            Assert.IsTrue(res.StatusCode == System.Net.HttpStatusCode.Unauthorized);
        }