Skip to content

Commit e68894c

Browse files
committed
HLR Feature
1 parent d981470 commit e68894c

File tree

7 files changed

+58
-18
lines changed

7 files changed

+58
-18
lines changed

examples/hlr/ListLookups.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Console.WriteLine($"MCC: {r.Country?.MCC}");
1717
Console.WriteLine($"Network name: {r.Network?.Name}");
1818
Console.WriteLine($"MNC: {r.Network?.MNC}");
19-
Console.WriteLine($"Cost: {r.Cost.Points}");
19+
Console.WriteLine($"Cost: {r.Cost}");
2020
Console.WriteLine($"Sent at: {r.SentAt}");
2121
Console.WriteLine($"Error code: {r.ErrorCode}");
2222

smsapi/Api/Response/HLR/LookupResult.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace SMSApi.Api.Response.HLR;
77

88
public record struct LookupResult
99
{
10-
public readonly LookupCost Cost;
10+
public readonly double Cost;
1111

1212
public readonly Country? Country;
1313

@@ -25,16 +25,6 @@ public record struct LookupResult
2525
public readonly DateTime SentAt;
2626
}
2727

28-
public readonly record struct LookupCost
29-
{
30-
public readonly double Points;
31-
32-
public LookupCost(double points)
33-
{
34-
Points = points;
35-
}
36-
}
37-
3828
public readonly record struct Ported
3929
{
4030
[JsonProperty("ported")] public readonly IEnumerable<MCC> PortedFrom;

smsapiTests/Unit/Action/HLR/Fixture/LookupsCollectionMother.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static Dictionary<string, dynamic> Lookups(
1616
string @interface,
1717
Country? country,
1818
Network? network,
19-
LookupCost cost,
19+
double cost,
2020
Ported? ported,
2121
uint? errorCode,
2222
DateTime sentAt

smsapiTests/Unit/Action/HLR/ListLookupsResponseTest.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
using SMSApi.Api;
66
using SMSApi.Api.Action;
77
using SMSApi.Api.Response.Common.Telephony;
8-
using SMSApi.Api.Response.HLR;
98
using smsapiTests.Unit.Action.HLR.Fixture;
109
using smsapiTests.Unit.Fixture;
1110
using smsapiTests.Unit.Helper;
1211

13-
namespace smsapiTests.Unit.Action.Blacklist;
12+
namespace smsapiTests.Unit.Action.HLR;
1413

1514
[TestClass]
1615
public class ListLookupsResponseTest
@@ -39,7 +38,7 @@ public void list_lookups_with_result()
3938
var @interface = "api";
4039
var country = new Country("Poland", 260);
4140
var network = new Network("T-Mobile", 3);
42-
var cost = new LookupCost(1.08);
41+
var cost = 1.08;
4342
var sentAt = DateTime.Now;
4443
var response = LookupsCollectionMother.Lookups(
4544
id,
@@ -78,7 +77,7 @@ public void list_lookups_with_error()
7877
var id = "655B26893332330011B0B297";
7978
var phoneNumber = "48500100100";
8079
var @interface = "api";
81-
var cost = new LookupCost(1.08);
80+
var cost = 1.08;
8281
var sentAt = DateTime.Now;
8382
var response = LookupsCollectionMother.Lookups(
8483
id,

smsapiTests/Unit/Action/HLR/LookupRequestTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
22
using SMSApi.Api.Action;
33

4-
namespace smsapiTests.Unit.Action.Blacklist;
4+
namespace smsapiTests.Unit.Action.HLR;
55

66
[TestClass]
77
public class LookupRequestTest
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Net;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using SMSApi.Api;
4+
using SMSApi.Api.Action;
5+
using smsapiTests.Unit.Fixture;
6+
using smsapiTests.Unit.Helper;
7+
8+
namespace smsapiTests.Unit.Action.HLR;
9+
10+
[TestClass]
11+
public class LookupResponseTest
12+
{
13+
private readonly ProxyStub _proxyStub = new();
14+
15+
[TestMethod]
16+
public void successfully_request_lookup()
17+
{
18+
_proxyStub.SyncExecutionResponse = new HttpResponseEntity(
19+
"[]".ToHttpEntityStreamTask(),
20+
HttpStatusCode.Accepted
21+
);
22+
23+
Lookup().Execute();
24+
25+
Assert.IsTrue(true);
26+
}
27+
28+
private Lookup Lookup()
29+
{
30+
var action = new Lookup("48500500");
31+
action.Proxy(_proxyStub);
32+
33+
return action;
34+
}
35+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.IO;
2+
using System.Text;
3+
using System.Threading.Tasks;
4+
5+
namespace smsapiTests.Unit.Helper;
6+
7+
public static class StringToStreamHelper
8+
{
9+
public static Task<Stream> ToHttpEntityStreamTask(this string @string)
10+
{
11+
var bytes = Encoding.UTF8.GetBytes(@string);
12+
var stream = new MemoryStream(bytes);
13+
14+
return Task.FromResult<Stream>(stream);
15+
}
16+
}

0 commit comments

Comments
 (0)