Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
48132aa
Added OAF validation exception
hamzashoukat94 Jul 6, 2023
3011af3
fixed linting warnings
asadali214 Jul 7, 2023
8dbd417
Common method for OAF deserialization
hamzashoukat94 Jul 7, 2023
65c87f8
Add common implementation of every converter in TryDeserializeOneOfAn…
hamzashoukat94 Jul 7, 2023
44d2288
Case converter changes
hamzashoukat94 Jul 10, 2023
91669b9
Unit test added
hamzashoukat94 Jul 11, 2023
8271c93
Add at least one Assert statement
hamzashoukat94 Jul 11, 2023
e6845b5
Handle carriage return
hamzashoukat94 Jul 11, 2023
d43d208
Handle the nested OAF cases and collection cases
hamzashoukat94 Jul 12, 2023
c4c47c6
Rename parameters to value
hamzashoukat94 Jul 13, 2023
9ef73af
Extracted UnionTypeConverter
asadali214 Jul 13, 2023
a42f8b3
Extarcted out JToken
asadali214 Jul 13, 2023
7edf454
Extarcted JToken in ReadJson
asadali214 Jul 13, 2023
729efae
Update to new design
hamzashoukat94 Jul 13, 2023
f580d27
Converter changes
hamzashoukat94 Jul 13, 2023
8816b6b
Use single token instead of JTokenType Array
hamzashoukat94 Jul 14, 2023
d4429bd
Exception messages issues fix
hamzashoukat94 Jul 14, 2023
1ca5bc7
Add the support of discriminator and unit test added
hamzashoukat94 Jul 14, 2023
68e5c9a
Add nested oaf unit tests
hamzashoukat94 Jul 17, 2023
b2d8775
Remove unused import
hamzashoukat94 Jul 18, 2023
e1e575e
DateTime handling
hamzashoukat94 Jul 18, 2023
0e2d994
fixed multiple issues
asadali214 Jul 19, 2023
9c04783
Enum cases handling
hamzashoukat94 Jul 20, 2023
3994671
DateTime assertion
hamzashoukat94 Jul 20, 2023
0e52215
Fixes for sending container types in body, form, query, header
asadali214 Jul 21, 2023
65430e4
Merge branch '47-add-support-for--union-types' of https://github.com/…
asadali214 Jul 21, 2023
02c75ad
issues fixed
hamzashoukat94 Jul 21, 2023
e1bf40e
Container tests
hamzashoukat94 Jul 23, 2023
7494ab8
fixed native dictionary mapping case for union types
asadali214 Jul 24, 2023
cea8bdc
Changed namespaces
hamzashoukat94 Jul 24, 2023
358f4ea
remove unused imports
hamzashoukat94 Jul 24, 2023
15ef0bd
UnionTypeConverter fixes
hamzashoukat94 Jul 24, 2023
d7a82f5
Pick up the spaced token from Json
hamzashoukat94 Jul 24, 2023
b7a650b
Update EnumCaseConverter
hamzashoukat94 Jul 24, 2023
e13fa7a
Added IsProperSubsetOf method in TestHelper along with refactoring an…
asadali214 Jul 25, 2023
a2b0473
Merge branch '47-add-support-for--union-types' of https://github.com/…
asadali214 Jul 25, 2023
cc491c6
fixed null header value test
asadali214 Jul 25, 2023
3fe312b
Handled Enum and Datetime
hamzashoukat94 Jul 25, 2023
2f4ed7d
bumped code coverage to 100% by adding new unit tests to cover newly …
asadali214 Jul 26, 2023
2878f9d
fixed rafactoring issues suggested by code climate
asadali214 Jul 26, 2023
43581a4
change access modifier for 2 TestHelper methods
asadali214 Jul 26, 2023
723f3b0
Code cleanup
hamzashoukat94 Jul 26, 2023
9a8b555
Updated design of NativeAnyOfContainer to replace ICases implementati…
asadali214 Jul 27, 2023
e88748c
Handle header and template dateTime cases
hamzashoukat94 Jul 27, 2023
401cbe2
Incorporate the container's Match method changes in unit tests
hamzashoukat94 Jul 27, 2023
e9237a0
removed early return for strings from CoreHelper's JsonSerialize
asadali214 Jul 31, 2023
0ccacb5
removed unused ICases interface from a testing union type container
asadali214 Jul 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions APIMatic.Core.Test/Api/HttpGet/ApiCallGetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void ApiCall_Get_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
Assert.AreEqual(actual.Data, expected);
}
Expand Down Expand Up @@ -136,7 +136,7 @@ public void ApiCall_GetWithDisableContentType_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
Assert.AreEqual(actual.Data.Message, expected.Message);
}
Expand Down Expand Up @@ -175,7 +175,7 @@ public void ApiCall_GetWithBasicAuthe_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
}

[Test]
Expand Down
96 changes: 96 additions & 0 deletions APIMatic.Core.Test/Api/HttpPost/ApiCallPostContainerTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System.Net;
using System.Net.Http;
using System.Net.Http.Json;
using APIMatic.Core.Test.MockTypes.Models;
using APIMatic.Core.Test.MockTypes.Models.Containers;
using APIMatic.Core.Utilities;
using NUnit.Framework;
using RichardSzalay.MockHttp;

namespace APIMatic.Core.Test.Api.HttpPost
{
[TestFixture]
internal class ApiCallPostContainerTest : ApiCallTest
{
[Test]
public void ApiCall_PostModelAsContainerData_OKResponse()
{
var oneOfAtomOrbit = CustomOneOfContainer.FromAtom(new Atom()
{
Name = "Hydrogen",
NumberOfProtons = 1,
NumberOfElectrons = 1,
});
var expected = new ServerResponse()
{
Passed = true,
};
var url = "/apicall/post-container-model/200";
var contentType = "application/json; charset=utf-8";

var content = JsonContent.Create(expected);
handlerMock.When(GetCompleteUrl(url))
.With(req =>
{
Assert.AreEqual(CoreHelper.JsonSerialize(oneOfAtomOrbit), req.Content.ReadAsStringAsync().Result);
Assert.AreEqual(contentType, req.Content.Headers.ContentType.ToString());
Assert.AreEqual("application/json", req.Headers.Accept.ToString());
return true;
})
.Respond(HttpStatusCode.OK, content);

var apiCall = CreateApiCall<ServerResponse>()
.RequestBuilder(requestBuilderAction => requestBuilderAction
.Setup(HttpMethod.Post, url)
.Parameters(p => p
.Body(b => b.Setup(oneOfAtomOrbit))))
.ExecuteAsync();

// Act
var actual = CoreHelper.RunTask(apiCall);

// Assert
Assert.NotNull(actual);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.AreEqual(expected, actual.Data);
}

[Test]
public void ApiCall_PostStringAsContainerData_OKResponse()
{
var anyOfStringDouble = NativeAnyOfContainer.FromString("some string as request body");
var expected = new ServerResponse()
{
Passed = true,
};
var url = "/apicall/post-container-string/200";
var contentType = "text/plain; charset=utf-8";

var content = JsonContent.Create(expected);
handlerMock.When(GetCompleteUrl(url))
.With(req =>
{
Assert.AreEqual(anyOfStringDouble.ToString(), req.Content.ReadAsStringAsync().Result);
Assert.AreEqual(contentType, req.Content.Headers.ContentType.ToString());
Assert.AreEqual("application/json", req.Headers.Accept.ToString());
return true;
})
.Respond(HttpStatusCode.OK, content);

var apiCall = CreateApiCall<ServerResponse>()
.RequestBuilder(requestBuilderAction => requestBuilderAction
.Setup(HttpMethod.Post, url)
.Parameters(p => p
.Body(b => b.Setup(anyOfStringDouble))))
.ExecuteAsync();

// Act
var actual = CoreHelper.RunTask(apiCall);

// Assert
Assert.NotNull(actual);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.AreEqual(expected, actual.Data);
}
}
}
8 changes: 4 additions & 4 deletions APIMatic.Core.Test/Api/HttpPost/ApiCallPostFileTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void ApiCall_PostFileData_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
}

Expand Down Expand Up @@ -109,7 +109,7 @@ public void ApiCall_PostFileDataWithFileContentType_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
}

Expand Down Expand Up @@ -156,7 +156,7 @@ public void ApiCall_PostFileDataWithContentType_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
}

Expand Down Expand Up @@ -208,7 +208,7 @@ public void ApiCall_PostMultipartForm_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
}
}
Expand Down
4 changes: 2 additions & 2 deletions APIMatic.Core.Test/Api/HttpPost/ApiCallPostStreamTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void ApiCall_PostBodyStream_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
}

Expand Down Expand Up @@ -94,7 +94,7 @@ public void ApiCall_PostBodyStreamWithWrongContentType_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
}
}
Expand Down
24 changes: 11 additions & 13 deletions APIMatic.Core.Test/Api/HttpPost/ApiCallPostTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Net.Http.Json;
Expand Down Expand Up @@ -52,7 +51,7 @@ public void ApiCall_PostBody_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
Assert.AreEqual(actual.Data.Message, expected.Message);
}
Expand Down Expand Up @@ -101,7 +100,7 @@ public void ApiCall_PostMultipleBody_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
Assert.AreEqual(actual.Data.Message, expected.Message);
}
Expand Down Expand Up @@ -143,7 +142,7 @@ public void ApiCall_PostBodyNonScalar_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
Assert.AreEqual(expected.Message, actual.Data.Message);
}
Expand Down Expand Up @@ -188,7 +187,7 @@ public void ApiCall_PostBodyWithContentType_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
Assert.AreEqual(expected.Message, actual.Data.Message);
}
Expand Down Expand Up @@ -231,7 +230,7 @@ public void ApiCall_PostBodyWithEmptyContentType_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
Assert.AreEqual(actual.Data.Message, expected.Message);
}
Expand Down Expand Up @@ -273,7 +272,7 @@ public void ApiCall_PostBinaryBody_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
}

Expand Down Expand Up @@ -401,7 +400,7 @@ public void ApiCall_PostFormData_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
Assert.AreEqual(actual.Data.Message, expected.Message);
}
Expand Down Expand Up @@ -449,7 +448,7 @@ public void ApiCall_PostQueryData_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
Assert.AreEqual(actual.Data.Message, expected.Message);
}
Expand All @@ -473,8 +472,7 @@ public void ApiCall_PostNullHeaderValue_OKResponse()
.With(req =>
{
Assert.AreEqual(text, req.Content.ReadAsStringAsync().Result);
Assert.IsTrue(req.Headers.Contains(headerKey));
Assert.AreEqual(string.Empty, req.Headers.GetValues(headerKey).FirstOrDefault());
Assert.False(req.Headers.Contains(headerKey));
return true;
})
.Respond(HttpStatusCode.OK, content);
Expand All @@ -492,7 +490,7 @@ public void ApiCall_PostNullHeaderValue_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
Assert.AreEqual(actual.Data.Message, expected.Message);
}
Expand Down
4 changes: 2 additions & 2 deletions APIMatic.Core.Test/Api/HttpPost/ApiCallPostXMLTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void ApiCall_PostXmlLong_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
Assert.AreEqual(actual.Data.Message, expected.Message);
}
Expand Down Expand Up @@ -90,7 +90,7 @@ public void ApiCall_PostXmlString_OKResponse()

// Assert
Assert.NotNull(actual);
Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.NotNull(actual.Data);
Assert.AreEqual(actual.Data.Message, expected.Message);
}
Expand Down
6 changes: 3 additions & 3 deletions APIMatic.Core.Test/Http/HttpClientWrapperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task HttpClient_GetCall_200Response()

var actual = await _client.ExecuteAsync(request);

Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.AreEqual(actual.Body, request.Body);
}

Expand All @@ -73,7 +73,7 @@ public async Task TestHttpClientGetCall_400Response()

var actual = await _client.ExecuteAsync(request);

Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.BadRequest);
Assert.AreEqual((int)HttpStatusCode.BadRequest, actual.StatusCode);
Assert.AreEqual(actual.Body, request.Body);
}

Expand Down Expand Up @@ -105,7 +105,7 @@ public async Task TestHttpClientGetCall_200Response()
// Act
var actual = await _client.ExecuteAsync(request);

Assert.AreEqual(actual.StatusCode, (int)HttpStatusCode.OK);
Assert.AreEqual((int)HttpStatusCode.OK, actual.StatusCode);
Assert.AreEqual(customHeaderValue, actual.Headers[customHeaderKey]);
}
}
Expand Down
33 changes: 0 additions & 33 deletions APIMatic.Core.Test/MockTypes/Convertors/ListDateTimeConverter.cs

This file was deleted.

35 changes: 0 additions & 35 deletions APIMatic.Core.Test/MockTypes/Convertors/MapDateTimeConverter.cs

This file was deleted.

Loading