Exemplo n.º 1
0
        public async Task PostNewFieldReturnsBadRequestAndCorrectContentType()
        {
            // Given
            CreateFieldViewModel model = ViewModelFactory.CreateInvalidCreationModel();

            // When
            HttpResponseMessage response = await Client.PostAsJsonAsync(EndPointFactory.CreateEndpoint(), model);

            // Then
            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
            response.Content.Headers.ContentType.ToString().Should().Be("application/problem+json; charset=utf-8");
        }
Exemplo n.º 2
0
        public async Task PostNewFieldReturnsCreatedAndCorrectContentType()
        {
            // Given
            A.CallTo(() => _fakeCommand.Create(A <CreateFieldModel> .Ignored)).Returns(Guid.NewGuid());

            // When
            HttpResponseMessage response = await Client.PostAsJsonAsync(EndPointFactory.CreateEndpoint(), ViewModelFactory.CreateValidCreationModel());

            // Then
            response.StatusCode.Should().Be(HttpStatusCode.Created);
            response.Headers.Location.Should().NotBeNull();
            A.CallTo(() => _fakeCommand.Create(A <CreateFieldModel> .Ignored)).MustHaveHappenedOnceExactly();
        }
Exemplo n.º 3
0
        public async Task PostNewSpeciesReturnsConflictIfResourceStateExceptionOccured()
        {
            // Given
            A.CallTo(() => _fakeCommand.Create(A <CreateSpeciesModel> .Ignored)).Throws(A.Fake <ResourceStateException>());

            // When
            HttpResponseMessage response = await Client.PostAsJsonAsync(EndPointFactory.CreateEndpoint(), ViewModelFactory.CreateValidCreationModel());

            // Then
            response.StatusCode.Should().Be(HttpStatusCode.Conflict);
            response.Content.Headers.ContentType.ToString().Should().Be("application/json; charset=utf-8");
            A.CallTo(() => _fakeCommand.Create(A <CreateSpeciesModel> .Ignored)).MustHaveHappenedOnceExactly();
        }