Esempio n. 1
0
        public void Perform_returns_ActivityStatus_Error_when_action_throws_exception()
        {
            var offerRepositoryMock = new Mock <IDataRepository <Offer> >();

            offerRepositoryMock.SetupSequence(x => x.GetFromCollection(It.IsAny <string>(), It.IsAny <long>()))
            .Throws(new Exception());
            offerRepositoryMock.Setup(x => x.Update(It.IsAny <Offer>()));

            var sut = new OfferLinkCleanupActivity(offerRepositoryMock.Object, _browser, _logger);

            var result = sut.Perform();

            Assert.AreEqual(GCActivityStatus.Error, result);
        }
Esempio n. 2
0
        public void Perform_returns_ActivityStatus_None_when_no_action_gets_to_be_performed()
        {
            var offerRepositoryMock = new Mock <IDataRepository <Offer> >();

            offerRepositoryMock.SetupSequence(x => x.GetFromCollection(It.IsAny <string>(), It.IsAny <long>()))
            .Returns(new List <Offer>().AsQueryable());
            offerRepositoryMock.Setup(x => x.Update(It.IsAny <Offer>()));

            var sut = new OfferLinkCleanupActivity(offerRepositoryMock.Object, _browser, _logger);

            var result = sut.Perform();

            Assert.AreEqual(GCActivityStatus.None, result);
        }
Esempio n. 3
0
        public void Initialize()
        {
            var browserMock = new Mock <IBrowser>();

            browserMock.Setup(x => x.GetPage(It.IsAny <Uri>()))
            .Returns(HtmlNode.CreateNode("To ogłoszenie jest nieaktualne"));
            _browser = browserMock.Object;

            var loggerMock = new Mock <ILogger>();

            loggerMock.Setup(x => x.Log(It.IsAny <LogType>(), It.IsAny <string>()));
            _logger = loggerMock.Object;

            _dbConnectionSettings = new DatabaseConnectionSettings("vps561493.ovh.net", 8086, "admin", "admin");
            _dbOfferRepository    = new DatabaseOfferRepository(_dbConnectionSettings);
            _sut = new OfferLinkCleanupActivity(_dbOfferRepository, _browser, _logger);
        }
Esempio n. 4
0
        public void Perform_returns_ActivityStatus_Performed_when_at_least_one_action_gets_successfully_performed()
        {
            var offerRepositoryMock = new Mock <IDataRepository <Offer> >();

            offerRepositoryMock.SetupSequence(x => x.GetFromCollection(It.IsAny <string>(), It.IsAny <long>()))
            .Returns(new List <Offer> {
                new Offer()
                {
                    Link = "http://www.placeholder.com"
                }
            }.AsQueryable())
            .Returns(new List <Offer>().AsQueryable());
            offerRepositoryMock.Setup(x => x.Update(It.IsAny <Offer>()));

            var sut = new OfferLinkCleanupActivity(offerRepositoryMock.Object, _browser, _logger);

            var result = sut.Perform();

            Assert.AreEqual(GCActivityStatus.Performed, result);
        }