Skip to content

Commit

Permalink
Marked ProviderId as required in Message (#217)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
csharpfritz and github-actions[bot] authored Sep 24, 2023
1 parent 6469571 commit 990159a
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 91 deletions.
8 changes: 1 addition & 7 deletions src/TagzApp.Common/Models/Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ public class Content
/// </summary>
public required string Provider { get; set; }

/// <summary>
/// Id provided by the provider for this content
/// </summary>
// TODO: CS8618: Non-nullable field is uninitialized. Consider declaring as nullable.
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public string ProviderId { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public required string ProviderId { get; set; }

public string HashtagSought { get; set; } = string.Empty;

Expand Down
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]);

}

}
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);

}

}

0 comments on commit 990159a

Please sign in to comment.