public void TestAdd() { fix.mockRepo.Setup(repo => repo.Add(It.IsAny <Entry>())).Verifiable(); var controller = new DefaultController(fix.mockRepo.Object); var result = controller.Create(new Entry()); Assert.IsType <CreatedAtRouteResult>(result); Assert.Equal("GetPhoneNumber", ((CreatedAtRouteResult)result).RouteName); fix.mockRepo.Verify(); result = controller.Create(null); Assert.IsType <BadRequestResult>(result); }
public void POSTCreateInvalidSessionTest() { var genotype = new Genotype { Id = 12, }; var viewModel = new AccessionViewModel { Id = 12, }; var mockRepo = new Mock <IPlantBreedingRepo>(); mockRepo.Setup(m => m.GetGenotype(12)).Returns(genotype); var controller = new DefaultController(mockRepo.Object); controller.ModelState.AddModelError("err", "errerr"); var response = controller.Create(viewModel) as ViewResult; Assert.IsNotNull(response); Console.WriteLine(response.ViewData.ToArray()); Assert.IsNotNull((response.ViewData.Model as AccessionViewModel).FamilyId); }