public void GetEntityNotifications()
        {
            var provider   = new PetaPocoUnitOfWorkProvider(Logger);
            var unitOfWork = provider.GetUnitOfWork();

            using (var repo = new NotificationsRepository(unitOfWork))
            {
                var node1 = new NodeDto {
                    CreateDate = DateTime.Now, Level = 1, NodeObjectType = Guid.Parse(Constants.ObjectTypes.ContentItem), ParentId = -1, Path = "-1,1", SortOrder = 1, Text = "hello1", Trashed = false, UniqueId = Guid.NewGuid(), UserId = 0
                };
                unitOfWork.Database.Insert(node1);
                var entity1 = Mock.Of <IEntity>(e => e.Id == node1.NodeId);
                var node2   = new NodeDto {
                    CreateDate = DateTime.Now, Level = 1, NodeObjectType = Guid.Parse(Constants.ObjectTypes.ContentItem), ParentId = -1, Path = "-1,2", SortOrder = 1, Text = "hello2", Trashed = false, UniqueId = Guid.NewGuid(), UserId = 0
                };
                unitOfWork.Database.Insert(node2);
                var entity2 = Mock.Of <IEntity>(e => e.Id == node2.NodeId);

                for (var i = 0; i < 10; i++)
                {
                    var userDto = new UserDto {
                        ContentStartId = -1, Email = "test" + i, Login = "******" + i, MediaStartId = -1, Password = "******", Type = 1, UserName = "******" + i, UserLanguage = "en"
                    };
                    unitOfWork.Database.Insert(userDto);
                    var userNew      = Mock.Of <IUser>(e => e.Id == userDto.Id);
                    var notification = repo.CreateNotification(userNew, (i % 2 == 0) ? entity1 : entity2, i.ToString(CultureInfo.InvariantCulture));
                }

                var notifications = repo.GetEntityNotifications(entity1);

                Assert.AreEqual(5, notifications.Count());
            }
        }
Ejemplo n.º 2
0
        public void GetEntityNotifications()
        {
            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                var repo = new NotificationsRepository((IScopeAccessor)provider);

                var node1 = new NodeDto {
                    CreateDate = DateTime.Now, Level = 1, NodeObjectType = Constants.ObjectTypes.ContentItem, ParentId = -1, Path = "-1,1", SortOrder = 1, Text = "hello1", Trashed = false, UniqueId = Guid.NewGuid(), UserId = -1
                };
                ScopeAccessor.AmbientScope.Database.Insert(node1);
                IEntity entity1 = Mock.Of <IEntity>(e => e.Id == node1.NodeId);
                var     node2   = new NodeDto {
                    CreateDate = DateTime.Now, Level = 1, NodeObjectType = Constants.ObjectTypes.ContentItem, ParentId = -1, Path = "-1,2", SortOrder = 1, Text = "hello2", Trashed = false, UniqueId = Guid.NewGuid(), UserId = -1
                };
                ScopeAccessor.AmbientScope.Database.Insert(node2);
                IEntity entity2 = Mock.Of <IEntity>(e => e.Id == node2.NodeId);

                for (int i = 0; i < 10; i++)
                {
                    var userDto = new UserDto {
                        Email = "test" + i, Login = "******" + i, Password = "******", UserName = "******" + i, UserLanguage = "en", CreateDate = DateTime.Now, UpdateDate = DateTime.Now
                    };
                    ScopeAccessor.AmbientScope.Database.Insert(userDto);
                    IUser        userNew      = Mock.Of <IUser>(e => e.Id == userDto.Id);
                    Notification notification = repo.CreateNotification(userNew, (i % 2 == 0) ? entity1 : entity2, i.ToString(CultureInfo.InvariantCulture));
                }

                IEnumerable <Notification> notifications = repo.GetEntityNotifications(entity1);

                Assert.AreEqual(5, notifications.Count());
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Deletes notifications by entity
        /// </summary>
        /// <param name="entity"></param>
        public IEnumerable <Notification> GetEntityNotifications(IEntity entity)
        {
            var uow        = _uowProvider.GetUnitOfWork();
            var repository = new NotificationsRepository(uow);

            return(repository.GetEntityNotifications(entity));
        }