-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Marked ProviderId as required in Message (#217)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
6469571
commit 990159a
Showing
3 changed files
with
85 additions
and
91 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
83 changes: 41 additions & 42 deletions
83
src/TagzApp.UnitTest/InMemoryMessaging/GivenNoSubscribers/WhenPublishingMessages.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 |
---|---|---|
@@ -1,42 +1,41 @@ | ||
using TagzApp.Common.Models; | ||
|
||
namespace TagzApp.UnitTest.InMemoryMessaging.GivenNoSubscribers; | ||
|
||
public class WhenPublishingMessages : BaseFixture | ||
{ | ||
|
||
private Hashtag _Tag = new Hashtag() { Text = "test" }; | ||
|
||
// Arrange - PUBLISH SOME MESSAGES | ||
private async Task Arrange() | ||
{ | ||
|
||
await _Sut.PublishContentAsync(_Tag, new Content | ||
{ | ||
Author = new Creator | ||
{ | ||
DisplayName = "Testy McTestface", | ||
ProfileImageUri = new Uri("http://myta.g"), | ||
ProfileUri = new Uri("http://myta.gg"), | ||
}, | ||
Provider = "TEST", | ||
SourceUri = new Uri("http://myta.gg/1"), | ||
Text = "This is a test", | ||
Timestamp = DateTimeOffset.Now, | ||
Type = ContentType.Message | ||
}); | ||
} | ||
|
||
[Fact] | ||
public async Task ShouldNotHoldMessages() | ||
{ | ||
|
||
await Arrange(); | ||
|
||
await Task.Delay(200); | ||
|
||
Assert.Empty(_Sut.Queue[_Tag.Text]); | ||
|
||
} | ||
|
||
} | ||
namespace TagzApp.UnitTest.InMemoryMessaging.GivenNoSubscribers; | ||
|
||
public class WhenPublishingMessages : BaseFixture | ||
{ | ||
|
||
private Hashtag _Tag = new() { Text = "test" }; | ||
|
||
// Arrange - PUBLISH SOME MESSAGES | ||
private async Task Arrange() | ||
{ | ||
|
||
await _Sut.PublishContentAsync(_Tag, new Content | ||
{ | ||
Author = new Creator | ||
{ | ||
DisplayName = "Testy McTestface", | ||
ProfileImageUri = new Uri("http://myta.g"), | ||
ProfileUri = new Uri("http://myta.gg"), | ||
}, | ||
Provider = "TEST", | ||
ProviderId = "test-id", | ||
SourceUri = new Uri("http://myta.gg/1"), | ||
Text = "This is a test", | ||
Timestamp = DateTimeOffset.Now, | ||
Type = ContentType.Message | ||
}); | ||
} | ||
|
||
[Fact] | ||
public async Task ShouldNotHoldMessages() | ||
{ | ||
|
||
await Arrange(); | ||
|
||
await Task.Delay(200); | ||
|
||
Assert.Empty(_Sut.Queue[_Tag.Text]); | ||
|
||
} | ||
|
||
} |
85 changes: 43 additions & 42 deletions
85
src/TagzApp.UnitTest/InMemoryMessaging/GivenOneSubscriber/WhenPublishingMessages.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 |
---|---|---|
@@ -1,42 +1,43 @@ | ||
namespace TagzApp.UnitTest.InMemoryMessaging.GivenOneSubscriber; | ||
public class WhenPublishingMessages | ||
{ | ||
|
||
protected InMemoryContentMessaging _Sut = new InMemoryContentMessaging(); | ||
|
||
private readonly Hashtag _Tag = new() { Text = "Test" }; | ||
|
||
private readonly Content _Content = new() | ||
{ | ||
Author = new Creator | ||
{ | ||
DisplayName = "Testy McTestface", | ||
ProfileImageUri = new Uri("http://myta.g"), | ||
ProfileUri = new Uri("http://myta.gg"), | ||
}, | ||
Provider = "TEST", | ||
SourceUri = new Uri("http://myta.gg/1"), | ||
Text = "This is a test", | ||
Timestamp = DateTimeOffset.Now, | ||
Type = ContentType.Message | ||
}; | ||
|
||
[Fact] | ||
public async Task ShouldPublishMessage() | ||
{ | ||
|
||
// Arrange | ||
Content published = null!; | ||
_Sut.SubscribeToContent(_Tag, (content) => published = content); | ||
|
||
// Act | ||
await _Sut.PublishContentAsync(_Tag, _Content); | ||
await Task.Delay(200); | ||
|
||
// Assert | ||
Assert.NotNull(published); | ||
Assert.Equal("This is a test", published.Text); | ||
|
||
} | ||
|
||
} | ||
namespace TagzApp.UnitTest.InMemoryMessaging.GivenOneSubscriber; | ||
public class WhenPublishingMessages | ||
{ | ||
|
||
protected InMemoryContentMessaging _Sut = new(); | ||
|
||
private readonly Hashtag _Tag = new() { Text = "Test" }; | ||
|
||
private readonly Content _Content = new() | ||
{ | ||
Author = new Creator | ||
{ | ||
DisplayName = "Testy McTestface", | ||
ProfileImageUri = new Uri("http://myta.g"), | ||
ProfileUri = new Uri("http://myta.gg"), | ||
}, | ||
Provider = "TEST", | ||
ProviderId = "test-id", | ||
SourceUri = new Uri("http://myta.gg/1"), | ||
Text = "This is a test", | ||
Timestamp = DateTimeOffset.Now, | ||
Type = ContentType.Message | ||
}; | ||
|
||
[Fact] | ||
public async Task ShouldPublishMessage() | ||
{ | ||
|
||
// Arrange | ||
Content published = null!; | ||
_Sut.SubscribeToContent(_Tag, (content) => published = content); | ||
|
||
// Act | ||
await _Sut.PublishContentAsync(_Tag, _Content); | ||
await Task.Delay(200); | ||
|
||
// Assert | ||
Assert.NotNull(published); | ||
Assert.Equal("This is a test", published.Text); | ||
|
||
} | ||
|
||
} |