private DomainResponse ToDomainResponse(MockResponsePayload payload)
 {
     return(new DomainResponse
     {
         PayLoad = payload.ToJsonCamelCase(),
     });
 }
        public void GetReturnsExpectedData(string path, MockResponsePayload payload)
        {
            var fullpath = $"/{path}";

            var body = ToDomainResponse(payload);

            _server
            .Given(
                Request.Create().WithPath(fullpath).UsingGet())
            .RespondWith(
                Response.Create().WithStatusCode(200).WithBodyAsJson(body, true));

            var result = _sut.Get(fullpath);

            Assert.Equal(payload?.Data, result.SelectToken(".data"));
        }
        public void DeleteReturnsExpectedData(string path, MockResponsePayload payload)
        {
            var fullpath = $"/{path}";

            var body = ToDomainResponse(payload);

            _server
            .Given(
                Request.Create().WithPath(fullpath).UsingDelete())
            .RespondWith(
                Response.Create().WithStatusCode(200).WithBodyAsJson(body, true));

            var result = _sut.Delete(fullpath);

            // BUG: It's ahn... Well... Yeah, there's a DomainResponse inside a DomainResponse
            var payloadAsString = result.PayLoad.ToString();

            Assert.Equal(payload?.Data, JsonConvert.DeserializeObject <DomainResponse>(payloadAsString).PayLoad.SelectToken(".data"));
        }
        public void PostOfTReturnsExpectedData(string path, MockRequestPayload requestPayload, MockResponsePayload responsePayload)
        {
            var fullpath = $"/{path}";

            var response = ToDomainResponse(responsePayload);

            _server
            .Given(
                Request.Create().WithPath(fullpath).UsingPost().WithBody(EqualsMatcher(requestPayload)))
            .RespondWith(
                Response.Create().WithStatusCode(200).WithBodyAsJson(response, true));

            var result = _sut.Post <MockResponsePayload>(fullpath, requestPayload.ToJsonCamelCase());

            Assert.Equal(responsePayload?.Data, result.Data);
        }