Beispiel #1
0
        public void AddOneAdministrator()
        {
            var mockAdmin = new Mock <IAdministratorLogic>(MockBehavior.Strict);

            mockAdmin.Setup(res => res.Get(adminList[0].Id)).Returns(adminList[0]);
            AdministratorController controller = new AdministratorController(mockAdmin.Object);

            var result   = controller.Add(adminList[0]);
            var okResult = result as OkObjectResult;

            Assert.AreEqual(new ObjectResult("").ToString(), controller.Add(adminList[0]).ToString());
        }
Beispiel #2
0
        public void AddAdministratorErrorEmailFormatWrong()
        {
            adminList[0].Email = "mauro";
            var mockAdmin = new Mock <IAdministratorLogic>(MockBehavior.Strict);

            mockAdmin.Setup(r => r.Add(adminList[0])).Throws(new FieldEnteredNotCorrect(""));
            AdministratorController controller = new AdministratorController(mockAdmin.Object);
            var result = controller.Add(adminList[0]);

            Assert.AreEqual(new UnprocessableEntityObjectResult("").ToString(), result.ToString());
        }
Beispiel #3
0
        public void DeleteAdministratorIdNegative()
        {
            var mockAdmin  = new Mock <IAdministratorLogic>(MockBehavior.Strict);
            var controller = new AdministratorController(mockAdmin.Object);

            controller.Add(adminList[0]);
            var result = controller.Delete(-2);

            Assert.AreEqual(new NotFoundObjectResult("").ToString(),
                            result.ToString());
        }
Beispiel #4
0
        public void DeleteAdministratorOk()
        {
            var mockAdmin = new Mock <IAdministratorLogic>(MockBehavior.Strict);

            mockAdmin.Setup(t => t.Get(1)).Returns(adminList[0]);
            mockAdmin.Setup(t => t.Delete(adminList[0]));
            var controller = new AdministratorController(mockAdmin.Object);

            controller.Add(adminList[0]);
            var result = controller.Delete(1);

            Assert.AreEqual(new OkObjectResult("").ToString(),
                            result.ToString());
        }