Example #1
0
        public async Task TestRestGreetingProvider(string expectedGreeting)
        {
            var httpClientFactoryMock  = Substitute.For <IHttpClientFactory>();
            var fakeHttpMessageHandler = FakeHttpMessageHandler.FactoryWithJsonBody(expectedGreeting);
            var fakeHttpClient         = new HttpClient(fakeHttpMessageHandler);

            httpClientFactoryMock.CreateClient().Returns(fakeHttpClient);

            var greetingProvider = new RestGreetingProvider(Substitute.For <ILogger <RestGreetingProvider> >(), httpClientFactoryMock, FactoryServicesConfig());

            (await greetingProvider.GetGreeting())
            .Should().Be(expectedGreeting);
        }