Exemple #1
0
        public void CreateHttpMessageEntityTest()
        {
            //Arrange
            const string userLanguages = "userLanguages";

            var tableValueConverter = new Mock <ITableValueConverter>();
            var statEntityFactory   = new StatEntityFactory(tableValueConverter.Object);

            tableValueConverter.Setup(m => m.DateTimeToTickWithGuid(_dateTime)).Returns(TickWithGuid);
            tableValueConverter.Setup(m => m.ArrayToString(_userLanguages)).Returns(userLanguages);

            //Act
            var httpMessage = statEntityFactory.CreateHttpMessageEntity(EventId, _dateTime, _domain);

            //Assert
            Assert.AreEqual(TickWithGuid, httpMessage.Tick);
            Assert.AreEqual(EventId, httpMessage.EventId);
            Assert.AreEqual(_dateTime, httpMessage.DateTime);
            Assert.AreEqual(AnonymousId, httpMessage.AnonymousId);
            Assert.AreEqual(HttpMethod, httpMessage.HttpMethod);
            Assert.AreEqual(IsAuthenticated, httpMessage.IsAuthenticated);
            Assert.AreEqual(StatusCode, httpMessage.StatusCode);
            Assert.AreEqual(Url, httpMessage.Url);
            Assert.AreEqual(UrlReferrer, httpMessage.UrlReferrer);
            Assert.AreEqual(UserAgent, httpMessage.UserAgent);
            Assert.AreEqual(UserHostAddress, httpMessage.UserHostAddress);
            Assert.AreEqual(UserHostName, httpMessage.UserHostName);
            Assert.AreEqual(UserId, httpMessage.UserId);
            Assert.AreEqual(userLanguages, httpMessage.UserLanguages);
        }
Exemple #2
0
        public void CreateProjectUploadingEntityTest()
        {
            //Arrange
            const string productName    = "productName";
            const string projectId      = "projectId";
            const string projectName    = "projectName";
            const string productVersion = "12.3";

            const ProjectType    projectType    = ProjectType.Tag;
            const ProjectSubtype projectSubtype = ProjectSubtype.Friend;

            var tableValueConverter = new Mock <ITableValueConverter>();
            var statEntityFactory   = new StatEntityFactory(tableValueConverter.Object);

            tableValueConverter.Setup(m => m.DateTimeToTickWithGuid(_dateTime)).Returns(TickWithGuid);
            tableValueConverter.Setup(m => m.UserAgentToProductName(UserAgent)).Returns(productName);
            tableValueConverter.Setup(m => m.UserAgentToVersion(UserAgent)).Returns(productVersion);

            //Act
            var projectUploadingEntity = statEntityFactory.CreateProjectUploadingEntity(EventId, _dateTime, _domain, projectId, projectName, projectType, projectSubtype);

            //Assert
            Assert.AreEqual(TickWithGuid, projectUploadingEntity.Tick);
            Assert.AreEqual(EventId, projectUploadingEntity.EventId);
            Assert.AreEqual(_dateTime, projectUploadingEntity.DateTime);
            Assert.AreEqual(productName, projectUploadingEntity.ProductName);
            Assert.AreEqual(UserId, projectUploadingEntity.UserId);
            Assert.AreEqual(projectId, projectUploadingEntity.ProjectId);
            Assert.AreEqual(projectName, projectUploadingEntity.ProjectName);
            Assert.AreEqual(IdentityProvider, projectUploadingEntity.IdentityProvider);
            Assert.AreEqual(productVersion, projectUploadingEntity.ProductVersion);
            Assert.AreEqual((int)projectType, projectUploadingEntity.ProjectType);
            Assert.AreEqual((int)projectSubtype, projectUploadingEntity.TagType);
        }
Exemple #3
0
        public void CreateProjectCreatingEntityTest()
        {
            //Arrange
            const string producer   = "producer";
            const string version    = "version";
            const string projectId  = "projectId";
            const string actionType = "actionType";

            var tableValueConverter = new Mock <ITableValueConverter>();
            var statEntityFactory   = new StatEntityFactory(tableValueConverter.Object);

            tableValueConverter.Setup(m => m.DateTimeToTickWithGuid(_dateTime)).Returns(TickWithGuid);
            tableValueConverter.Setup(m => m.UserAgentToProductName(UserAgent)).Returns(producer);
            tableValueConverter.Setup(m => m.UserAgentToVersion(UserAgent)).Returns(version);

            //Act
            var statProjectStateEntity = statEntityFactory.CreateProjectCreatingEntity(_dateTime, _domain, projectId, actionType);

            //Assert
            Assert.AreEqual(projectId, statProjectStateEntity.ProjectId);
            Assert.AreEqual(actionType, statProjectStateEntity.ActionType);
            Assert.AreEqual(_dateTime, statProjectStateEntity.DateTime);
            Assert.AreEqual(producer, statProjectStateEntity.Producer);
            Assert.AreEqual(version, statProjectStateEntity.Version);
        }
Exemple #4
0
        public Task AddUserRegistration(DomainActionData domain)
        {
            string   eventId     = GuidWraper.Generate();
            DateTime curDateTime = DateTimeWrapper.CurrentDateTime();

            StatUserRegistrationV2Entity userRegistrationEntity = StatEntityFactory.CreateUserRegistrationEntity(eventId, curDateTime, domain);
            ITableRepository <StatUserRegistrationV2Entity> userRegistrationRepository = RepositoryFactory.Create <StatUserRegistrationV2Entity>();

            return(userRegistrationRepository.AddAsync(userRegistrationEntity));
        }
        public Task AddProjectUploading(DomainActionData actionData, string projectId, string projectName, ProjectType projectType, ProjectSubtype projectSubtype)
        {
            string   eventId     = GuidWraper.Generate();
            DateTime curDateTime = DateTimeWrapper.CurrentDateTime();

            StatProjectUploadingV2Entity projectUploadingEntity = StatEntityFactory.CreateProjectUploadingEntity(eventId, curDateTime, actionData, projectId, projectName, projectType, projectSubtype);
            ITableRepository <StatProjectUploadingV2Entity> projectUploadingRepository = RepositoryFactory.Create <StatProjectUploadingV2Entity>();

            return(projectUploadingRepository.AddAsync(projectUploadingEntity));
        }
Exemple #6
0
        public Task AddProjectDeletion(DomainActionData domain, string projectId)
        {
            string   eventId     = GuidWraper.Generate();
            DateTime curDateTime = DateTimeWrapper.CurrentDateTime();

            StatProjectDeletionV2Entity statProjectDeletionEntity = StatEntityFactory.CreateProjectDeletionEntity(eventId, curDateTime, domain, projectId);
            ITableRepository <StatProjectDeletionV2Entity> projectDeletionRepository = RepositoryFactory.Create <StatProjectDeletionV2Entity>();

            return(projectDeletionRepository.AddAsync(statProjectDeletionEntity));
        }
        public Task AddWatching(DomainActionData domain, string projectId)
        {
            string   eventId     = GuidWraper.Generate();
            DateTime curDateTime = DateTimeWrapper.CurrentDateTime();

            StatWatchingV2Entity watchingEntity = StatEntityFactory.CreateWatchingEntity(eventId, curDateTime, domain, projectId);
            ITableRepository <StatWatchingV2Entity> watchingRepository = RepositoryFactory.Create <StatWatchingV2Entity>();

            return(watchingRepository.AddAsync(watchingEntity));
        }
Exemple #8
0
        public void CreateUserLoginEntityTest()
        {
            //Arrange
            var tableValueConverter = new Mock <ITableValueConverter>();
            var statEntityFactory   = new StatEntityFactory(tableValueConverter.Object);

            tableValueConverter.Setup(m => m.DateTimeToTickWithGuid(_dateTime)).Returns(TickWithGuid);
            tableValueConverter.Setup(m => m.UserAgentToProductName(UserAgent)).Returns(ProductName);

            //Act
            var userLoginEntity = statEntityFactory.CreateUserLoginEntity(EventId, _dateTime, _domain);

            //Assert
            Assert.AreEqual(TickWithGuid, userLoginEntity.Tick);
            Assert.AreEqual(EventId, userLoginEntity.EventId);
            Assert.AreEqual(_dateTime, userLoginEntity.DateTime);
            Assert.AreEqual(ProductName, userLoginEntity.ProductName);
            Assert.AreEqual(IdentityProvider, userLoginEntity.IdentityProvider);
            Assert.AreEqual(UserId, userLoginEntity.UserId);
            Assert.AreEqual(Email, userLoginEntity.Email);
            Assert.AreEqual(UserName, userLoginEntity.UserName);
        }
Exemple #9
0
        public void CreateWatchingEntityTest()
        {
            //Arrange
            const string projectId = "projectId";

            var tableValueConverter = new Mock <ITableValueConverter>();
            var statEntityFactory   = new StatEntityFactory(tableValueConverter.Object);

            tableValueConverter.Setup(m => m.DateTimeToTickWithGuid(_dateTime)).Returns(TickWithGuid);

            //Act
            var watchingEntity = statEntityFactory.CreateWatchingEntity(EventId, _dateTime, _domain, projectId);

            //Assert
            Assert.AreEqual(TickWithGuid, watchingEntity.Tick);
            Assert.AreEqual(EventId, watchingEntity.EventId);
            Assert.AreEqual(_dateTime, watchingEntity.DateTime);
            Assert.AreEqual(AnonymousId, watchingEntity.AnonymousId);
            Assert.AreEqual(IsAuthenticated, watchingEntity.IsAuthenticated);
            Assert.AreEqual(UrlReferrer, watchingEntity.UrlReferrer);
            Assert.AreEqual(projectId, watchingEntity.ProjectId);
            Assert.AreEqual(UserId, watchingEntity.UserId);
        }
Exemple #10
0
        public void CreateProjectDeletionEntityTest()
        {
            //Arrange
            const string productName = "productName";
            const string projectId   = "projectId";

            var tableValueConverter = new Mock <ITableValueConverter>();
            var statEntityFactory   = new StatEntityFactory(tableValueConverter.Object);

            tableValueConverter.Setup(m => m.DateTimeToTickWithGuid(_dateTime)).Returns(TickWithGuid);
            tableValueConverter.Setup(m => m.UserAgentToProductName(UserAgent)).Returns(productName);

            //Act
            var projectDeletionEntity = statEntityFactory.CreateProjectDeletionEntity(EventId, _dateTime, _domain, projectId);

            //Assert
            Assert.AreEqual(TickWithGuid, projectDeletionEntity.Tick);
            Assert.AreEqual(EventId, projectDeletionEntity.EventId);
            Assert.AreEqual(_dateTime, projectDeletionEntity.DateTime);
            Assert.AreEqual(productName, projectDeletionEntity.ProductName);
            Assert.AreEqual(projectId, projectDeletionEntity.ProjectId);
            Assert.AreEqual(UserId, projectDeletionEntity.UserId);
        }