Beispiel #1
0
        public void Throw_NullTweetException_When_TweetIsNotFound()
        {
            // Arrange
            this.collectionsRepositoryStub
            .Setup(x => x.All)
            .Returns(
                new List <Collection>()
            {
                new Collection()
                {
                    Id = "collectionId"
                }
            }.AsQueryable()
                );

            var collectionServie = new global::RTWTR.Service.Data.CollectionService(
                this.saverStub.Object,
                this.mapperStub.Object,
                this.collectionsRepositoryStub.Object,
                this.tweetsRepositoryStub.Object,
                this.collectionTweetsRepositoryStub.Object
                );

            // Act & Assert
            Assert.ThrowsException <NullTweetException>(() =>
            {
                collectionServie.AddTweetToCollection("collectionId", "tweetId");
            });
        }
Beispiel #2
0
        public void Call_Saver_SaveChanges_Once()
        {
            // Arrange
            this.saverStub
            .Setup(x => x.SaveChanges())
            .Returns(1)
            .Verifiable();

            this.collectionsRepositoryStub
            .Setup(x => x.All)
            .Returns(
                new List <Collection>()
            {
                new Collection()
                {
                    Id = "collectionId"
                }
            }.AsQueryable()
                );

            this.tweetsRepositoryStub
            .Setup(x => x.All)
            .Returns(
                new List <Tweet>()
            {
                new Tweet()
                {
                    Id = "tweetId"
                }
            }.AsQueryable()
                );

            var collectionServie = new global::RTWTR.Service.Data.CollectionService(
                this.saverStub.Object,
                this.mapperStub.Object,
                this.collectionsRepositoryStub.Object,
                this.tweetsRepositoryStub.Object,
                this.collectionTweetsRepositoryStub.Object
                );

            // Act
            collectionServie.AddTweetToCollection("collectionId", "tweetId");

            // Assert
            this.saverStub.Verify(
                x => x.SaveChanges(),
                Times.Once
                );
        }
Beispiel #3
0
        public void Throw_InvalidTweetIdException_When_TweetIdIsEmpty()
        {
            // Arrange
            var collectionServie = new global::RTWTR.Service.Data.CollectionService(
                this.saverStub.Object,
                this.mapperStub.Object,
                this.collectionsRepositoryStub.Object,
                this.tweetsRepositoryStub.Object,
                this.collectionTweetsRepositoryStub.Object
                );

            // Act & Assert
            Assert.ThrowsException <InvalidTweetIdException>(() =>
            {
                collectionServie.AddTweetToCollection("collectionId", " ");
            });
        }
Beispiel #4
0
        public void Throw_NullCollectionException_When_CollectionIsNotFound()
        {
            // Arrange
            var collectionServie = new global::RTWTR.Service.Data.CollectionService(
                this.saverStub.Object,
                this.mapperStub.Object,
                this.collectionsRepositoryStub.Object,
                this.tweetsRepositoryStub.Object,
                this.collectionTweetsRepositoryStub.Object
                );

            // Act & Assert
            Assert.ThrowsException <NullCollectionException>(() =>
            {
                collectionServie.AddTweetToCollection("collectionId", "tweetId");
            });
        }
Beispiel #5
0
        public void Return_One_When_SuccessfullyAddedUserToFavourites()
        {
            // Arrange
            this.saverStub
            .Setup(x => x.SaveChanges())
            .Returns(1);

            this.collectionsRepositoryStub
            .Setup(x => x.All)
            .Returns(
                new List <Collection>()
            {
                new Collection()
                {
                    Id = "collectionId"
                }
            }.AsQueryable()
                );

            this.tweetsRepositoryStub
            .Setup(x => x.All)
            .Returns(
                new List <Tweet>()
            {
                new Tweet()
                {
                    Id = "tweetId"
                }
            }.AsQueryable()
                );

            var collectionServie = new global::RTWTR.Service.Data.CollectionService(
                this.saverStub.Object,
                this.mapperStub.Object,
                this.collectionsRepositoryStub.Object,
                this.tweetsRepositoryStub.Object,
                this.collectionTweetsRepositoryStub.Object
                );

            // Act & Assert
            Assert.AreEqual(
                1,
                collectionServie.AddTweetToCollection("collectionId", "tweetId")
                );
        }