Skip to content

Possibility to assert invoked Uris? #31

Open
@Kralizek

Description

@Kralizek

Hi,

I'm using your library to author some tests and I got myself in the situation where my API client is forming a URL by adding many components both in the path and the querystring.

My test is targeting only a subsection of the requested URI and I would like to "test" it. Ideally on the used option.

To make a concrete example

var option = new HttpMessageOptions
{
    HttpMethod = HttpMethod.Get,
    HttpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK)
    {
        Content = new StringContent(JsonConvert.SerializeObject(contact))
    },
    RequestUri = null 
};

var sut = CreateSystemUnderTest(option);

var response = await sut.GetByIdAsync(contactId);

Assert.That(option.InvokedUri, Contains.SubString($"/contacts/v1/contact/vid/{contactId}"));

Right now I am forced to do:

var options = new HttpMessageOptions
{
    HttpMethod = HttpMethod.Get,
    HttpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK)
    {
        Content = new StringContent(JsonConvert.SerializeObject(contact))
    },
    RequestUri = new Uri($"https://api.hubapi.com/contacts/v1/contact/vid/{contactId}/profile?formSubmissionMode=all&propertyMode=value_and_history&showListMemberships=true")
};

which is really outside of the scope of my unit test.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions