Skip to content

Commit

Permalink
Added tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
lvukadinovic-ib committed Nov 5, 2024
1 parent 872f547 commit 9376c5b
Show file tree
Hide file tree
Showing 8 changed files with 1,214 additions and 1,294 deletions.
2 changes: 1 addition & 1 deletion ApiClient.Tests/ApiExceptionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void ErrorResponseTest(int errorResponseIndex)
Dictionary<string, string> responseHeaders = new Dictionary<string, string>()
{
{ "Server", "SMS,API" },
{ "X-Request-ID", "1234567898765432100" },
{ "X-Request-ID", "1608758729810312842" },
{ "Content-Type", "application/json; charset=utf-8" }
};

Expand Down
200 changes: 100 additions & 100 deletions ApiClient.Tests/ApiTest.cs

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions ApiClient.Tests/DateTimeSerializationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,12 @@ public class DateTimeSerializationTest
[DataTestMethod]
public void DateTimeFormatDeserializationTest(string dateString, int dateValueIndex)
{
// ARRANGE
DateTimeOffset expected = DateTimeValues[dateValueIndex];

string jsonDate = $"{{\"date\":\"{dateString}\"}}";

// ACT
TestObject actual = JsonConvert.DeserializeObject<TestObject>(jsonDate);
TestObject actual = JsonConvert.DeserializeObject<TestObject>(jsonDate)!;

// ASSERT
Assert.AreEqual(expected, actual.Date);
Assert.AreEqual(expected.Ticks, actual.Date.Ticks);
Assert.AreEqual(expected.Offset, actual.Date.Offset);
Expand All @@ -66,13 +63,10 @@ public void DateTimeFormatDeserializationTest(string dateString, int dateValueIn
[DataTestMethod]
public void DateTimeFormatSerializationTest(int dateValueIndex, string expected)
{
// ARRANGE
DateTimeOffset initialDate = DateTimeValues[dateValueIndex];

// ACT
string actual = JsonConvert.SerializeObject(initialDate);

// ASSERT
Assert.AreEqual($"\"{expected}\"", actual);
}

Expand Down
1,158 changes: 564 additions & 594 deletions ApiClient.Tests/EmailApiTest.cs

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions ApiClient.Tests/GeneralSetupTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class GeneralSetupTest : ApiTest
protected const string SMS_SEND_TEXT_ADVANCED_ENDPOINT = "/sms/2/text/advanced";

[TestMethod]
public void UsingExampleFromDocs() // Here is for debugging only
public void UsingExampleFromDocs()
{
string expectedRequest = @"
string givenRequest = @"
{
""messages"": [
{
Expand Down Expand Up @@ -48,20 +48,20 @@ public class GeneralSetupTest : ApiTest
]
}";

SetUpPostRequest(SMS_SEND_TEXT_ADVANCED_ENDPOINT, new Dictionary<string, string> { { "param1", "val1" } }, expectedRequest, expectedResponse, 200);
SetUpPostRequest(SMS_SEND_TEXT_ADVANCED_ENDPOINT, new Dictionary<string, string> { { "param1", "val1" } }, givenRequest, expectedResponse, 200);

var client = new RestClient(configuration.BasePath + SMS_SEND_TEXT_ADVANCED_ENDPOINT);
client.UserAgent = "infobip-api-client-csharp/" + Configuration.Version;
client.Timeout = -1;
var client = new RestClient(configuration!.BasePath + SMS_SEND_TEXT_ADVANCED_ENDPOINT)
{
UserAgent = "infobip-api-client-csharp/" + Configuration.Version,
Timeout = -1
};
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", configuration.ApiKeyWithPrefix);
request.AddHeader("Content-Type", "application/json; charset=utf-8");
request.AddHeader("Accept", "application/json");
request.AddQueryParameter("param1", "val1");
request.AddParameter("application/json", expectedRequest, ParameterType.RequestBody);
request.AddParameter("application/json", givenRequest, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
//Console.WriteLine(response.Content);
Console.WriteLine(wireMockServer.LogEntries);

Assert.IsNotNull(response);
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
Expand Down
13 changes: 1 addition & 12 deletions ApiClient.Tests/SmsApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ void SmsResponseAssertion(SmsResponse smsResponse)

AssertResponseWithHttpInfo(smsApi.SendSmsMessageWithHttpInfo(smsRequest), SmsResponseAssertion);
AssertResponseWithHttpInfo(smsApi.SendSmsMessageWithHttpInfoAsync(smsRequest).Result, SmsResponseAssertion);

//Console.WriteLine(wireMockServer.LogEntries);
}


Expand Down Expand Up @@ -254,10 +252,6 @@ public void ShouldSendFullyFeaturedSmsMessage()
}}
}}";

// TODO check if we need to emit default values for deliveryTimeWindow
//,
//""minute"": { givenDeliveryTimeFromMinuteMessage2}

string givenBulkId = "BULK-ID-123-xyz";
string givenTracking = "SMS";
string givenTrackingType = "MY_CAMPAIGN";
Expand Down Expand Up @@ -401,9 +395,7 @@ public void ShouldSendFullyFeaturedBinaryMessage()
""callbackData"": ""{givenCallbackDataMessage1}"",
""validityPeriod"": {givenValidityPeriodMessage1}
}}";
//,
// ""dataCoding"": { givenDataCodingMessage1},
// ""esmClass"": { givenEsmClassMessage1}

string givenFromMessage2 = "41793026700";
string givenToMessage2 = "41793026700";
string givenHexMessage2 = "54 65 73 74 20 6d 65 73 73 61 67 65 2e";
Expand Down Expand Up @@ -453,9 +445,6 @@ public void ShouldSendFullyFeaturedBinaryMessage()
}}
}}";

//,
// ""dataCoding"": { givenDataCodingMessage2},
// ""esmClass"": { givenEsmClassMessage2}
string givenBulkId = "BULK-ID-123-xyz";
int givenSendingSpeedLimitAmount = 10;
string givenSendingSpeedLimitTimeUnitString = "HOUR";
Expand Down
Loading

0 comments on commit 9376c5b

Please sign in to comment.