public void Grades_Controller_Test_On_Details_With_NonExistent_Id() { //Arrange Guid id = new Guid("f616cc8c-2223-4145-b7d0-232a1f6f0795"); var repo = Substitute.For <IRepository>(); var sut = new GradesController(repo); repo.GetById <Grade>(id); //Act var actual = sut.Details(id).Result; //Assert Assert.IsInstanceOfType(actual, typeof(NotFoundResult)); }
public void Grades_Controller_Test_On_Details_With_Existent_Id() { //Arrange Guid id = new Guid("f616cc8c-2223-4145-b7d0-232a1f6f0795"); int value = 10; DateTime date = DateTime.Now; Grade expectedGrades = new Grade(value, date); expectedGrades.Id = id; var repo = Substitute.For <IRepository>(); var sut = new GradesController(repo); repo.GetById <Grade>(id).Returns(expectedGrades); //Act var actual = sut.Details(id).Result as ViewResult; //Assert Assert.IsInstanceOfType(actual, typeof(ViewResult)); var viewResult = actual; Assert.AreEqual(expectedGrades, viewResult.Model); }
public void Details_NoId_LoadsError() { ViewResult result = (ViewResult)controller.Details(null); Assert.AreEqual("Error", result.ViewName); }