Skip to content

Commit

Permalink
More work in support of #438.
Browse files Browse the repository at this point in the history
  • Loading branch information
uncheckederror committed Apr 19, 2024
1 parent 6049023 commit fc52cc3
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 43 deletions.
30 changes: 19 additions & 11 deletions Messaging.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ public async Task RegisterAClientAsync()
Assert.Equal("https://sms.callpipe.com/swagger/index.html", data.CallbackUrl);
}

// TODO: A Complete functional Test includes these steps:
// 1. Login
// 2. Register a Client
// 3. Verify Routing
// 4. Send Outbound SMS
// 5. Recieve Inbound SMS
// 6. Send Outbound MMS
// 7. Recieve Inbound MMS

[Fact]
public async Task GetAllClientsAsync()
{
Expand All @@ -130,12 +139,11 @@ public async Task CorrectlyFormattedButInvalidMessage()
string route = "/api/inbound/1pcom";
string token = "okereeduePeiquah3yaemohGhae0ie";

var stringContent = new FormUrlEncodedContent(new[]
{
var stringContent = new FormUrlEncodedContent([
new KeyValuePair<string, string>("msisdn", "15555551212"),
new KeyValuePair<string, string>("to", "14445556543"),
new KeyValuePair<string, string>("message", "Your Lyft code is 12345"),
});
]);

var response = await _httpClient.PostAsync($"{route}?token={token}", stringContent);

Expand All @@ -151,7 +159,7 @@ public async Task CorrectlyFormattedButInvalidMessage()
public async Task SendSMSMessageAsync()
{
var _client = await GetHttpClientWithValidBearerTokenAsync();
var message = new SendMessageRequest { MediaURLs = Array.Empty<string>(), Message = "This is an SMS Message test.", MSISDN = "2068589313", To = "2068589312" };
var message = new SendMessageRequest { MediaURLs = [], Message = "This is an SMS Message test.", MSISDN = "2068589313", To = "2068589312" };
var response = await _client.PostAsJsonAsync("/message/send?test=true", message);
var details = await response.Content.ReadFromJsonAsync<SendMessageResponse>();
Assert.NotNull(details);
Expand Down Expand Up @@ -208,7 +216,7 @@ public async Task SendSMSMessageAsync()
public async Task SendSMSGroupMessageAsync()
{
var _client = await GetHttpClientWithValidBearerTokenAsync();
var message = new SendMessageRequest { MediaURLs = Array.Empty<string>(), Message = "This is an SMS Group Message test.", MSISDN = "12068589313", To = "12068589312,12068589313,15036622288" };
var message = new SendMessageRequest { MediaURLs = [], Message = "This is an SMS Group Message test.", MSISDN = "12068589313", To = "12068589312,12068589313,15036622288" };
var response = await _client.PostAsJsonAsync("/message/send?test=true", message);
var details = await response.Content.ReadFromJsonAsync<SendMessageResponse>();
Assert.NotNull(details);
Expand All @@ -220,15 +228,15 @@ public async Task SendSMSGroupMessageAsync()
[Fact]
public async Task MessageSendingTestAsync()
{
var stringContent = new FormUrlEncodedContent(new[]
{
var stringContent = new FormUrlEncodedContent(
[
new KeyValuePair<string, string>("msisdn", "15555551212"),
new KeyValuePair<string, string>("to", "14445556543"),
new KeyValuePair<string, string>("username", _configuration.GetConnectionString("PComNetUsername") ?? string.Empty),
new KeyValuePair<string, string>("password", _configuration.GetConnectionString("PComNetPassword") ?? string.Empty),
new KeyValuePair<string, string>("messagebody", "Your Lyft code is 12345"),

});
]);
var response = await _httpClient.PostAsync("/message/send/test", stringContent);
_output.WriteLine(await response.Content.ReadAsStringAsync());
Assert.True(response.IsSuccessStatusCode);
Expand Down Expand Up @@ -257,12 +265,12 @@ public async Task BadToken()
string route = "/api/inbound/1pcom";
string token = "thisIsNotAValidToken";

var stringContent = new FormUrlEncodedContent(new[]
{
var stringContent = new FormUrlEncodedContent(
[
new KeyValuePair<string, string>("msisdn", "15555551212"),
new KeyValuePair<string, string>("to", "14445556543"),
new KeyValuePair<string, string>("message", "Your Lyft code is 12345"),
});
]);

var response = await _httpClient.PostAsync($"{route}?token={token}", stringContent);
_output.WriteLine(await response.Content.ReadAsStringAsync());
Expand Down
112 changes: 112 additions & 0 deletions Messaging/Migrations/20240418224229_RegistrationTesting.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Messaging/Migrations/20240418224229_RegistrationTesting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Messaging.Migrations
{
/// <inheritdoc />
public partial class RegistrationTesting : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "DateLastTestMessageReceived",
table: "ClientRegistrations",
type: "TEXT",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "DateLastTestMessageReceived",
table: "ClientRegistrations");
}
}
}
5 changes: 4 additions & 1 deletion Messaging/Migrations/MessagingContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ partial class MessagingContextModelSnapshot : ModelSnapshot
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.11");
modelBuilder.HasAnnotation("ProductVersion", "8.0.4");

modelBuilder.Entity("Models.ClientRegistration", b =>
{
Expand All @@ -35,6 +35,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.IsRequired()
.HasColumnType("TEXT");
b.Property<DateTime>("DateLastTestMessageReceived")
.HasColumnType("TEXT");
b.Property<DateTime>("DateRegistered")
.HasColumnType("TEXT");
Expand Down
Loading

0 comments on commit fc52cc3

Please sign in to comment.