コード例 #1
0
        public void Call_CollectionRepository_All_Once()
        {
            // Arrange
            this.collectionRepositoryStub
            .Setup(x => x.All)
            .Returns(
                new List <Collection>()
            {
                new Collection()
                {
                    Id = "collectionId"
                }
            }.AsQueryable()
                )
            .Verifiable();

            var collectionService = new global::RTWTR.Service.Data.CollectionService(
                saverStub.Object,
                mapperStub.Object,
                collectionRepositoryStub.Object,
                tweetRepositoryStub.Object,
                collectionTweetsRepositoryStub.Object
                );

            // Act
            collectionService.RemoveCollection("collectionId");

            // Assert
            this.collectionRepositoryStub.Verify(
                x => x.All,
                Times.Once
                );
        }
コード例 #2
0
        public void ReturnOne_When_CollectionSuccessfullyRemoved()
        {
            // Arrange
            this.collectionRepositoryStub
            .Setup(x => x.All)
            .Returns(
                new List <Collection>()
            {
                new Collection()
                {
                    Id = "collectionId"
                }
            }.AsQueryable()
                );

            this.saverStub
            .Setup(x => x.SaveChanges())
            .Returns(1);

            var collectionService = new global::RTWTR.Service.Data.CollectionService(
                saverStub.Object,
                mapperStub.Object,
                collectionRepositoryStub.Object,
                tweetRepositoryStub.Object,
                collectionTweetsRepositoryStub.Object
                );

            // Act & Assert
            Assert.AreEqual(
                1,
                collectionService.RemoveCollection("collectionId")
                );
        }
コード例 #3
0
        public void Throw_NullCollectionException_When_CollectionIsNotFound()
        {
            // Arrange
            var collectionService = new global::RTWTR.Service.Data.CollectionService(
                saverStub.Object,
                mapperStub.Object,
                collectionRepositoryStub.Object,
                tweetRepositoryStub.Object,
                collectionTweetsRepositoryStub.Object
                );

            // Act & Assert
            Assert.ThrowsException <NullCollectionException>(() =>
            {
                collectionService.RemoveCollection("collectionId");
            });
        }
コード例 #4
0
        public void Throw_InvalidCollectionIdException_When_InvokedWithEmptyCollectionId()
        {
            // Arrange
            var collectionService = new global::RTWTR.Service.Data.CollectionService(
                saverStub.Object,
                mapperStub.Object,
                collectionRepositoryStub.Object,
                tweetRepositoryStub.Object,
                collectionTweetsRepositoryStub.Object
                );

            // Act & Assert
            Assert.ThrowsException <InvalidCollectionIdException>(() =>
            {
                collectionService.RemoveCollection(" ");
            });
        }