public void CallTest()
        {
            //Arrange
            var domainStatProjectState1 = new DomainStatProjectState() { Producer = ProductName.TaggerIPhone, IsSuccessfulUpload = true };
            var domainStatProjectState2 = new DomainStatProjectState() { Producer = ProductName.TaggerIPhone, IsSuccessfulUpload = false };
            var domainStatProjectState3 = new DomainStatProjectState() { Producer = "ProductName", IsSuccessfulUpload = true };

            var domainReport = new DomainReport();

            var statProjectDeletionFilter = new Mock<IStatProjectDeletionFilter>();

            var taggerIPhoneDeletionsFilter = new TaggerIPhoneDeletionsFilter();
            taggerIPhoneDeletionsFilter.Set(statProjectDeletionFilter.Object);

            //Act
            taggerIPhoneDeletionsFilter.Call(domainStatProjectState1, domainReport);
            taggerIPhoneDeletionsFilter.Call(domainStatProjectState2, domainReport);
            taggerIPhoneDeletionsFilter.Call(domainStatProjectState3, domainReport);

            //Assert
            Assert.AreEqual(1, domainReport.TaggerIPhoneDeletions);
            statProjectDeletionFilter.Verify(m => m.Call(domainStatProjectState1, domainReport), Times.Once());
            statProjectDeletionFilter.Verify(m => m.Call(domainStatProjectState2, domainReport), Times.Once());
            statProjectDeletionFilter.Verify(m => m.Call(domainStatProjectState3, domainReport), Times.Once());
        }
        public void CallTest()
        {
            //Arrange
            var domainStatProjectState1 = new DomainStatProjectState() { Producer = ProductName.ImageShack, IsSuccessfulUpload = true };
            var domainStatProjectState2 = new DomainStatProjectState() { Producer = ProductName.ImageShack, IsSuccessfulUpload = false };
            var domainStatProjectState3 = new DomainStatProjectState() { Producer = ProductName.ImageShack, IsSuccessfulUpload = false };
            var domainStatProjectState4 = new DomainStatProjectState() { Producer = "ProductName", IsSuccessfulUpload = true };

            var domainReport = new DomainReport();

            var statProjectDeletionFilter = new Mock<IStatProjectCancellationFilter>();

            var imageShackCancellationFilter = new ImageShackCancellationFilter();
            imageShackCancellationFilter.Set(statProjectDeletionFilter.Object);

            //Act
            imageShackCancellationFilter.Call(domainStatProjectState1, domainReport);
            imageShackCancellationFilter.Call(domainStatProjectState2, domainReport);
            imageShackCancellationFilter.Call(domainStatProjectState3, domainReport);
            imageShackCancellationFilter.Call(domainStatProjectState4, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.ImageShackUploadCancels);
            statProjectDeletionFilter.Verify(m => m.Call(domainStatProjectState1, domainReport), Times.Once());
            statProjectDeletionFilter.Verify(m => m.Call(domainStatProjectState2, domainReport), Times.Once());
            statProjectDeletionFilter.Verify(m => m.Call(domainStatProjectState3, domainReport), Times.Once());
            statProjectDeletionFilter.Verify(m => m.Call(domainStatProjectState4, domainReport), Times.Once());
        }
        public void CallTest()
        {
            //Arrange
            var domainStatProjectState1 = new DomainStatProjectState() { Producer = ProductName.Standalone, IsSuccessfulUpload = true };
            var domainStatProjectState2 = new DomainStatProjectState() { Producer = ProductName.Standalone, IsSuccessfulUpload = false };
            var domainStatProjectState3 = new DomainStatProjectState() { Producer = "ProductName", IsSuccessfulUpload = true };
            
            var domainReport = new DomainReport();

            var statProjectUploadingFilter = new Mock<IStatProjectUploadingFilter>();

            var standaloneUploadsFilter = new StandaloneUploadsFilter();
            standaloneUploadsFilter.Set(statProjectUploadingFilter.Object);

            //Act
            standaloneUploadsFilter.Call(domainStatProjectState1, domainReport);
            standaloneUploadsFilter.Call(domainStatProjectState2, domainReport);
            standaloneUploadsFilter.Call(domainStatProjectState3, domainReport);

            //Assert
            Assert.AreEqual(1, domainReport.StandaloneSuccessfulUploads);
            statProjectUploadingFilter.Verify(m => m.Call(domainStatProjectState1, domainReport), Times.Once());
            statProjectUploadingFilter.Verify(m => m.Call(domainStatProjectState2, domainReport), Times.Once());
            statProjectUploadingFilter.Verify(m => m.Call(domainStatProjectState3, domainReport), Times.Once());
        }
Пример #4
0
        public void CompileReportTest()
        {
            //Arrange
            const string projectId1 = "projectId1";
            const string projectId2 = "projectId2";
            const int days = 3;
            var startDate = new DateTime(3452345234);
            var finishDate = startDate.Add(TimeSpan.FromDays(days));
            var interval = new Interval() { Start = startDate, Finish = finishDate };
            
            var watching1 = new DomainStatWatching();
            var watching2 = new DomainStatWatching();
            var registration1 = new DomainStatUserRegistration();
            var registration2 = new DomainStatUserRegistration();
            var uploading1 = new DomainStatProjectUploading() { ProjectId = projectId1 };
            var uploading2 = new DomainStatProjectUploading() { ProjectId = projectId2 };
            var deletion1 = new DomainStatProjectDeletion() {ProjectId = projectId1};
            var deletion2 = new DomainStatProjectDeletion() {ProjectId = projectId2};
            var projectState1 = new DomainStatProjectState();
            var projectState2 = new DomainStatProjectState();

            var watchings = new List<DomainStatWatching>(){watching1,watching2};
            var registratios = new List<DomainStatUserRegistration>(){registration1,registration2};
            var uploadings = new List<DomainStatProjectUploading>(){uploading1,uploading2};
            var deletions = new List<DomainStatProjectDeletion>(){deletion1,deletion2};

            var filtersManager = new Mock<IFiltersManager>();
            var statisticsService = new Mock<IStatisticsService>();

            var compiler = new StatisticsCompiler(filtersManager.Object, statisticsService.Object, interval);

            statisticsService.Setup(m => m.GetWatchings(interval)).Returns(watchings);
            statisticsService.Setup(m => m.GetUserRegistrations(interval)).Returns(registratios);
            statisticsService.Setup(m => m.GetProjectUploadings(interval)).Returns(uploadings);
            statisticsService.Setup(m => m.GetProjectDeletions(interval)).Returns(deletions);
            statisticsService.Setup(m => m.GetProjectState(projectId1)).Returns(projectState1);
            statisticsService.Setup(m => m.GetProjectState(projectId2)).Returns(projectState2);

            //Act
            var report = compiler.CompileReport();

            //Assert
            Assert.AreEqual(days.ToString(CultureInfo.InvariantCulture), report.Interval);
            filtersManager.Verify(m => m.FilterStatWatching(watching1, report), Times.Once());
            filtersManager.Verify(m => m.FilterStatWatching(watching2, report), Times.Once());
            filtersManager.Verify(m => m.FilterStatUserRegistration(registration1, report), Times.Once());
            filtersManager.Verify(m => m.FilterStatUserRegistration(registration2, report), Times.Once());
            filtersManager.Verify(m => m.FilterStatProjectUploading(projectState1, report), Times.Once());
            filtersManager.Verify(m => m.FilterStatProjectUploading(projectState2, report), Times.Once());
            filtersManager.Verify(m => m.FilterStatProjectDeletion(projectState1, report), Times.Once());
            filtersManager.Verify(m => m.FilterStatProjectDeletion(projectState2, report), Times.Once());
            filtersManager.Verify(m => m.FilterStatProjectCancellation(projectState1, report), Times.Once());
            filtersManager.Verify(m => m.FilterStatProjectCancellation(projectState2, report), Times.Once());
        }
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatProjectState = new DomainStatProjectState() { Producer = ProductName.ImageShack, IsSuccessfulUpload = false };
            var domainReport = new DomainReport();

            var imageShackCancellationFilter = new ImageShackCancellationFilter();

            //Act
            imageShackCancellationFilter.Call(domainStatProjectState, domainReport);
            imageShackCancellationFilter.Call(domainStatProjectState, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.ImageShackUploadCancels);
        }
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatProjectState = new DomainStatProjectState() { Producer = ProductName.TaggerAndroid, IsSuccessfulUpload = true };
            var domainReport = new DomainReport();

            var cicPcDeletionsFilter = new TaggerAndroidDeletionsFilter();

            //Act
            cicPcDeletionsFilter.Call(domainStatProjectState, domainReport);
            cicPcDeletionsFilter.Call(domainStatProjectState, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.TaggerAndroidDeletions);
        }
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatProjectState = new DomainStatProjectState() { Producer = ProductName.Standalone, IsSuccessfulUpload = true};
            var domainReport = new DomainReport();

            var standaloneUploadsFilter = new StandaloneUploadsFilter();

            //Act
            standaloneUploadsFilter.Call(domainStatProjectState, domainReport);
            standaloneUploadsFilter.Call(domainStatProjectState, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.StandaloneSuccessfulUploads);
        }
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatProjectState = new DomainStatProjectState() { Producer = ProductName.CicPc, IsSuccessfulUpload = false };
            var domainReport = new DomainReport();

            var cicPcCancellationFilter = new CicPcCancellationFilter();

            //Act
            cicPcCancellationFilter.Call(domainStatProjectState, domainReport);
            cicPcCancellationFilter.Call(domainStatProjectState, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.CicPcUploadCancels);
        }
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatProjectState = new DomainStatProjectState() { Producer = ProductName.DailyMotion, IsSuccessfulUpload = true };
            var domainReport = new DomainReport();

            var dailyMotionDeletionsFilter = new DailyMotionDeletionsFilter();

            //Act
            dailyMotionDeletionsFilter.Call(domainStatProjectState, domainReport);
            dailyMotionDeletionsFilter.Call(domainStatProjectState, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.DailyMotionDeletions);
        }
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatProjectState = new DomainStatProjectState() { Producer = ProductName.CicIPad, IsSuccessfulUpload=true };
            var domainReport = new DomainReport();

            var cicIPadUploadsFilter = new CicIPadUploadsFilter();

            //Act
            cicIPadUploadsFilter.Call(domainStatProjectState, domainReport);
            cicIPadUploadsFilter.Call(domainStatProjectState, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.CicIPadSuccessfulUploads);
        }
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatProjectState = new DomainStatProjectState() { Producer = ProductName.TaggerIPhone, IsSuccessfulUpload = false };
            var domainReport = new DomainReport();

            var taggerIPhoneCancellationFilter = new TaggerIPhoneCancellationFilter();

            //Act
            taggerIPhoneCancellationFilter.Call(domainStatProjectState, domainReport);
            taggerIPhoneCancellationFilter.Call(domainStatProjectState, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.TaggerIPhoneUploadCancels);
        }
Пример #12
0
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatProjectState = new DomainStatProjectState() { Producer = ProductName.Player, IsSuccessfulUpload = true};
            var domainReport = new DomainReport();

            var playerUploadsFilter = new PlayerUploadsFilter();

            //Act
            playerUploadsFilter.Call(domainStatProjectState, domainReport);
            playerUploadsFilter.Call(domainStatProjectState, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.PlayerSuccessfulUploads);
        }
Пример #13
0
        public void FilterStatProjectUploadingTest()
        {
            //Arrange
            var domainStatProjectState = new DomainStatProjectState();

            var statProjectUploadingFilters = new List<IStatProjectUploadingFilter>();
            var filter = new Mock<IStatProjectUploadingFilter>();

            _filtersFactory.Setup(m => m.CreateStatProjectUploadingFilters()).Returns(statProjectUploadingFilters);
            _filtersChainBuilder.Setup(m => m.BuildStatProjectUploadingFilter(statProjectUploadingFilters)).Returns(filter.Object);

            var filtersManager = new FiltersManager(_filtersFactory.Object, _filtersChainBuilder.Object);

            //Act
            filtersManager.FilterStatProjectUploading(domainStatProjectState, _domainReport);

            //Assert
            filter.Verify(m => m.Call(domainStatProjectState, _domainReport), Times.Once());
        }
Пример #14
0
 public void FilterStatProjectCancellation(DomainStatProjectState domainStatProjectState, DomainReport domainReport)
 {
     _statProjectCancellationFilter.Call(domainStatProjectState, domainReport);
 }
Пример #15
0
 public void FilterStatProjectUploading(DomainStatProjectState domainStatProjectState, DomainReport domainReport)
 {
     _statProjectUploadingFilter.Call(domainStatProjectState, domainReport);
 }
Пример #16
0
        public void GetProjectStateForAbsentProjectIdTest()
        {
            //Arrange
            const string projectId1 = "projectId1";

            var entity1 = new StatProjectStateV3Entity() { ProjectId = projectId1, ActionType = StatActionType.Avsx };
            var entity2 = new StatProjectStateV3Entity() { ProjectId = projectId1, ActionType = StatActionType.Screenshot };
            var entity3 = new StatProjectStateV3Entity() { ProjectId = projectId1, ActionType = StatActionType.Video };

            var entities = new List<StatProjectStateV3Entity>() { entity1, entity2, entity3 };

            var domain1 = new DomainStatProjectState();

            var repositoryFactory = new Mock<IRepositoryFactory>();
            var tableValueConverter = new Mock<ITableValueConverter>();
            var statMapper = new Mock<IStatMapper>();

            var repository = new FakeRepository<StatProjectStateV3Entity>(entities);

            repositoryFactory.Setup(m => m.Create<StatProjectStateV3Entity>(Tables.StatProjectStateV3)).Returns(repository);
            statMapper.Setup(m => m.StatProjectStateToDomain(It.Is<StatProjectStateV3Entity>(p => p.ProjectId == projectId1 &&
                                                                                                  p.ActionType == null &&
                                                                                                  p.Producer == null), false)).Returns(domain1);

            var statisticsService = new StatisticsService(repositoryFactory.Object, tableValueConverter.Object, statMapper.Object);

            //Act
            var projectState1 = statisticsService.GetProjectState(projectId1);

            //Assert
            Assert.AreEqual(domain1, projectState1);
        }