public Index ( ) : System.Web.Mvc.ViewResult | ||
Résultat | System.Web.Mvc.ViewResult |
public void ShouldNot_RaiseException_WhenDbIsEmpty() { // setup var mock = new Mock<IRepository>(); mock.Setup(x => x.Query<Inquiry>()).Returns(new List<Inquiry>().AsQueryable()); var inquiriesController = new InquiriesController(mock.Object); // act var response = inquiriesController.Index() as ViewResult; // check Assert.IsNotNull(response); }
public void Should_ReturnInquiry_WhenRequestedFullList() { // setup var mock = new Mock<IRepository>(); mock.Setup(z => z.Query<Inquiry>(x => x.Client, x => x.Source)).Returns(ListInquiries.AsQueryable()); var inquiriesController = new InquiriesController(mock.Object); // act var response = inquiriesController.Index(); var typedResponse = response as ViewResult; var list = typedResponse.Model as IEnumerable<Inquiry>; // chek Assert.That(list.Single(x => x.Client.LastName == "Petrov") != null && list.Single(x => x.Source.Subject == "subj2") != null); }
public void ShouldNot_RaiseException_WhenRepostioryIsEmptyAndIndexRequested() { // arrange var mock = new Mock<IRepository>(); mock.Setup(x => x.Query<Inquiry>()).Returns(new List<Inquiry>().AsQueryable()); var inquiriesController = new InquiriesController(mock.Object); // act var response = inquiriesController.Index(); // assert Assert.IsNotNull(response); }
public void Should_ReturnFullListOfInquiries_WhenIndexRequested() { // arrange var mock = new Mock<IRepository>(); mock.Setup(z => z.Query<Inquiry>(x => x.Client, x => x.Source)).Returns(inquiries.AsQueryable()); var inquiriesController = new InquiriesController(mock.Object); // act var response = inquiriesController.Index(); var list = response.Model as IEnumerable<Inquiry>; // assert list.Count().Should().Be(40); }