Example #1
0
        public void Delete_ShouldReturnNotFound()
        {
            mockContext = new Mock <IHotelAC>();
            mockSet     = new Mock <DbSet <Soba> >();
            mockContext.Setup(m => m.Sobe).Returns(mockSet.Object);

            var controller = new SobaController(mockContext.Object);

            controller.Create(new Soba {
                SobaID = 1
            });
            controller.Delete(2);
            controller.DeleteConfirmed(2);
            ActionResult result = controller.Delete(2);

            Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult), "The room exists");
        }
Example #2
0
        public void Delete_ShouldDeleteCorrectRoom()
        {
            mockContext = new Mock <IHotelAC>();
            mockSet     = new Mock <DbSet <Soba> >();
            mockContext.Setup(m => m.Sobe).Returns(mockSet.Object);

            var controller = new SobaController(mockContext.Object);

            controller.Create(new Soba {
                SobaID = 10
            });
            controller.Delete(10);
            controller.DeleteConfirmed(10);

            mockSet.Verify(m => m.Remove(It.IsAny <Soba>()), Times.Once, "Room failed to remove");
            mockContext.Verify(m => m.SaveChanges(), Times.Exactly(2), "Could not save changes");
        }