public void DOBUnitTest() { var mockRepo = new Moq.Mock <IRepository <Person> >(); mockRepo.Setup(aa => aa.AsQueryable()).Returns(PersonList().AsQueryable <Person>()); var controller = new RecordsController(mockRepo.Object); var result = controller.BirthDate(); Assert.That(result != null); Assert.That(CastIt(result) != null); Assert.That(CastIt(result).First().FirstName == "Lucille"); Assert.That(CastIt(result).Last().FirstName == "Lindsay Bluth"); }
public void BirthDate() { // Arrange var mockFileProcessor = new Mock <IRecordService>(); mockFileProcessor.Setup(x => x.ImportRecords()).Returns(records); RecordsController controller = new RecordsController(mockFileProcessor.Object); // Act IHttpActionResult result = controller.BirthDate(); var contentResult = result as JsonResult <IOrderedEnumerable <Record> >; // Assert Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.AreEqual(3, contentResult.Content.Count()); Assert.AreEqual("01/01/1985", contentResult.Content.ElementAt(0).DateOfBirth); }