Skip to content

Add possibility to compare expected response with actual one in Contacts Integration Tests #140

@dr-3lo

Description

@dr-3lo

In Contacts integration tests it is good idea to implement custom comparer for Contact, it will allow to check what actual response result we got from our models for test request.

ex.
```

    //load request from file
    using var responseContent = await Feature.LoadFileToStringContent();

    //new logic: get response object from string
    var responseStream = await responseContent.ReadAsStreamAsync();
    var expectedResponse = await JsonSerializer.DeserializeAsync<CreateContactResponse>(responseStream, _jsonSerializerOptions);
    responseStream.Position = 0; // Reset stream position for mock response

    ...

    // Act
    ...

    // Assert
    mockHttp.VerifyNoOutstandingExpectation();
    result.Should().NotBeNull();

    //new logic: use expectedResponse to verify result 
    result.Should().BeEquivalentTo(expectedResponse);
    }

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions