Skip to content

Commit

Permalink
Refactor observer naming in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasweimann committed Nov 8, 2023
1 parent a68c9a3 commit ce286d0
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions src/UnitTests/UpdateManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ public void Given_NoObserver_On_RunUpdate_Should_Return()
public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_Observers()
{
// Arrange
var observerAll = Substitute.For<IObserver<Update>>();
var observer = Substitute.For<IObserver<Update>>();
var updateManager = new UpdateManager(_telegramBotMock);
var disposableAll = updateManager.Update.Subscribe(observerAll);
var disposableAll = updateManager.Update.Subscribe(observer);
var updates = new[] { new Update { Message = new Message() } };

// Act
updateManager.DistributeUpdates(updates);

// Assert
observerAll.Received()
observer.Received()
.OnNext(updates.Single());
disposableAll.Dispose();
}
Expand Down Expand Up @@ -172,16 +172,16 @@ public void OnException_WhenCalled_DistributesExceptionToObservers(UpdateType up
public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_MessageObservers()
{
// Arrange
var observerAll = Substitute.For<IObserver<Message>>();
var observer = Substitute.For<IObserver<Message>>();
var updateManager = new UpdateManager(_telegramBotMock);
var disposableAll = updateManager.Message.Subscribe(observerAll);
var disposableAll = updateManager.Message.Subscribe(observer);
var updates = new[] { new Update { Message = new Message() } };

// Act
updateManager.DistributeUpdates(updates);

// Assert
observerAll.Received()
observer.Received()
.OnNext(updates.Single()
.Message);
disposableAll.Dispose();
Expand All @@ -191,16 +191,16 @@ public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_MessageO
public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_EditedMessageObservers()
{
// Arrange
var observerAll = Substitute.For<IObserver<Message>>();
var observer = Substitute.For<IObserver<Message>>();
var updateManager = new UpdateManager(_telegramBotMock);
var disposableAll = updateManager.EditedMessage.Subscribe(observerAll);
var disposableAll = updateManager.EditedMessage.Subscribe(observer);
var updates = new[] { new Update { EditedMessage = new Message() } };

// Act
updateManager.DistributeUpdates(updates);

// Assert
observerAll.Received()
observer.Received()
.OnNext(updates.Single()
.EditedMessage);
disposableAll.Dispose();
Expand All @@ -210,16 +210,16 @@ public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_EditedMe
public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_InlineQueryObservers()
{
// Arrange
var observerAll = Substitute.For<IObserver<InlineQuery>>();
var observer = Substitute.For<IObserver<InlineQuery>>();
var updateManager = new UpdateManager(_telegramBotMock);
var disposableAll = updateManager.InlineQuery.Subscribe(observerAll);
var disposableAll = updateManager.InlineQuery.Subscribe(observer);
var updates = new[] { new Update { InlineQuery = new InlineQuery() } };

// Act
updateManager.DistributeUpdates(updates);

// Assert
observerAll.Received()
observer.Received()
.OnNext(updates.Single()
.InlineQuery);
disposableAll.Dispose();
Expand All @@ -229,16 +229,16 @@ public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_InlineQu
public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_ChosenInlineResultObservers()
{
// Arrange
var observerAll = Substitute.For<IObserver<ChosenInlineResult>>();
var observer = Substitute.For<IObserver<ChosenInlineResult>>();
var updateManager = new UpdateManager(_telegramBotMock);
var disposableAll = updateManager.ChosenInlineResult.Subscribe(observerAll);
var disposableAll = updateManager.ChosenInlineResult.Subscribe(observer);
var updates = new[] { new Update { ChosenInlineResult = new ChosenInlineResult() } };

// Act
updateManager.DistributeUpdates(updates);

// Assert
observerAll.Received()
observer.Received()
.OnNext(updates.Single()
.ChosenInlineResult);
disposableAll.Dispose();
Expand All @@ -248,16 +248,16 @@ public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_ChosenIn
public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_CallbackQueryObservers()
{
// Arrange
var observerAll = Substitute.For<IObserver<CallbackQuery>>();
var observer = Substitute.For<IObserver<CallbackQuery>>();
var updateManager = new UpdateManager(_telegramBotMock);
var disposableAll = updateManager.CallbackQuery.Subscribe(observerAll);
var disposableAll = updateManager.CallbackQuery.Subscribe(observer);
var updates = new[] { new Update { CallbackQuery = new CallbackQuery() } };

// Act
updateManager.DistributeUpdates(updates);

// Assert
observerAll.Received()
observer.Received()
.OnNext(updates.Single()
.CallbackQuery);
disposableAll.Dispose();
Expand All @@ -267,16 +267,16 @@ public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_Callback
public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_ChannelPostObservers()
{
// Arrange
var observerAll = Substitute.For<IObserver<Message>>();
var observer = Substitute.For<IObserver<Message>>();
var updateManager = new UpdateManager(_telegramBotMock);
var disposableAll = updateManager.ChannelPost.Subscribe(observerAll);
var disposableAll = updateManager.ChannelPost.Subscribe(observer);
var updates = new[] { new Update { ChannelPost = new Message() } };

// Act
updateManager.DistributeUpdates(updates);

// Assert
observerAll.Received()
observer.Received()
.OnNext(updates.Single()
.ChannelPost);
disposableAll.Dispose();
Expand All @@ -286,16 +286,16 @@ public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_ChannelP
public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_EditedChannelPostObservers()
{
// Arrange
var observerAll = Substitute.For<IObserver<Message>>();
var observer = Substitute.For<IObserver<Message>>();
var updateManager = new UpdateManager(_telegramBotMock);
var disposableAll = updateManager.EditedChannelPost.Subscribe(observerAll);
var disposableAll = updateManager.EditedChannelPost.Subscribe(observer);
var updates = new[] { new Update { EditedChannelPost = new Message() } };

// Act
updateManager.DistributeUpdates(updates);

// Assert
observerAll.Received()
observer.Received()
.OnNext(updates.Single()
.EditedChannelPost);
disposableAll.Dispose();
Expand All @@ -305,16 +305,16 @@ public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_EditedCh
public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_ShippingQueryObservers()
{
// Arrange
var observerAll = Substitute.For<IObserver<ShippingQuery>>();
var observer = Substitute.For<IObserver<ShippingQuery>>();
var updateManager = new UpdateManager(_telegramBotMock);
var disposableAll = updateManager.ShippingQuery.Subscribe(observerAll);
var disposableAll = updateManager.ShippingQuery.Subscribe(observer);
var updates = new[] { new Update { ShippingQuery = new ShippingQuery() } };

// Act
updateManager.DistributeUpdates(updates);

// Assert
observerAll.Received()
observer.Received()
.OnNext(updates.Single()
.ShippingQuery);
disposableAll.Dispose();
Expand All @@ -324,16 +324,16 @@ public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_Shipping
public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_PreCheckoutQueryObservers()
{
// Arrange
var observerAll = Substitute.For<IObserver<PreCheckoutQuery>>();
var observer = Substitute.For<IObserver<PreCheckoutQuery>>();
var updateManager = new UpdateManager(_telegramBotMock);
var disposableAll = updateManager.PreCheckoutQuery.Subscribe(observerAll);
var disposableAll = updateManager.PreCheckoutQuery.Subscribe(observer);
var updates = new[] { new Update { PreCheckoutQuery = new PreCheckoutQuery() } };

// Act
updateManager.DistributeUpdates(updates);

// Assert
observerAll.Received()
observer.Received()
.OnNext(updates.Single()
.PreCheckoutQuery);
disposableAll.Dispose();
Expand All @@ -343,16 +343,16 @@ public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_PreCheck
public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_PollObservers()
{
// Arrange
var observerAll = Substitute.For<IObserver<Poll>>();
var observer = Substitute.For<IObserver<Poll>>();
var updateManager = new UpdateManager(_telegramBotMock);
var disposableAll = updateManager.Poll.Subscribe(observerAll);
var disposableAll = updateManager.Poll.Subscribe(observer);
var updates = new[] { new Update { Poll = new Poll() } };

// Act
updateManager.DistributeUpdates(updates);

// Assert
observerAll.Received()
observer.Received()
.OnNext(updates.Single()
.Poll);
disposableAll.Dispose();
Expand All @@ -362,16 +362,16 @@ public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_PollObse
public void Given_ValidUpdate_On_DistributeUpdates_Should_PushUpdatesTo_PollAnswerObservers()
{
// Arrange
var observerAll = Substitute.For<IObserver<PollAnswer>>();
var observer = Substitute.For<IObserver<PollAnswer>>();
var updateManager = new UpdateManager(_telegramBotMock);
var disposableAll = updateManager.PollAnswer.Subscribe(observerAll);
var disposableAll = updateManager.PollAnswer.Subscribe(observer);
var updates = new[] { new Update { PollAnswer = new PollAnswer() } };

// Act
updateManager.DistributeUpdates(updates);

// Assert
observerAll.Received()
observer.Received()
.OnNext(updates.Single()
.PollAnswer);
disposableAll.Dispose();
Expand Down

0 comments on commit ce286d0

Please sign in to comment.