Ejemplo n.º 1
0
        public void Can_Create_Valid_Group()
        {
            // Arrange
            Mock <IWorkerAdminGroup>  mock       = new Mock <IWorkerAdminGroup>();
            Mock <HttpPostedFileBase> mockImage  = new Mock <HttpPostedFileBase>();
            AdminGroupController      controller = new AdminGroupController(mock.Object);
            // Act
            ActionResult result = controller.Create(testGroup, mockImage.Object);

            // Assert
            mock.Verify(m => m.CreateGroup(testGroup));
            Assert.IsNotInstanceOfType(result, typeof(ViewResult));
        } // end Can_Create_Valid_Group()
Ejemplo n.º 2
0
        public void Cannot_Create_Invalid_Group()
        {
            // Arrange
            Mock <IWorkerAdminGroup>  mock       = new Mock <IWorkerAdminGroup>();
            Mock <HttpPostedFileBase> mockImage  = new Mock <HttpPostedFileBase>();
            AdminGroupController      controller = new AdminGroupController(mock.Object);

            controller.ModelState.AddModelError("error", "error");
            // Act
            ActionResult result = controller.Create(testGroup, mockImage.Object);

            // Assert
            mock.Verify(m => m.CreateGroup(testGroup), Times.Never());
            Assert.IsInstanceOfType(result, typeof(ViewResult));
        } // end Cannot_Create_Invalid_Group()