Skip to content

Fixed an issue with ambiguous Unsubscribe and introduced Consume #10

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,20 @@ public interface ITestMessageInterface : ITinyMessage
public class InterfaceDerivedMessage<TThings> : ITestMessageInterface
{
public object Sender { get; private set; }
public bool Consume { get; private set; }

public TThings Things { get; set; }

public InterfaceDerivedMessage(object sender)
public InterfaceDerivedMessage(object sender) : this(sender, false)
{
}

public InterfaceDerivedMessage(object sender, bool consume)
{
this.Sender = sender;
this.Consume = consume;
}
}
}

public class TestProxy : ITinyMessageProxy
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ public class TinyMessageSubscriptionTokenTests
public void Dispose_WithValidHubReference_UnregistersWithHub()
{
var messengerMock = new Moq.Mock<ITinyMessengerHub>();

messengerMock.Setup((messenger) => messenger.Unsubscribe<TestMessage>(Moq.It.IsAny<TinyMessageSubscriptionToken>())).Verifiable();

var token = new TinyMessageSubscriptionToken(messengerMock.Object, typeof(TestMessage));

token.Dispose();

messengerMock.VerifyAll();
}

[TestMethod]
public void Dispose_WithInvalidHubReference_DoesNotThrow()
{
var token = UtilityMethods.GetTokenWithOutOfScopeMessenger();

GC.Collect();
GC.WaitForFullGCComplete(2000);

Expand All @@ -38,7 +40,6 @@ public void Dispose_WithInvalidHubReference_DoesNotThrow()
public void Ctor_NullHub_ThrowsArgumentNullException()
{
var messenger = UtilityMethods.GetMessenger();

var token = new TinyMessageSubscriptionToken(null, typeof(ITinyMessage));
}

Expand All @@ -47,15 +48,13 @@ public void Ctor_NullHub_ThrowsArgumentNullException()
public void Ctor_InvalidMessageType_ThrowsArgumentOutOfRangeException()
{
var messenger = UtilityMethods.GetMessenger();

var token = new TinyMessageSubscriptionToken(messenger, typeof(object));
}

[TestMethod]
public void Ctor_ValidHubAndMessageType_DoesNotThrow()
{
var messenger = UtilityMethods.GetMessenger();

var token = new TinyMessageSubscriptionToken(messenger, typeof(TestMessage));
}
}
Expand Down
Loading