Ejemplo n.º 1
0
        public async Task PutFieldReturnsBadRequestAndCorrectContentType()
        {
            // Given
            UpdateFieldViewModel model = ViewModelFactory.CreateInvalidUpdateModel();

            // When
            HttpResponseMessage response = await Client.PutAsJsonAsync(EndPointFactory.UpdateEndpoint(), model);

            // Then
            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
            response.Content.Headers.ContentType.ToString().Should().Be("application/problem+json; charset=utf-8");
        }
Ejemplo n.º 2
0
        public async Task PutPlantEventReturnsNotFoundAndCorrectContentType()
        {
            // Given
            A.CallTo(() => _fakeCommand.Update(A <Guid> .Ignored, A <UpdatePlantEventModel> .Ignored)).Returns(Task.FromResult <Event>(null));

            // When
            HttpResponseMessage response = await Client.PutAsJsonAsync(EndPointFactory.UpdateEndpoint(), ViewModelFactory.CreateValidUpdateModel());

            // Then
            response.StatusCode.Should().Be(HttpStatusCode.NotFound);
            response.Content.Headers.ContentType.ToString().Should().Be("application/problem+json; charset=utf-8");
            A.CallTo(() => _fakeCommand.Update(A <Guid> .Ignored, A <UpdatePlantEventModel> .Ignored)).MustHaveHappenedOnceExactly();
        }
Ejemplo n.º 3
0
        public async Task PutFieldReturnsFieldAndCorrectContentType()
        {
            // Given
            A.CallTo(() => _fakeCommand.Update(A <UpdateFieldModel> .Ignored)).Returns(A.Fake <Field>());

            // When
            HttpResponseMessage response = await Client.PutAsJsonAsync(EndPointFactory.UpdateEndpoint(), ViewModelFactory.CreateValidUpdateModel());

            // Then
            response.StatusCode.Should().Be(HttpStatusCode.OK);
            response.Content.Headers.ContentType.ToString().Should().Be("application/json; charset=utf-8");
            A.CallTo(() => _fakeCommand.Update(A <UpdateFieldModel> .Ignored)).MustHaveHappenedOnceExactly();
        }
Ejemplo n.º 4
0
        public async Task PutSpeciesReturnsConflictIfResourceStateExceptionOccured()
        {
            // Given
            A.CallTo(() => _fakeCommand.Update(A <UpdateSpeciesModel> .Ignored)).Throws(A.Fake <ResourceStateException>());

            // When
            HttpResponseMessage response = await Client.PutAsJsonAsync(EndPointFactory.UpdateEndpoint(), ViewModelFactory.CreateValidUpdateModel());

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