Exemplo n.º 1
0
        public void EquipmentById()
        {
            var httpClient       = new HttpClient(_handlerMock.Object);
            var subjectUnderTest = new WidgetRepository(_options, httpClient);
            var result           = subjectUnderTest.EquipmentById(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/equipmentWidget?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>()
                );
        }