public void Details_Controller_Test_On_Delete_With_Existent_Id() { //Arrange Guid id = new Guid("f616cc8c-2223-4145-b7d0-232a1f6f0795"); string feedBackMessage = "TestT"; int noOfPages = 10; int rating = 10; DateTime checkIn = DateTime.Now; DateTime checkOut = DateTime.Now.AddDays(1); Detail expectaDetail = new Detail(checkIn, checkOut, feedBackMessage, noOfPages, rating); expectaDetail.Id = id; var repo = Substitute.For <IRepository>(); var sut = new DetailsController(repo); repo.GetById <Detail>(id).Returns(expectaDetail); //Act var actual = sut.Delete(id).Result as ViewResult; //Assert Assert.IsInstanceOfType(actual, typeof(ViewResult)); var viewResult = actual; Assert.AreEqual(expectaDetail, viewResult.Model); }
public void Details_Controller_Test_On_Delete_With_Null_Id() { //Arrange var id = Guid.Empty; var repo = Substitute.For <IRepository>(); var sut = new DetailsController(repo); repo.GetById <Detail>(id); //Act var actual = sut.Delete(id).Result; //Assert Assert.IsInstanceOfType(actual, typeof(NotFoundResult)); }
public void Details_Controller_Test_On_Delete_With_NonExistent_Id() { //Arrange Guid id = new Guid("f616cc8c-2223-4145-b7d0-232a1f6f0795"); var repo = Substitute.For <IRepository>(); var sut = new DetailsController(repo); repo.GetById <Detail>(id); //Act var actual = sut.Delete(id).Result; //Assert Assert.IsInstanceOfType(actual, typeof(NotFoundResult)); }