public async Task GetSummaryListReturnsNullWhenDataDoesntExist() { // Arrange var repository = A.Fake <ICosmosRepository <SummaryDataModel> >(); A.CallTo(() => repository.GetData( A <Expression <Func <SummaryDataModel, SummaryDataModel> > > .Ignored, A <Expression <Func <SummaryDataModel, bool> > > .Ignored)).Returns((IList <SummaryDataModel>)null); var summaryService = new SummaryService(repository, mapper); // Act var result = await summaryService.GetSummaryList(RequestUrl).ConfigureAwait(false); // Assert Assert.Null(result); }
public async Task GetSummaryListReturnsApiModelsWithCorrectUrlPrefixWhenDataExists() { // Arrange var dataModels = GetSummaryDataModels(); var repository = A.Fake <ICosmosRepository <SummaryDataModel> >(); A.CallTo(() => repository.GetData( A <Expression <Func <SummaryDataModel, SummaryDataModel> > > .Ignored, A <Expression <Func <SummaryDataModel, bool> > > .Ignored)).Returns(dataModels); var summaryService = new SummaryService(repository, mapper); // Act var result = await summaryService.GetSummaryList(RequestUrl).ConfigureAwait(false); // Assert var resultArray = result.ToArray(); for (var i = 0; i < resultArray.Length; i++) { Assert.Equal($"{RequestUrl}{dataModels[i].CanonicalName}", resultArray[i].Url); } }