public async Task GetReturnsNullWhenDataNotPresent() { // Arrange IEnumerable <AppRegistrationModel>?fakeAppRegistrationModel = null; var expectedResult = new OkObjectResult(null); var function = new GetHttpTrigger(fakeLogger, fakeDocumentService); A.CallTo(() => fakeDocumentService.GetAsync(A <Expression <Func <AppRegistrationModel, bool> > > .Ignored)).Returns(fakeAppRegistrationModel); // Act var result = await function.Run(A.Fake <HttpRequest>(), PathName).ConfigureAwait(false); // Assert A.CallTo(() => fakeDocumentService.GetAsync(A <Expression <Func <AppRegistrationModel, bool> > > .Ignored)).MustHaveHappenedOnceExactly(); var statusResult = Assert.IsType <OkObjectResult>(result); Assert.Equal(expectedResult.StatusCode, statusResult.StatusCode); }
public async Task GetReturnsSuccessWhenDataPresent() { // Arrange const HttpStatusCode expectedResult = HttpStatusCode.OK; var dummyModels = A.CollectionOfDummy <AppRegistrationModel>(2); var function = new GetHttpTrigger(fakeLogger, fakeDocumentService); A.CallTo(() => fakeDocumentService.GetAsync(A <Expression <Func <AppRegistrationModel, bool> > > .Ignored)).Returns(dummyModels); // Act var result = await function.Run(A.Fake <HttpRequest>(), PathName).ConfigureAwait(false); // Assert A.CallTo(() => fakeDocumentService.GetAsync(A <Expression <Func <AppRegistrationModel, bool> > > .Ignored)).MustHaveHappenedOnceExactly(); var statusResult = Assert.IsType <OkObjectResult>(result); Assert.Equal((int)expectedResult, statusResult.StatusCode); }