예제 #1
0
        public void DeleteActionResult_SuccessfulDelete_ShouldRedirectToIndexView()
        {
            var result = (ViewResult)_controller.Delete(It.IsAny <int>());

            _mock.Verify(c => c.DeleteManufacturer(It.IsAny <int>()), Times.Once);

            Assert.NotNull(result);
            Assert.True(result.ViewName == "Index");
        }
예제 #2
0
        public void TestManufacturerDelete()
        {
            // Arrange
            var fakeManufacturer = FakeManufacturers().First();

            var mockBusinessLogic = new Mock <ISportStoreBusinessLogic>();

            mockBusinessLogic
            .Setup(bl => bl.Manufacturer.DeleteById(fakeManufacturer.Id));

            var controller = new ManufacturerController(mockBusinessLogic.Object);

            // Act
            var result = controller.Delete(fakeManufacturer.Id);

            // Assert
            mockBusinessLogic.VerifyAll();

            Assert.IsInstanceOfType(result, typeof(OkResult));
        }
예제 #3
0
        public void Delete_Removes_Manufacturer()
        {
            var manufacturerId      = 1;
            var deletedManufacturer = new Manufacturer(1, "Title", "image", "label");
            var manufacturerList    = new List <Manufacturer>()
            {
                deletedManufacturer,
                new Manufacturer(1, "Title", "image", "label")
            };

            manufacturerRepo.GetByID(manufacturerId).Returns(deletedManufacturer);
            manufacturerRepo.When(d => d.Delete(deletedManufacturer))
            .Do(d => manufacturerList.Remove(deletedManufacturer));
            manufacturerRepo.GetAll().Returns(manufacturerList);

            var result = underTest.Delete(manufacturerId);

            Assert.DoesNotContain(deletedManufacturer, result); /*Does not work in all cases*/
            //Assert.All(result, item => Assert.Contains("Second item", item.Title));
        }