Exemplo n.º 1
0
        public async Task FoundId_Widget()
        {
            var    service = TestUtility.CreateService(m_category);
            var    widget  = InMemoryExampleApiRepository.SampleWidgets[0];
            string eTag    = ExampleApiService.CreateWidgetETag(widget);

            (await service.GetWidgetAsync(id: widget.Id))
            .Should().BeSuccess(new GetWidgetResponseDto {
                Widget = widget, ETag = eTag
            });
        }
Exemplo n.º 2
0
        public async Task Modified_Widget()
        {
            var    service = TestUtility.CreateService(m_category);
            var    widget  = InMemoryExampleApiRepository.SampleWidgets[0];
            string eTag    = ExampleApiService.CreateWidgetETag(widget);

            (await service.GetWidgetAsync(new GetWidgetRequestDto {
                Id = widget.Id, IfNoneMatch = "\"xyzzy\""
            }, CancellationToken.None))
            .Should().BeSuccess(new GetWidgetResponseDto {
                Widget = widget, ETag = eTag
            });
        }
Exemplo n.º 3
0
        public async Task BadIfNoneMatch()
        {
            var    service = TestUtility.CreateService(m_category);
            var    widget  = InMemoryExampleApiRepository.SampleWidgets[0];
            string eTag    = ExampleApiService.CreateWidgetETag(widget);
            var    result  = await service.GetWidgetAsync(new GetWidgetRequestDto { Id = widget.Id, IfNoneMatch = "xyzzy" }, CancellationToken.None);

            if (m_category == "InMemory")
            {
                result.Should().BeSuccess(new GetWidgetResponseDto {
                    Widget = widget, ETag = eTag
                });
            }
            else
            {
                result.Should().BeFailure(HttpServiceErrors.CreateHeaderInvalidFormat("If-None-Match"));
            }
        }