Beispiel #1
0
        public void Invoke_SaveChanges_On_UnitOfWork_When_Found()
        {
            //Arrange
            var fakeUnit             = new Mock <IUnitOfWork>();
            var fakeDateTimeProvider = Mock.Of <IDateTimeProvider>();
            var fakeTweetService     = Mock.Of <ITweetService>();
            var sut = new UserTweetService(fakeUnit.Object, fakeTweetService, fakeDateTimeProvider);

            var fakeUserTweetRepo = new Mock <IGenericRepository <UserTweet> >();
            var userTweet         = new UserTweet {
                TweetId = "789", UserId = "123"
            };
            var userTweetCollection = new List <UserTweet> {
                userTweet
            };

            fakeUserTweetRepo.Setup(r => r.All).Returns(userTweetCollection.AsQueryable());
            fakeUnit.Setup(u => u.UserTweets).Returns(fakeUserTweetRepo.Object);
            fakeUnit.Setup(s => s.SaveChanges()).Verifiable();

            //Act
            sut.DeleteUserTweet("123", "789");

            //Assert
            fakeUnit.Verify(v => v.SaveChanges(), Times.Once);
        }
Beispiel #2
0
        public void Throw_Argument_Null_Exception_When_TweetId_Is_Null()
        {
            //Arrange
            var fakeTimeProvider = Mock.Of <IDateTimeProvider>();
            var fakeUnit         = Mock.Of <IUnitOfWork>();
            var fakeTweetService = Mock.Of <ITweetService>();
            var sut = new UserTweetService(fakeUnit, fakeTweetService, fakeTimeProvider);

            //Act & Assert
            Assert.ThrowsException <ArgumentNullException>(() => sut.DeleteUserTweet("123", null));
        }