Esempio n. 1
0
        public void TestLoginOK()
        {
            Administrator administrator = new Administrator()
            {
                Email    = "*****@*****.**",
                Password = "******"
            };
            string token             = "token";
            var    mockAdministrator = new Mock <IAdministratorLogic>(MockBehavior.Strict);

            mockAdministrator.Setup(p => p.GetByEmailAndPassword(It.IsAny <string>(), It.IsAny <string>())).Returns(administrator);
            var mockSession = new Mock <ISessionLogic>(MockBehavior.Strict);

            mockSession.Setup(p => p.GenerateToken(It.IsAny <Administrator>())).Returns(token);
            var controller = new AdministratorController(mockAdministrator.Object, mockSession.Object);

            var result = controller.Login("admin", "123") as OkObjectResult;

            mockAdministrator.VerifyAll();
            Assert.AreEqual(200, result.StatusCode);
        }