public void GetCurrentHealthStatusAsyncExceptionTestAsync() { //Arrange var repository = A.Fake <ICosmosRepository <CurrentOpportunitiesSegmentModel> >(); var dummyHealthCheckContext = A.Dummy <HealthCheckContext>(); A.CallTo(() => repository.PingAsync()).Throws(new ApplicationException()); var currentOpportunitiesSegmentService = new CurrentOpportunitiesSegmentService(repository, fakeCourseCurrentOpportunitiesRefresh, fakeIAVCurrentOpportunatiesRefresh, fakeLogger, fakeMapper, fakeJobProfileSegmentRefreshService, fakeCurrentOpportunitiesSegmentUtilities); //Act Func <Task> serviceHealthStatus = async() => await currentOpportunitiesSegmentService.CheckHealthAsync(dummyHealthCheckContext).ConfigureAwait(false); //Asserts serviceHealthStatus.Should().Throw <Exception>(); }
public async Task GetCurrentHealthStatusAsyncTestAsync(bool isHealthyResponse, HealthStatus expectedStatus) { // arrange var dummyHealthCheckContext = A.Dummy <HealthCheckContext>(); A.CallTo(() => fakeRepository.PingAsync()).Returns(isHealthyResponse); var currentOpportunitiesSegmentService = new CurrentOpportunitiesSegmentService(fakeRepository, fakeCourseCurrentOpportunitiesRefresh, fakeIAVCurrentOpportunatiesRefresh, fakeLogger, fakeMapper, fakeJobProfileSegmentRefreshService, fakeCurrentOpportunitiesSegmentUtilities); //Act var serviceHealthStatus = await currentOpportunitiesSegmentService.CheckHealthAsync(dummyHealthCheckContext).ConfigureAwait(false); //Asserts serviceHealthStatus.Status.Should().Be(expectedStatus); A.CallTo(() => fakeRepository.PingAsync()).MustHaveHappenedOnceExactly(); }