コード例 #1
0
        public void CallTest()
        {
            //Arrange
            var domainStatUserRegistration1 = new DomainStatUserRegistration() { IdentityProvider = IdentityType.Twitter.ToString() };
            var domainStatUserRegistration2 = new DomainStatUserRegistration() { IdentityProvider = "IdentityProvider" };
            var domainStatUserRegistration3 = new DomainStatUserRegistration();

            var domainReport = new DomainReport();

            var statUserRegistrationFilter = new Mock<IStatUserRegistrationFilter>();

            var twitterRegistrationsFilter = new TwitterRegistrationsFilter();
            twitterRegistrationsFilter.Set(statUserRegistrationFilter.Object);

            //Act
            twitterRegistrationsFilter.Call(domainStatUserRegistration1, domainReport);
            twitterRegistrationsFilter.Call(domainStatUserRegistration2, domainReport);
            twitterRegistrationsFilter.Call(domainStatUserRegistration3, domainReport);

            //Assert
            Assert.AreEqual(1, domainReport.TwitterRegistrations);
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration1, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration2, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration3, domainReport), Times.Once());
        }
コード例 #2
0
        public void CallTest()
        {
            //Arrange
            var domainStatUserRegistration1 = new DomainStatUserRegistration() { ProductName = ProductName.TaggerAndroid };
            var domainStatUserRegistration2 = new DomainStatUserRegistration() { ProductName = "ProductName" };
            var domainStatUserRegistration3 = new DomainStatUserRegistration();

            var domainReport = new DomainReport();

            var statUserRegistrationFilter = new Mock<IStatUserRegistrationFilter>();

            var taggerAndroidRegistrationsFilter = new TaggerAndroidRegistrationsFilter();
            taggerAndroidRegistrationsFilter.Set(statUserRegistrationFilter.Object);

            //Act
            taggerAndroidRegistrationsFilter.Call(domainStatUserRegistration1, domainReport);
            taggerAndroidRegistrationsFilter.Call(domainStatUserRegistration2, domainReport);
            taggerAndroidRegistrationsFilter.Call(domainStatUserRegistration3, domainReport);

            //Assert
            Assert.AreEqual(1, domainReport.TaggerAndroidRegistrations);
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration1, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration2, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration3, domainReport), Times.Once());
        }
コード例 #3
0
        public void CallTest()
        {
            //Arrange
            var domainStatUserRegistration1 = new DomainStatUserRegistration() { ProductName = ProductName.CicIPad };
            var domainStatUserRegistration2 = new DomainStatUserRegistration() { ProductName = ProductName.CicMac };
            var domainStatUserRegistration3 = new DomainStatUserRegistration() { ProductName = ProductName.CicPc };
            var domainStatUserRegistration4 = new DomainStatUserRegistration() { ProductName = ProductName.ImageShack };
            var domainStatUserRegistration5 = new DomainStatUserRegistration() { ProductName = ProductName.Mozilla };
            var domainStatUserRegistration6 = new DomainStatUserRegistration() { ProductName = ProductName.Player };
            var domainStatUserRegistration7 = new DomainStatUserRegistration() { ProductName = ProductName.Standalone };
            var domainStatUserRegistration8 = new DomainStatUserRegistration() { ProductName = ProductName.TaggerAndroid };
            var domainStatUserRegistration9 = new DomainStatUserRegistration() { ProductName = ProductName.TaggerIPhone };
            var domainStatUserRegistration10 = new DomainStatUserRegistration() { ProductName = ProductName.DailyMotion };
            var domainStatUserRegistration11 = new DomainStatUserRegistration() { ProductName = ProductName.JwPlayer };
            var domainStatUserRegistration12 = new DomainStatUserRegistration() { ProductName = "ProductName1" };
            var domainStatUserRegistration13 = new DomainStatUserRegistration();

            var domainReport = new DomainReport();

            var statUserRegistrationFilter = new Mock<IStatUserRegistrationFilter>();

            var otherRegistrationsFilter = new OtherRegistrationsFilter();
            otherRegistrationsFilter.Set(statUserRegistrationFilter.Object);

            //Act
            otherRegistrationsFilter.Call(domainStatUserRegistration1, domainReport);
            otherRegistrationsFilter.Call(domainStatUserRegistration2, domainReport);
            otherRegistrationsFilter.Call(domainStatUserRegistration3, domainReport);
            otherRegistrationsFilter.Call(domainStatUserRegistration4, domainReport);
            otherRegistrationsFilter.Call(domainStatUserRegistration5, domainReport);
            otherRegistrationsFilter.Call(domainStatUserRegistration6, domainReport);
            otherRegistrationsFilter.Call(domainStatUserRegistration7, domainReport);
            otherRegistrationsFilter.Call(domainStatUserRegistration8, domainReport);
            otherRegistrationsFilter.Call(domainStatUserRegistration9, domainReport);
            otherRegistrationsFilter.Call(domainStatUserRegistration10, domainReport);
            otherRegistrationsFilter.Call(domainStatUserRegistration11, domainReport);
            otherRegistrationsFilter.Call(domainStatUserRegistration12, domainReport);
            otherRegistrationsFilter.Call(domainStatUserRegistration13, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.OtherRegistrations);
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration1, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration2, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration3, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration4, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration5, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration6, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration7, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration8, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration9, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration10, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration11, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration12, domainReport), Times.Once());
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration13, 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());
        }
コード例 #5
0
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatUserRegistration = new DomainStatUserRegistration() { ProductName = ProductName.CicMac };
            var domainReport = new DomainReport();

            var cicMacRegistrationsFilter = new CicMacRegistrationsFilter();

            //Act
            cicMacRegistrationsFilter.Call(domainStatUserRegistration, domainReport);
            cicMacRegistrationsFilter.Call(domainStatUserRegistration, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.CicMacRegistrations);
        }
コード例 #6
0
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatUserRegistration = new DomainStatUserRegistration() { IdentityProvider = IdentityType.Odnoklassniki.ToString() };
            var domainReport = new DomainReport();

            var odnoklassnikiRegistrationsFilter = new OdnoklassnikiRegistrationsFilter();

            //Act
            odnoklassnikiRegistrationsFilter.Call(domainStatUserRegistration, domainReport);
            odnoklassnikiRegistrationsFilter.Call(domainStatUserRegistration, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.OdnoklassnikiRegistrations);
        }
コード例 #7
0
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatUserRegistration = new DomainStatUserRegistration() { ProductName = ProductName.Mozilla };
            var domainReport = new DomainReport();

            var browserRegistrationsFilter = new BrowserRegistrationsFilter();

            //Act
            browserRegistrationsFilter.Call(domainStatUserRegistration, domainReport);
            browserRegistrationsFilter.Call(domainStatUserRegistration, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.BrowserRegistrations);
        }
コード例 #8
0
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatUserRegistration = new DomainStatUserRegistration() { ProductName = ProductName.DailyMotion };
            var domainReport = new DomainReport();

            var dailyMotionRegistrationsFilter = new DailyMotionRegistrationsFilter();

            //Act
            dailyMotionRegistrationsFilter.Call(domainStatUserRegistration, domainReport);
            dailyMotionRegistrationsFilter.Call(domainStatUserRegistration, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.DailyMotionRegistrations);
        }
コード例 #9
0
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatUserRegistration = new DomainStatUserRegistration() { ProductName = ProductName.Standalone };
            var domainReport = new DomainReport();

            var standaloneRegistrationsFilter = new StandaloneRegistrationsFilter();

            //Act
            standaloneRegistrationsFilter.Call(domainStatUserRegistration, domainReport);
            standaloneRegistrationsFilter.Call(domainStatUserRegistration, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.StandaloneRegistrations);
        }
コード例 #10
0
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatUserRegistration = new DomainStatUserRegistration() { IdentityProvider = IdentityType.Twitter.ToString() };
            var domainReport = new DomainReport();

            var twitterRegistrationsFilter = new TwitterRegistrationsFilter();

            //Act
            twitterRegistrationsFilter.Call(domainStatUserRegistration, domainReport);
            twitterRegistrationsFilter.Call(domainStatUserRegistration, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.TwitterRegistrations);
        }
コード例 #11
0
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatUserRegistration = new DomainStatUserRegistration() { ProductName = ProductName.JwPlayer };
            var domainReport = new DomainReport();

            var jwPlayerRegistrationsFilter = new JwPlayerRegistrationsFilter();

            //Act
            jwPlayerRegistrationsFilter.Call(domainStatUserRegistration, domainReport);
            jwPlayerRegistrationsFilter.Call(domainStatUserRegistration, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.JwPlayerRegistrations);
        }
コード例 #12
0
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatUserRegistration = new DomainStatUserRegistration() { ProductName = ProductName.ImageShack };
            var domainReport = new DomainReport();

            var imageShackRegistrationsFilter = new ImageShackRegistrationsFilter();

            //Act
            imageShackRegistrationsFilter.Call(domainStatUserRegistration, domainReport);
            imageShackRegistrationsFilter.Call(domainStatUserRegistration, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.ImageShackRegistrations);
        }
コード例 #13
0
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatUserRegistration = new DomainStatUserRegistration() { ProductName = ProductName.TaggerAndroid };
            var domainReport = new DomainReport();

            var taggerAndroidRegistrationsFilter = new TaggerAndroidRegistrationsFilter();

            //Act
            taggerAndroidRegistrationsFilter.Call(domainStatUserRegistration, domainReport);
            taggerAndroidRegistrationsFilter.Call(domainStatUserRegistration, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.TaggerAndroidRegistrations);
        }
コード例 #14
0
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatUserRegistration = new DomainStatUserRegistration();
            var domainReport = new DomainReport();

            var allRegistrationsFilter = new AllRegistrationsFilter();

            //Act
            allRegistrationsFilter.Call(domainStatUserRegistration, domainReport);
            allRegistrationsFilter.Call(domainStatUserRegistration, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.AllRegistrations);
        }
コード例 #15
0
        public void CallWhenNotSetFelterTest()
        {
            //Arrange
            var domainStatUserRegistration = new DomainStatUserRegistration() { ProductName = "otherProduct" };
            var domainReport = new DomainReport();

            var otherRegistrationsFilter = new OtherRegistrationsFilter();

            //Act
            otherRegistrationsFilter.Call(domainStatUserRegistration, domainReport);
            otherRegistrationsFilter.Call(domainStatUserRegistration, domainReport);

            //Assert
            Assert.AreEqual(2, domainReport.OtherRegistrations);
        }
コード例 #16
0
        public void FilterStatUserRegistrationTest()
        {
            //Arrange
            var domainStatUserRegistration = new DomainStatUserRegistration();

            var statUserRegistrationFilters = new List<IStatUserRegistrationFilter>();
            var filter = new Mock<IStatUserRegistrationFilter>();

            _filtersFactory.Setup(m => m.CreateStatUserRegistrationFilters()).Returns(statUserRegistrationFilters);
            _filtersChainBuilder.Setup(m => m.BuildStatUserRegistrationFilter(statUserRegistrationFilters)).Returns(filter.Object);

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

            //Act
            filtersManager.FilterStatUserRegistration(domainStatUserRegistration, _domainReport);

            //Assert
            filter.Verify(m => m.Call(domainStatUserRegistration, _domainReport), Times.Once());
        }
コード例 #17
0
        public void CallTest()
        {
            //Arrange
            var domainStatUserRegistration = new DomainStatUserRegistration();

            var domainReport = new DomainReport();

            var statUserRegistrationFilter = new Mock<IStatUserRegistrationFilter>();

            var allRegistrationsFilter = new AllRegistrationsFilter();
            allRegistrationsFilter.Set(statUserRegistrationFilter.Object);

            //Act
            allRegistrationsFilter.Call(domainStatUserRegistration, domainReport);

            //Assert
            Assert.AreEqual(1, domainReport.AllRegistrations);
            statUserRegistrationFilter.Verify(m => m.Call(domainStatUserRegistration, domainReport), Times.Once());
        }
コード例 #18
0
        public void GetUserRegistrationsTest()
        {
            //Arrange
            var domain1 = new DomainStatUserRegistration();
            var domain2 = new DomainStatUserRegistration();

            var entity1 = new StatUserRegistrationV2Entity() { Tick = Tick1 };
            var entity2 = new StatUserRegistrationV2Entity() { Tick = Tick2 };
            var entities = new List<StatUserRegistrationV2Entity>() { entity1, entity2 };

            var repository = new Mock<IRepository<StatUserRegistrationV2Entity>>();

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

            repositoryFactory.Setup(m => m.Create<StatUserRegistrationV2Entity>(Tables.StatUserRegistrationV2)).Returns(repository.Object);
            repository.Setup(m => m.GetStatEntities(It.Is<StatQueryObject>(p => p.StartInterval == Tick2 &&
                                                                                p.EndInterval == Tick1 &&
                                                                                p.IsStartInclude == false &&
                                                                                p.IsEndInclude == false)))
                .Returns(entities);

            tableValueConverter.Setup(m => m.DateTimeToComparerTick(_startDate)).Returns(Tick2);
            tableValueConverter.Setup(m => m.DateTimeToComparerTick(_finishDate)).Returns(Tick1);
            statMapper.Setup(m => m.StatUserRegistrationToDomain(entity1)).Returns(domain1);
            statMapper.Setup(m => m.StatUserRegistrationToDomain(entity2)).Returns(domain2);

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

            //Act
            var result = statisticsService.GetUserRegistrations(_interval).ToList();

            //Assert
            Assert.AreEqual(2, result.Count);
            CollectionAssert.Contains(result, domain1);
            CollectionAssert.Contains(result, domain2);
        }
コード例 #19
0
ファイル: FiltersManager.cs プロジェクト: GusLab/video-portal
 public void FilterStatUserRegistration(DomainStatUserRegistration domainUserRegistration, DomainReport domainReport)
 {
     _statUserRegistrationFilter.Call(domainUserRegistration, domainReport);
 }