public void Get_WithNoArgs_ReturnsJsonListOfAllReports() { // Arrange // we expect the returned object to have fields added by the mapper var expectedResult = ReportsControllerTestHelpers.FakeReportList().Select(report => map.Map <Domain.ReportDefinition, ReportDefinition>(report)); // Act var result = controller.Get().AsCSharpObject <List <ReportDefinition> >(); // Assert result.Should().HaveCount(2, because: "that's what the test object had"); result.ShouldBeEquivalentTo(expectedResult); }
public void Get_WithId_ReturnsSingleReport_WithSameId() { // Arrange: This only works because the IDs equal the index of the list members for the test class. var expectedResult = ReportsControllerTestHelpers.FakeReportList()[1]; // Act var result = controller.Get("1").AsCSharpObject <ReportDefinition>(); // Assert: It's unclear to me how we wind up with id, columns, and inputs, because we're not mapping to the view model this time. result.ShouldBeEquivalentTo(expectedResult, x => x .Excluding(field => field.id) .Excluding(field => field.columns) .Excluding(field => field.inputs) ); }
public void Get_WithFourArgs_ReturnsSingleReport_MatchingThoseParameters() { // this test is quick-and-dirty and needs serious help. // all it shows currently is that this method can match on a name instead of an ID. // Arrange var expectedResult = new List <dynamic> { (dynamic)ReportsControllerTestHelpers.FakeReportList()[0] }; // Act var result = controller.Get("FakeReport", testStartDate, testEndDate, null) .AsCSharpObject <List <ReportDefinition> >(); // Assert result.ShouldBeEquivalentTo(expectedResult, x => x.ExcludingMissingMembers()); }