generated from FromDoppler/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from FromDoppler/add-get-message-status
Add get message status
- Loading branch information
Showing
7 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using DopplerBeplic.Models.Responses; | ||
using DopplerBeplic.Services.Interfaces; | ||
using Newtonsoft.Json; | ||
|
||
namespace DopplerBeplic.Tests | ||
{ | ||
public class GetTemplateMessageStatusTests | ||
{ | ||
[Fact] | ||
public async Task GET_get_message_status_should_not_authorize_without_token() | ||
{ | ||
var application = new PlaygroundApplication(); | ||
var client = application.CreateClient(); | ||
|
||
var response = await client.GetAsync("/customer/messages/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"); | ||
|
||
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); | ||
Assert.Equal("Bearer", response.Headers.WwwAuthenticate.ToString()); | ||
} | ||
|
||
[Fact] | ||
public async Task GET_get_message_status_should_authorize_super_user_and_returns_status() | ||
{ | ||
var bodyParams = new { }; | ||
|
||
var application = new PlaygroundApplication(); | ||
|
||
var messageId = Guid.NewGuid().ToString(); | ||
|
||
var expectedResponse = new TemplateMessageResponse() | ||
{ | ||
MessageId = messageId, | ||
Status = new List<TemplateMessageStatusResponse>() | ||
{ | ||
new TemplateMessageStatusResponse() | ||
{ | ||
Status = "READ", | ||
StatusDate = DateTime.UtcNow | ||
} | ||
} | ||
}; | ||
|
||
var beplicServiceMock = new Mock<IBeplicService>(); | ||
beplicServiceMock.Setup(x => x.GetMessageStatus(messageId)).ReturnsAsync(expectedResponse); | ||
|
||
application.ConfigureServices(services => services.AddSingleton(beplicServiceMock.Object)); | ||
|
||
var client = application.CreateClient(); | ||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", TestUsersData.Token_Superuser_Expire2033_05_18); | ||
|
||
var response = await client.GetAsync($"/customer/messages/{messageId}"); | ||
|
||
Assert.Equal(HttpStatusCode.OK, response.StatusCode); | ||
|
||
beplicServiceMock.Verify(x => x.GetMessageStatus(messageId), Times.Once); | ||
|
||
var content = await response.Content.ReadAsStringAsync(); | ||
|
||
var messageResponse = JsonConvert.DeserializeObject<TemplateMessageResponse>(content); | ||
|
||
Assert.Equal(messageResponse?.MessageId, expectedResponse.MessageId); | ||
Assert.Equal("READ", messageResponse?.Status?[0].Status); | ||
} | ||
|
||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
doppler-beplic/Models/Responses/BeplicResponses/BeplicTemplateMessageStatusResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace DopplerBeplic.Models.Responses.BeplicResponses | ||
{ | ||
public class BeplicTemplateMessageStatusResponse | ||
{ | ||
public string? Status { get; set; } | ||
public DateTime StatusDate { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
doppler-beplic/Models/Responses/TemplateMessageStatusResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace DopplerBeplic.Models.Responses | ||
{ | ||
public class TemplateMessageStatusResponse | ||
{ | ||
public string? Status { get; set; } | ||
public DateTime StatusDate { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters