Beispiel #1
0
        public void SeasonHasToBeLongerThenZero(int seasonLength)
        {
            var fixture = new Fixture().Customize(new AutoMoqCustomization());
            //Arrange

            var pocketOptions = fixture.Create <PocketOptions>();

            pocketOptions.SeasonLength = seasonLength;

            optionsMock.Setup(o => o.Value).Returns(pocketOptions);
            this.sut = new LoadDataFromPocket(loggerMock.Object, optionsMock.Object, pocketConector.Object);
            //Act
            Assert.Throws <InvalidOperationException>(
                () => { sut.Execute(); }
                );
        }
Beispiel #2
0
        public void NoTagsEndsInError()
        {
            var fixture = new Fixture().Customize(new AutoMoqCustomization());
            //Arrange

            var pocketOptions = fixture.Create <PocketOptions>();

            pocketOptions.SeasonLength = 2;
            pocketOptions.Tags         = new List <string>();

            optionsMock.Setup(o => o.Value).Returns(pocketOptions);
            this.sut = new LoadDataFromPocket(loggerMock.Object, optionsMock.Object, pocketConector.Object);
            //Act
            Assert.Throws <InvalidOperationException>(
                () => { sut.Execute(); }
                );
        }
Beispiel #3
0
        public void SeasonLengthIsRespected(int seasonLength)
        {
            var fixture = new Fixture().Customize(new AutoMoqCustomization());
            //Arrange
            var pocketOptions = fixture.Create <PocketOptions>();

            pocketOptions.SeasonLength = seasonLength;

            optionsMock.Setup(o => o.Value).Returns(pocketOptions);
            fixture.Inject(optionsMock);
            this.sut = fixture.Create <LoadDataFromPocket>();
            //Act
            var result = sut.Execute();


            Assert.That(result.Count, Is.EqualTo(seasonLength));
        }
Beispiel #4
0
        public void HappyPath_EachEpisodeHasAllArticle()
        {
            var fixture = new Fixture().Customize(new AutoMoqCustomization());
            //Arrange

            var pocketOptions = fixture.Create <PocketOptions>();

            pocketOptions.SeasonLength = 2;
            pocketOptions.Tags         = new List <string> {
                "Test", "Test2"
            };
            optionsMock.Setup(o => o.Value).Returns(pocketOptions);
            fixture.Inject(optionsMock);
            this.sut = fixture.Create <LoadDataFromPocket>();
            //Act

            var result = sut.Execute();

            Assert.That(result.Any(e => e.Articles.Count == pocketOptions.Tags.Count), Is.True, "Not All Episodes had all articles");
        }
Beispiel #5
0
        public void EdgeCase_AllTagsHadToFewArticlesSeasonIsShorter()
        {
            var fixture = new Fixture().Customize(new AutoMoqCustomization());
            //Arrange

            var pocketOptions = fixture.Create <PocketOptions>();

            pocketOptions.SeasonLength = 4;
            const string tagWithArticles    = "Test";
            const string tagWithoutArticles = "Test2";

            pocketOptions.Tags = new List <string> {
                tagWithArticles, tagWithoutArticles
            };

            optionsMock.Setup(o => o.Value).Returns(pocketOptions);
            pocketConector.SetupSequence(pc => pc.MoveArticleFromPocketByTag(tagWithArticles))
            .Returns(fixture.Create <Article>())
            .Returns(fixture.Create <Article>())
            .Returns((Article)null)
            .Returns((Article)null);
            pocketConector.SetupSequence(pc => pc.MoveArticleFromPocketByTag(tagWithoutArticles))
            .Returns(fixture.Create <Article>())
            .Returns((Article)null)
            .Returns((Article)null)
            .Returns((Article)null);
            fixture.Inject(optionsMock);
            fixture.Inject(pocketConector);
            loggerMock = fixture.Freeze <Mock <ILogger <LoadDataFromPocket> > >();

            //this.sut = new LoadDataFromPocket(loggerMock.Object, optionsMock.Object, pocketConector.Object);
            sut = fixture.Create <LoadDataFromPocket>();
            //Act

            var result = sut.Execute();

            Assert.That(result.Count, Is.EqualTo(2), "Season expected to be shorter due to lack of articles!");
            Assert.That(result[0].Articles.Count, Is.EqualTo(2), "First Epside should be full");
            Assert.That(result[1].Articles.Count, Is.EqualTo(1), "Second episode should have 1 article");
        }
Beispiel #6
0
        public void EdgeCase_OnaTagHadToFewAllArticle()
        {
            var fixture = new Fixture().Customize(new AutoMoqCustomization());
            //Arrange

            var pocketOptions = fixture.Create <PocketOptions>();

            pocketOptions.SeasonLength = 4;
            const string tagWithArticles    = "Test";
            const string tagWithoutArticles = "Test2";

            pocketOptions.Tags = new List <string> {
                tagWithArticles, tagWithoutArticles
            };

            optionsMock.Setup(o => o.Value).Returns(pocketOptions);
            pocketConector.Setup(pc => pc.MoveArticleFromPocketByTag(tagWithArticles))
            .Returns(fixture.Create <Article>());

            pocketConector.SetupSequence(pc => pc.MoveArticleFromPocketByTag(tagWithoutArticles))
            .Returns(fixture.Create <Article>())
            .Returns((Article)null)
            .Returns((Article)null)
            .Returns((Article)null);
            fixture.Inject(optionsMock);
            fixture.Inject(pocketConector);
            loggerMock = fixture.Freeze <Mock <ILogger <LoadDataFromPocket> > >();

            //this.sut = new LoadDataFromPocket(loggerMock.Object, optionsMock.Object, pocketConector.Object);
            sut = fixture.Create <LoadDataFromPocket>();
            //Act

            var result = sut.Execute();

            Assert.That(result.FirstOrDefault().Articles.Count, Is.EqualTo(2), "First Epsiode  should be full length");
            Assert.That(result.Count(e => e.Articles.Count < 2), Is.EqualTo(3), "not all episde had expected artcile count");
        }