Пример #1
0
        public async Task Then_The_Ping_Endpoint_Is_Called_For_CoursesApi(
            [Frozen] Mock <ICoursesApiClient <CoursesApiConfiguration> > client,
            HealthCheckContext healthCheckContext,
            CoursesApiHealthCheck healthCheck)
        {
            //Act
            await healthCheck.CheckHealthAsync(healthCheckContext, CancellationToken.None);

            //Assert
            client.Verify(x => x.GetResponseCode(It.IsAny <GetPingRequest>()), Times.Once);
        }
Пример #2
0
        public async Task And_CourseDeliveryApi_Ping_Not_Found_Then_Unhealthy(
            [Frozen] Mock <ICoursesApiClient <CoursesApiConfiguration> > client,
            HealthCheckContext healthCheckContext,
            CoursesApiHealthCheck healthCheck)
        {
            //Arrange
            client.Setup(x => x.GetResponseCode(new GetPingRequest()))
            .ReturnsAsync(HttpStatusCode.NotFound);
            //Act
            var actual = await healthCheck.CheckHealthAsync(healthCheckContext, CancellationToken.None);

            //Assert
            Assert.AreEqual(HealthStatus.Unhealthy, actual.Status);
        }
Пример #3
0
        public async Task Then_If_It_Is_Successful_200_Is_Returned(
            [Frozen] Mock <ICoursesApiClient <CoursesApiConfiguration> > client,
            HealthCheckContext healthCheckContext,
            CoursesApiHealthCheck healthCheck)
        {
            //Arrange
            client.Setup(x => x.GetResponseCode(It.IsAny <GetPingRequest>()))
            .ReturnsAsync(HttpStatusCode.OK);
            //Act
            var actual = await healthCheck.CheckHealthAsync(healthCheckContext, CancellationToken.None);

            //Assert
            Assert.AreEqual(HealthStatus.Healthy, actual.Status);
        }