コード例 #1
0
        public void PriceBreakdownById()
        {
            var httpClient       = new HttpClient(_handlerMock.Object);
            var subjectUnderTest = new WidgetRepository(_options, httpClient);
            var result           = subjectUnderTest.PriceBreakdownById(12, null);

            result.Should().NotBeNull(); // this is fluent assertions here...

            // also check the 'http' call was like we expected it
            var expectedUri = new Uri("https://serverTest.com/recipes/12/priceBreakdownWidget?123");

            _handlerMock.Protected().Verify(
                "SendAsync",
                Times.Exactly(2), // we expected a single external request
                ItExpr.Is <HttpRequestMessage>(req =>
                                               req.Method == HttpMethod.Get && // we expected a GET request
                                               req.RequestUri == expectedUri // to this uri
                                               ),
                ItExpr.IsAny <CancellationToken>()
                );
        }