public void Teachers_Controller_Test_On_Details_With_Existent_Id() { //Arrange Guid id = new Guid("f616cc8c-2223-4145-b7d0-232a1f6f0795"); string firstName = "TestF"; string lastName = "TestL"; string userName = "******"; string password = "******"; string emailAdress = "TestE"; Teacher expectedTeacher = new Teacher(firstName, lastName, userName, password, emailAdress); expectedTeacher.Id = id; var repo = Substitute.For <IRepository>(); var sut = new TeachersController(repo); repo.GetById <Teacher>(id).Returns(expectedTeacher); //Act var actual = sut.Details(id).Result as ViewResult; //Assert Assert.IsInstanceOfType(actual, typeof(ViewResult)); var viewResult = actual; Assert.AreEqual(expectedTeacher, viewResult.Model); }
public void Teachers_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 TeachersController(repo); repo.GetById <Teacher>(id); //Act var actual = sut.Details(id).Result; //Assert Assert.IsInstanceOfType(actual, typeof(NotFoundResult)); }