From 12e4b36defb9fc7912c3d192d366723ab79a414c Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Sun, 5 Sep 2021 14:10:46 -0400 Subject: [PATCH] fix tests --- .../RetrieveTweetsProcessorTests.cs | 36 +++++++++++-------- .../StatusPublicationPipelineTests.cs | 3 +- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTweetsProcessorTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTweetsProcessorTests.cs index 38b750c..17a3aa2 100644 --- a/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTweetsProcessorTests.cs +++ b/src/Tests/BirdsiteLive.Pipeline.Tests/Processors/RetrieveTweetsProcessorTests.cs @@ -4,6 +4,7 @@ using System.Threading; using System.Threading.Tasks; using BirdsiteLive.DAL.Contracts; using BirdsiteLive.DAL.Models; +using BirdsiteLive.Pipeline.Models; using BirdsiteLive.Pipeline.Processors; using BirdsiteLive.Twitter; using BirdsiteLive.Twitter.Models; @@ -27,9 +28,14 @@ namespace BirdsiteLive.Pipeline.Tests.Processors LastTweetPostedId = -1 }; + var user1WtData = new UserWithDataToSync + { + User = user1, + }; + var users = new[] { - user1 + user1WtData }; var tweets = new[] @@ -57,14 +63,12 @@ namespace BirdsiteLive.Pipeline.Tests.Processors It.Is(y => y == user1.Id), It.Is(y => y == tweets.Last().Id), It.Is(y => y == tweets.Last().Id), + It.Is(y => y == 0), It.IsAny() )) .Returns(Task.CompletedTask); var twitterUserServiceMock = new Mock(MockBehavior.Strict); - twitterUserServiceMock - .Setup(x => x.GetUser(It.Is(y => y == user1.Acct))) - .Returns(new TwitterUser {Protected = false}); var logger = new Mock>(MockBehavior.Strict); #endregion @@ -94,9 +98,14 @@ namespace BirdsiteLive.Pipeline.Tests.Processors LastTweetSynchronizedForAllFollowersId = 46 }; + var user1WtData = new UserWithDataToSync + { + User = user1, + }; + var users = new[] { - user1 + user1WtData }; var tweets = new[] @@ -129,9 +138,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors var twitterUserDalMock = new Mock(MockBehavior.Strict); var twitterUserServiceMock = new Mock(MockBehavior.Strict); - twitterUserServiceMock - .Setup(x => x.GetUser(It.Is(y => y == user1.Acct))) - .Returns(new TwitterUser { Protected = false }); var logger = new Mock>(MockBehavior.Strict); #endregion @@ -147,7 +153,7 @@ namespace BirdsiteLive.Pipeline.Tests.Processors Assert.AreEqual(users.Length, usersResult.Length); - Assert.AreEqual(users[0].Acct, usersResult[0].User.Acct); + Assert.AreEqual(users[0].User.Acct, usersResult[0].User.Acct); Assert.AreEqual(tweets.Length, usersResult[0].Tweets.Length); #endregion } @@ -164,9 +170,14 @@ namespace BirdsiteLive.Pipeline.Tests.Processors LastTweetSynchronizedForAllFollowersId = 46 }; + var user1WtData = new UserWithDataToSync + { + User = user1, + }; + var users = new[] { - user1 + user1WtData }; var tweets = new[] @@ -199,9 +210,6 @@ namespace BirdsiteLive.Pipeline.Tests.Processors var twitterUserDalMock = new Mock(MockBehavior.Strict); var twitterUserServiceMock = new Mock(MockBehavior.Strict); - twitterUserServiceMock - .Setup(x => x.GetUser(It.Is(y => y == user1.Acct))) - .Returns(new TwitterUser { Protected = false }); var logger = new Mock>(MockBehavior.Strict); #endregion @@ -216,7 +224,7 @@ namespace BirdsiteLive.Pipeline.Tests.Processors logger.VerifyAll(); Assert.AreEqual(users.Length, usersResult.Length); - Assert.AreEqual(users[0].Acct, usersResult[0].User.Acct); + Assert.AreEqual(users[0].User.Acct, usersResult[0].User.Acct); Assert.AreEqual(tweets.Length, usersResult[0].Tweets.Length); #endregion } diff --git a/src/Tests/BirdsiteLive.Pipeline.Tests/StatusPublicationPipelineTests.cs b/src/Tests/BirdsiteLive.Pipeline.Tests/StatusPublicationPipelineTests.cs index 2a47b95..81eeb59 100644 --- a/src/Tests/BirdsiteLive.Pipeline.Tests/StatusPublicationPipelineTests.cs +++ b/src/Tests/BirdsiteLive.Pipeline.Tests/StatusPublicationPipelineTests.cs @@ -27,6 +27,7 @@ namespace BirdsiteLive.Pipeline.Tests It.IsAny())) .Returns(Task.Delay(0)); + var refreshTwitterUserStatusProcessor = new Mock(MockBehavior.Strict); var retrieveTweetsProcessor = new Mock(MockBehavior.Strict); var retrieveFollowersProcessor = new Mock(MockBehavior.Strict); var sendTweetsToFollowersProcessor = new Mock(MockBehavior.Strict); @@ -34,7 +35,7 @@ namespace BirdsiteLive.Pipeline.Tests var logger = new Mock>(); #endregion - var pipeline = new StatusPublicationPipeline(retrieveTweetsProcessor.Object, retrieveTwitterUsersProcessor.Object, retrieveFollowersProcessor.Object, sendTweetsToFollowersProcessor.Object, saveProgressionProcessor.Object, logger.Object); + var pipeline = new StatusPublicationPipeline(retrieveTweetsProcessor.Object, retrieveTwitterUsersProcessor.Object, retrieveFollowersProcessor.Object, sendTweetsToFollowersProcessor.Object, saveProgressionProcessor.Object, refreshTwitterUserStatusProcessor.Object, logger.Object); await pipeline.ExecuteAsync(ct.Token); #region Validations