Esempio n. 1
0
        public async Task HandleGetList_ReturnsOkEvenWithEmptyListAsync()
        {
            var client = Mock(new List <DummyEntity>()).CreateClient();
            var result = await client.GetFromJsonAsync <Response <List <DummyEntity> > >("/dummies");

            result.Should().BeEquivalentTo(DummyResponse.GetResponse(new List <DummyEntity>()));
        }
Esempio n. 2
0
        public async Task HandleGet_ReturnsOkWithDummyEntityAsync()
        {
            var expectedResult = new DummyEntityFaker().Generate();
            var client         = Mock(expectedResult).CreateClient();

            var result = await client.GetFromJsonAsync <Response <DummyEntity> >($"/dummies/{expectedResult.Id}");

            result.Should().BeEquivalentTo(DummyResponse.GetResponse(expectedResult));
        }
Esempio n. 3
0
        public async Task HandleGetList_ReturnsOkWithFilledListAsync()
        {
            var expectedResults = new DummyEntityFaker().Generate(3);
            var client          = Mock(expectedResults).CreateClient();

            var result = await client.GetFromJsonAsync <Response <List <DummyEntity> > >("/dummies");

            result.Should().BeEquivalentTo(DummyResponse.GetResponse(expectedResults));
        }
Esempio n. 4
0
        public async Task HandlePatch_ShouldReturnOkWithLinks()
        {
            var entity = new DummyEntityFaker().Generate();
            var client = api.CreateClient();

            var result = await client.PatchAsync($"/dummies/{entity.Id}", JsonContent.Create(entity));

            result.StatusCode.Should().Be(StatusCodes.Status200OK);

            var content = await result.Content.ReadFromJsonAsync <Response <DummyEntity> >();

            content.Should().BeEquivalentTo(DummyResponse.GetResponse());
        }
Esempio n. 5
0
        public async Task HandleDelete_ShouldReturnDeletedEntity()
        {
            var expectedResult = new DummyEntityFaker().Generate();
            var client         = Mock(expectedResult).CreateClient();

            var result = await client.DeleteAsync($"/dummies/{expectedResult.Id}");

            result.StatusCode.Should().Be(StatusCodes.Status200OK);

            var content = await result.Content.ReadFromJsonAsync <Response <DummyEntity> >();

            content.Should().BeEquivalentTo(DummyResponse.GetResponse(expectedResult));
        }
        public async Task HandleCreate_ShouldReturnCreatedEntityWithLocation()
        {
            var expectedResult = new DummyEntityFaker().Generate();
            var client         = Mock(expectedResult).CreateClient();

            var result = await client.PostAsJsonAsync("/dummies", expectedResult);

            result.StatusCode.Should().Be(StatusCodes.Status201Created);
            result.Headers.Location.Should().Be($"/dummies/{expectedResult.Id}");

            var content = await result.Content.ReadFromJsonAsync <Response <DummyEntity> >();

            content.Should().BeEquivalentTo(DummyResponse.GetResponse(expectedResult));
        }