Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marked ProviderId as required in Message #217

Merged
merged 2 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);

}

}