コード例 #1
0
        public void GetByID_OneItem_ReturnsDMAction()
        {
            // Arrange
            var      id     = Guid.NewGuid();
            DMAction entity = new DMAction {
                ID = id
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <DMAction>(entity));

            // Assert
            Assert.AreNotSame(entity, _cache.GetByID(id));
        }
コード例 #2
0
        private static void OnDMAction(int actionTypeID)
        {
            string details = ProcessEventAndBuildDetails(actionTypeID);

            NWObject dm = OBJECT_SELF;

            var record = new DMAction
            {
                DMActionTypeID = actionTypeID,
                Name           = dm.Name,
                CDKey          = GetPCPublicCDKey(dm),
                Details        = details
            };

            // Bypass the caching logic
            DataService.DataQueue.Enqueue(new DatabaseAction(record, DatabaseActionType.Insert));
        }
コード例 #3
0
        private static void OnDMAction(int actionTypeID)
        {
            string details = ProcessEventAndBuildDetails(actionTypeID);

            NWObject dm = Object.OBJECT_SELF;

            var record = new DMAction
            {
                DMActionTypeID = actionTypeID,
                Name           = dm.Name,
                CDKey          = _.GetPCPublicCDKey(dm),
                DateOfAction   = DateTime.UtcNow,
                Details        = details
            };

            // Don't cache DM actions.
            DataService.DataQueue.Enqueue(new DatabaseAction(record, DatabaseActionType.Insert));
        }
コード例 #4
0
        public void GetByID_TwoItems_ReturnsCorrectObject()
        {
            // Arrange
            var      id1     = Guid.NewGuid();
            var      id2     = Guid.NewGuid();
            DMAction entity1 = new DMAction {
                ID = id1
            };
            DMAction entity2 = new DMAction {
                ID = id2
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <DMAction>(entity1));
            MessageHub.Instance.Publish(new OnCacheObjectSet <DMAction>(entity2));

            // Assert
            Assert.AreNotSame(entity1, _cache.GetByID(id1));
            Assert.AreNotSame(entity2, _cache.GetByID(id2));
        }
コード例 #5
0
        public bool Run(params object[] args)
        {
            int    actionTypeID = Convert.ToInt32(args[0]);
            string details      = BuildDetails(actionTypeID);

            NWObject dm = Object.OBJECT_SELF;

            var record = new DMAction
            {
                DMActionTypeID = actionTypeID,
                Name           = dm.Name,
                CDKey          = _.GetPCPublicCDKey(dm),
                DateOfAction   = DateTime.UtcNow,
                Details        = details
            };

            // Don't cache DM actions.
            _data.DataQueue.Enqueue(new DatabaseAction(record, DatabaseActionType.Insert));
            return(true);
        }
コード例 #6
0
        public void GetByID_RemovedItem_ReturnsCorrectObject()
        {
            // Arrange
            var      id1     = Guid.NewGuid();
            var      id2     = Guid.NewGuid();
            DMAction entity1 = new DMAction {
                ID = id1
            };
            DMAction entity2 = new DMAction {
                ID = id2
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <DMAction>(entity1));
            MessageHub.Instance.Publish(new OnCacheObjectSet <DMAction>(entity2));
            MessageHub.Instance.Publish(new OnCacheObjectDeleted <DMAction>(entity1));

            // Assert
            Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(id1); });
            Assert.AreNotSame(entity2, _cache.GetByID(id2));
        }