コード例 #1
0
        public async Task Returns_ETag_for_HEAD_request()
        {
            // Arrange
            List <Meeting> meetings = _fakers.Meeting.Generate(2);

            await _testContext.RunOnDatabaseAsync(async dbContext =>
            {
                await dbContext.ClearTableAsync <Meeting>();
                dbContext.Meetings.AddRange(meetings);
                await dbContext.SaveChangesAsync();
            });

            const string route = "/meetings";

            // Act
            (HttpResponseMessage httpResponse, string responseDocument) = await _testContext.ExecuteHeadAsync <string>(route);

            // Assert
            httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);

            httpResponse.Headers.ETag.Should().NotBeNull();
            httpResponse.Headers.ETag.IsWeak.Should().BeFalse();
            httpResponse.Headers.ETag.Tag.Should().NotBeNullOrEmpty();

            responseDocument.Should().BeEmpty();
        }
コード例 #2
0
        public async Task Returns_no_body_for_successful_HEAD_request()
        {
            // Arrange
            Meeting meeting = _fakers.Meeting.Generate();

            await _testContext.RunOnDatabaseAsync(async dbContext =>
            {
                dbContext.Meetings.Add(meeting);
                await dbContext.SaveChangesAsync();
            });

            string route = "/meetings/" + meeting.StringId;

            // Act
            (HttpResponseMessage httpResponse, string responseDocument) = await _testContext.ExecuteHeadAsync <string>(route);

            // Assert
            httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);

            responseDocument.Should().BeEmpty();
        }