예제 #1
0
        public void LastTweetUpdater_ForPage_And_Animated_Test()
        {
            //тест дата твита
            var dtNow1 = new DateTime(2020, 10, 14, 0, 0, 0);

            var nowDate = new SelectLogic.Stubs.DateSupplyStub
            {
                Now = dtNow1
            };

            var animatedTweetDateUpdaterStub = new Stubs.AnimatedTweetDateUpdaterStub
            {
                DontThrowNotImpl = true
            };


            var pageUpdStub = new Stubs.SitePageTweetDateUpdaterStub
            {
                DontThrowNotImpl = true                 //режим работы правильный
            };

            var upd = new LastTweetUpdater(nowDate, animatedTweetDateUpdaterStub, pageUpdStub);

            var page = new db.SitePage
            {
                Title = "https://kawaii-mobile.com/2020/10/uchuu-no-stellvia/",
                URL   = "Uchuu no Stellvia"
            };

            var img = new db.AnimatedImage
            {
                BlobName = "uchuu-no-stellvia",
            };

            TwittData data = new TwittData
            {
                Image = img,
                Page  = page
            };

            upd.UpdateLastTweetDate(data);

            Assert.IsTrue(pageUpdStub.CalledDate == dtNow1);
            Assert.AreSame(pageUpdStub.CalledPage, page);

            Assert.IsTrue(animatedTweetDateUpdaterStub.CalledDate == dtNow1);
            Assert.AreSame(animatedTweetDateUpdaterStub.CalledImage, img);
        }
예제 #2
0
        public void LastTweetUpdater_Ctor_AnimatedTweetDateUpdater_Test()
        {
            var nowDate = new SelectLogic.Stubs.DateSupplyStub();
            //var animatedTweetDateUpdaterStub = new Stubs.AnimatedTweetDateUpdaterStub();
            var pageUpdStub = new Stubs.SitePageTweetDateUpdaterStub();

            try
            {
                var upd = new LastTweetUpdater(nowDate, null, pageUpdStub);
                Assert.Fail("Очікувалося виключення ArgumentNullException");
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsTrue(ex.ParamName == "animatedTweetDateUpdater");
            }
        }
예제 #3
0
        public void LastTweetUpdater_UpdateLastTweetDate_PageNull_Test()
        {
            var nowDate = new SelectLogic.Stubs.DateSupplyStub();
            var animatedTweetDateUpdaterStub = new Stubs.AnimatedTweetDateUpdaterStub();
            var pageUpdStub = new Stubs.SitePageTweetDateUpdaterStub();

            var upd = new LastTweetUpdater(nowDate, animatedTweetDateUpdaterStub, pageUpdStub);

            try
            {
                TwittData data = new TwittData();

                upd.UpdateLastTweetDate(data);

                Assert.Fail("Очікувалося виключення ArgumentNullException");
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsTrue(ex.ParamName == "data");
                Assert.IsTrue(ex.Message.Contains("data.Page"));
            }
        }
예제 #4
0
        public void LastTweetUpdater_ForPage_Only_Test()
        {
            //тест дата твита
            var dtNow1 = new DateTime(2020, 10, 14, 0, 0, 0);

            var nowDate = new SelectLogic.Stubs.DateSupplyStub
            {
                Now = dtNow1
            };

            //это в данном тесте не применяется (и выбросит исключение если туда пройдет)
            var animatedTweetDateUpdaterStub = new Stubs.AnimatedTweetDateUpdaterStub();

            var pageUpdStub = new Stubs.SitePageTweetDateUpdaterStub
            {
                DontThrowNotImpl = true                 //режим работы правильный
            };

            var upd = new LastTweetUpdater(nowDate, animatedTweetDateUpdaterStub, pageUpdStub);

            var page = new db.SitePage
            {
                Title = "https://kawaii-mobile.com/2020/10/uchuu-no-stellvia/",
                URL   = "Uchuu no Stellvia"
            };

            TwittData data = new TwittData
            {
                Image = null,
                Page  = page
            };

            upd.UpdateLastTweetDate(data);

            Assert.IsTrue(pageUpdStub.CalledDate == dtNow1);
            Assert.AreSame(pageUpdStub.CalledPage, page);
        }