Example #1
0
        public void Scope_and_open_and_save_on_open_context_should_make_entity_in_parent_visible()
        {
            // arrange
            var openEntity = new DummyEntity {
                Name = "Bob"
            };
            DummyEntity scopeEntity;

            /*
             * PROBLEM here:
             * - the inner dbContext is joining the outer dbContext
             * - the tracked dbContext in the outer/parent is not the proxy, thus, no updates were populated.
             * -> maybe the proxy-dbContexts may never "join" the parent scope?
             * -> maybe we should replace or stack the joined dbScopes?
             * --> who is disposing the inner-most dbContext then and how?
             */

            // act
            using (var scope = DbContextScopeFactory.Create())
            {
                var scopeDbContext = scope.Get <DummyDbContext>();

                using (var openDbContext = DbContextScopeFactory.Open <DummyDbContext>())
                {
                    openDbContext.Add(openEntity);
                    openDbContext.SaveChanges();
                }

                scopeEntity = scopeDbContext.Find <DummyEntity>(openEntity.Id);
            }

            // assert
            Assert.AreEqual(openEntity.Id, scopeEntity.Id);
        }
        public void TestCombinesWithPendingChangesAddUpdate()
        {
            // Arrange
            var methodCounter = new DaoMethodCallsCounter();
            var context       = new DummyContext(_folder, methodCounter);

            var newItem = new DummyEntity
            {
                Key  = "1051",
                Name = "Test 1051"
            };

            var newItem2 = new DummyEntity
            {
                Key  = "751",
                Name = "Test 751"
            };

            context.DummyEntitiesWithCache.Add(newItem);
            context.DummyEntitiesWithCache.Update(newItem2);

            // Act
            var addedItem   = context.DummyEntitiesWithCache.FirstOrDefault(x => x.Key == "1051");
            var updatedItem = context.DummyEntitiesWithCache.FirstOrDefault(x => x.Key == "751");

            // Assert
            Assert.AreEqual(newItem2, updatedItem);
            Assert.AreEqual(newItem, addedItem);
            Assert.AreEqual(0, methodCounter.EntityCallsCount);
            Assert.AreEqual(0, methodCounter.GetIdentifiersCallsCount);
        }
Example #3
0
        public void GetOrInsert_WithEntityGet()
        {
            var fixture = new Fixture();

            fixture.Customize(new OmitOnRecursionCustomization());

            var obj = fixture.Create <DummyEntity>();

            var context = this.CreateDummyContext();

            var sut = new Repository <DummyEntity>(context);

            sut.Insert(obj);
            sut.Commit();

            Assert.AreEqual(1, sut.GetAll().Count);

            var request = new DummyEntity()
            {
                Id        = obj.Id,
                Property1 = "sometext"
            };

            var result = sut.GetOrInsert(request);

            Assert.AreEqual(1, sut.GetAll().Count);
            Assert.AreEqual(obj, result);
        }
Example #4
0
        public async Task Update_entity_should_call_refresh_entities_async_in_parent_scope()
        {
            // arrange
            var dummyEntity = new DummyEntity {
                Name = "Bob"
            };

            using (var dbContext = DbContextScopeFactory.Open <DummyDbContext>())
            {
                await dbContext.DummyEntities.AddAsync(dummyEntity);

                await dbContext.SaveChangesAsync();
            }
            CalledMethods.Clear();

            // act
            using (var dbContext = DbContextScopeFactory.Open <DummyDbContext>())
            {
                var savedDummyEntity = await dbContext.DummyEntities.FindAsync(dummyEntity.Id);

                savedDummyEntity.Name = "Alice";
                await dbContext.SaveChangesAsync();
            }

            // assert
            assertCallOrder("SaveChangesAsync", "RefreshEntitiesInParentScopeAsync-SKIP", "Dispose");
        }
Example #5
0
        public void MigratorTests_WhenAnEntityWithASpecificPartitionKeyIsDeleted_ItIsNoLongerInATable()
        {
            // Arrange
            var tableName = "deleting2";
            var entity    = new DummyEntity {
                PartitionKey = "PK", RowKey = "RK", ETag = "*"
            };
            var entity2 = new DummyEntity {
                PartitionKey = "PK2", RowKey = DateTime.UtcNow.Ticks.ToString(), ETag = "*"
            };
            var tableRef = _tableClient.GetTableReference(tableName);

            tableRef.DeleteIfExists();
            tableRef.CreateIfNotExists();
            var op  = TableOperation.Insert(entity);
            var op2 = TableOperation.Insert(entity2);

            tableRef.Execute(op);
            tableRef.Execute(op2);

            // Act
            _migrator.CreateMigration(_ =>
            {
                _.Delete(tableName, "PK");
            }, 6, "1.2", "MigratorTests_WhenAnEntityWithASpecificPartitionKeyIsDeleted_ItIsNoLongerInATable");

            // Assert
            var query  = new TableQuery <DummyEntity>();
            var result = tableRef.ExecuteQuery(query).ToList();

            result.FirstOrDefault(e => e.PartitionKey == "PK").Should().BeNull("this entity was deleted.");
            result.FirstOrDefault(e => e.PartitionKey == "PK2").Should().NotBeNull("this entity has a diferent PK.");
        }
Example #6
0
        public void MigratorTests_WhenInsertIsUsedWithAValidTableNameWhichDoesNotExistsAndShouldBeCreated_ThenPassedEntityIsCreated()
        {
            // Arrange
            var rowKey = DateTime.Now.Ticks.ToString();
            var table  = _tableClient.GetTableReference("dummy");

            // Act
            _migrator.CreateMigration(_ =>
            {
                var entity = new DummyEntity {
                    PartitionKey = "dummy", RowKey = rowKey, Name = "dummy"
                };

                _.Insert("dummy", entity, true);
            }, 1, "1.0", "MigratorTests_WhenInsertIsUsedWithAValidTableNameWhichDoesNotExistsAndShouldBeCreated_ThenPassedEntityIsCreated");

            var query = new TableQuery <DummyEntity>().Where(
                TableQuery.CombineFilters(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "dummy"),
                    TableOperators.And, TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, rowKey)));

            var result = table.ExecuteQuery(query);

            // Assert
            result.FirstOrDefault().Should().NotBeNull();
        }
Example #7
0
        public async void Remove()
        {
            var service = MoqHelper.CreateWithMocks <MemoryDatabaseDelegate>();

            var store = new List <DummyEntity>
            {
                new DummyEntity
                {
                    Id   = "123",
                    Name = "Foo"
                }
            };

            var IMemoryCollectionFactory = Mock.Get(service.IMemoryCollectionFactory);

            IMemoryCollectionFactory.Setup(x => x.GetOrCreateCollection <DummyEntity>()).Returns(store);

            var entity = new DummyEntity
            {
                Id = "123"
            };

            await service.RemoveAsync <DummyEntity>(entity.Id);

            Assert.DoesNotContain(store, x => x.Id == "123");
        }
        public void FilterResultOnCurrentPrincipal_RestrictedScopeOfResponsibility_ReturnsEntitiesWithMatchingAllowedIds()
        {
            // Arrange
            var ids = new List <int> {
                1
            };
            var firstEntity = new DummyEntity {
                Id = 1
            };
            var secondEntity = new DummyEntity {
                Id = 2
            };
            var data = new List <DummyEntity> {
                firstEntity, secondEntity
            };

            SetMockData(data);
            var query = data.AsQueryable();

            _scopeOfResponsibilityService.Setup(x => x.RestrictScopeOfResponsibilityOnLoginConfiguration(out ids)).Returns(true);

            // Act
            var result = _scopeOfResponsibilityService.Object.FilterResultOnCurrentPrincipal(query);

            // Assert
            Assert.AreEqual(firstEntity, result.Single());
        }
Example #9
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Potion.Deleted || m_Potion.Map == Map.Internal)
                {
                    return;
                }

                IPoint3D p = targeted as IPoint3D;

                if (p == null)
                {
                    return;
                }

                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                SpellHelper.GetSurfaceTop(ref p);

                from.RevealingAction();

                IEntity to = new DummyEntity(Serial.Zero, new Point3D(p), map);

                Effects.SendMovingEffect(from, to, m_Potion.ItemID, 7, 0, false, false, m_Potion.Hue, 0);

                Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(ExplodingTarPotionEffect_Callback), new object[] { p, from, map });

                m_Potion.SetNextDrinkTime(from);
            }
Example #10
0
        public void Write_user_via_scope_should_work()
        {
            // arrange
            var entity = new DummyEntity {
                Name = "Bob"
            };

            // act
            using (var scope = DbContextScopeFactory.Create())
            {
                var dbContext = scope.Get <DummyDbContext>();
                dbContext.Add(entity);

                scope.SaveChanges();
            }

            // assert
            using (var scope = DbContextScopeFactory.CreateReadOnly())
            {
                var dbContext = scope.Get <DummyDbContext>();

                var users = dbContext.DummyEntities.ToArray();
                Assert.AreEqual(1, users.Length);
            }
        }
        public IEnumerable <object> GetValues(DummyEntity entity)
        {
            foreach (var field in mapping)
            {
                var value = GetValue(entity, field.Path);

                if (value is JValue jValue)
                {
                    value = jValue.Value;
                }
                else if (value is JToken jToken)
                {
                    value = jToken.ToString();
                }

                if (value is string text)
                {
                    yield return(text.Replace("\n", "\\n"));
                }
                else
                {
                    yield return(value);
                }
            }
        }
Example #12
0
        public void MigratorTests_WhenAnEntityIsDeleted_ItIsNoLongerInATable()
        {
            // Arrange
            var tableName = "deleting";
            var entity    = new DummyEntity {
                PartitionKey = "PK", RowKey = "RK", ETag = "*"
            };
            var tableRef = _tableClient.GetTableReference(tableName);

            tableRef.DeleteIfExists();
            tableRef.CreateIfNotExists();
            var op = TableOperation.Insert(entity);

            tableRef.Execute(op);

            // Act
            _migrator.CreateMigration(_ =>
            {
                _.Delete(tableName, entity);
            }, 5, "1.2", "MigratorTests_WhenAnEntityIsDeleted_ItIsNoLongerInATable");

            // Assert
            var query  = new TableQuery <DummyEntity>();
            var result = tableRef.ExecuteQuery(query);

            result.FirstOrDefault(e => e.RowKey == "PK").Should().BeNull("this entity was deleted.");
        }
Example #13
0
        public void Target(Mobile m)
        {
            if (!m.Poisoned)
            {
                Caster.SendLocalizedMessage(1060176);                   // That creature is not poisoned!
            }
            else if (CheckBSequence(m))
            {
                SpellHelper.Turn(Caster, m);

                /* Cures the target of poisons, but causes the caster to be burned by fire damage for 13-55 hit points.
                 * The amount of fire damage is lessened if the caster has high Karma.
                 */

                Poison p = m.Poison;

                if (p != null)
                {
                    // Cleanse by fire is now difficulty based
                    int chanceToCure = 10000 + (int)(Caster.Skills[SkillName.Chivalry].Value * 75) - ((p.Level + 1) * 2000);
                    chanceToCure /= 100;

                    if (chanceToCure > Utility.Random(100))
                    {
                        if (m.CurePoison(Caster))
                        {
                            if (Caster != m)
                            {
                                Caster.SendLocalizedMessage(1010058);                      // You have cured the target of all poisons!
                            }
                            m.SendLocalizedMessage(1010059);                               // You have been cured of all poisons.
                        }
                    }
                    else
                    {
                        m.SendLocalizedMessage(1010060);                           // You have failed to cure your target!
                    }
                }

                m.PlaySound(0x1E0);
                m.FixedParticles(0x373A, 1, 15, 5012, 3, 2, EffectLayer.Waist);

                IEntity from = new DummyEntity(Serial.Zero, new Point3D(m.X, m.Y, m.Z - 5), m.Map);
                IEntity to   = new DummyEntity(Serial.Zero, new Point3D(m.X, m.Y, m.Z + 45), m.Map);
                Effects.SendMovingParticles(from, to, 0x374B, 1, 0, false, false, 63, 2, 9501, 1, 0, EffectLayer.Head, 0x100);

                Caster.PlaySound(0x208);
                Caster.FixedParticles(0x3709, 1, 30, 9934, 0, 7, EffectLayer.Waist);

                int damage = 50 - ComputePowerValue(4);

                // TODO: Should caps be applied?
                Utility.FixMinMax(ref damage, 13, 55);

                AOS.Damage(Caster, Caster, damage, 0, 100, 0, 0, 0, true);
            }

            FinishSequence();
        }
Example #14
0
        public Separation(Entity _character, Flock _flock, float _neighbourhoodMaxDistance, float _neighbourhoodMinDotProduct)
            : base(_character, _flock, _neighbourhoodMaxDistance, _neighbourhoodMinDotProduct)
        {
            dummy = new DummyEntity();
            flee = new Flee(_character, dummy);

            maxNeighborhoodSize = 5;
        }
Example #15
0
        public void NullPredicate()
        {
            var entity = new DummyEntity();

            new TestCaseRunner()
            .Run(() => PredicateMiddleware <DummyContext, DummyEntity> .NullPredicate(entity))
            .Verify(true, (Type)null);
        }
Example #16
0
        public PathFollow(Entity _character, Path _path)
        {
            character = _character;
            path = _path;

            dummy = new DummyEntity();
            seek = new Seek(character, dummy);
        }
Example #17
0
        public Cohesion(Entity _character, Flock _flock, float _neighbourhoodMaxDistance, float _neighbourhoodMinDotProduct)
            : base(_character, _flock, _neighbourhoodMaxDistance, _neighbourhoodMinDotProduct)
        {
            dummy = new DummyEntity();
            seek = new Seek(character, dummy);

            maxNeighborhoodSize = 30;
        }
Example #18
0
 public void RegisterEntities()
 {
     player   = new Player();
     dummy    = new DummyEntity();
     Entities = new List <Entity>();
     Entities.Add(player);
     Entities.Add(dummy);
 }
Example #19
0
        public void Should_insert_entity_when_entity_is_transient()
        {
            var entity = new DummyEntity();
            int count  = _repository.Count();

            _repository.InsertOrUpdate(entity);

            _repository.Count().Should().Be(count + 1);
        }
        public void ReturnsEverythingFieldIsNullOrWhiteSpace()
        {
            var sut  = new DummyEntity();
            var list = sut.ShapeDataObject() as IDictionary <string, object>;

            Assert.Equal(sut.Fizz, list?["Fizz"]);
            Assert.Equal(sut.Buzz, list?["Buzz"]);
            Assert.Equal(sut.Id, list?["Id"]);
        }
Example #21
0
        public void Should_insert_single_entity()
        {
            int count  = _repository.Count();
            var entity = new DummyEntity();

            _repository.Insert(entity);

            _repository.Count().Should().Be(count + 1);
        }
        public void ShapeData(string field, string key)
        {
            var sut  = new DummyEntity();
            var list = sut.ShapeDataObject(field) as IDictionary <string, object>;

            Assert.Equal(sut.Fizz, list?[key]);
            Assert.Throws <KeyNotFoundException>(() => list?["Buzz"]);
            Assert.Throws <KeyNotFoundException>(() => list?["Id"]);
        }
Example #23
0
        public void Equality_NullEqualsNull_ReturnsTrue()
        {
            // Arrange
            DummyEntity entity1 = null;
            DummyEntity entity2 = null;

            // Act - Assert
            Assert.IsTrue(entity1 == entity2);
        }
Example #24
0
        public ObstacleAvoidance(Entity _character, float _lookahead, string[] _tagsToAvoid)
        {
            character = _character;
            lookahead = _lookahead;
            tagsToAvoid = _tagsToAvoid;

            dummy = new DummyEntity();
            seek = new Seek(character, dummy);
        }
Example #25
0
        public void Equality_NotNullEqualsNull_ReturnsFalse()
        {
            // Arrange
            DummyEntity entity1 = new DummyEntity();
            DummyEntity entity2 = null;

            // Act - Assert
            Assert.IsFalse(entity1 == entity2);
            Assert.IsFalse(entity1.Equals(entity2));
        }
Example #26
0
        public async void Set_Should_Invoke_Cache()
        {
            var service       = MoqHelper.CreateWithMocks <EntityCacheService>();
            var ICacheService = Mock.Get(service.ICacheService);

            var dummy = new DummyEntity();
            await service.SetAsync(dummy);

            ICacheService.VerifyIgnoreArgs(x => x.SetAsync <DummyEntity>(null, null, null), Times.Once);
        }
        public void ShouldUsePreProcessUpdate()
        {
            var toEditModel = new DummyEntity {
                Name = "Edited Model", Id = 1
            };
            var editedModel = _repository.Update(toEditModel);

            Assert.Equal("Edited Model_UPDATED", editedModel.Name);
            Assert.Equal(toEditModel.Id, editedModel.Id);
        }
Example #28
0
        public FormationManager(FormationPattern _pattern)
        {
            pattern = _pattern;
            slotAssignments = new Dictionary<Entity, SlotAssignment>();

            arrive = new Arrive(null, null, 3f, 5f);
            dummy = new DummyEntity();

            id = count++;
        }
 public void CanCreateAndSetAuditedEntity()
 {
     SystemTime.Now = () => new DateTime(9,8,7,6,5,4);
     var a = new DummyEntity {CreatedBy= "vincent",Created = SystemTime.Now()};
     a.ShouldNotBeNull();
     a.Created.ShouldNotBeNull();
     a.CreatedBy.ShouldNotBeNull();
     a.CreatedBy.ShouldEqual("vincent");
     a.Created.ShouldEqual(SystemTime.Now());
 }
        public void ShouldCreateModel()
        {
            var model = new DummyEntity {
                Name = "New Model"
            };
            var newModel = _repository.Create(model);

            Assert.Equal(model.Name, newModel.Name);
            Assert.True(model.Id > 4);
        }
Example #31
0
 protected WebApplicationFactory <Startup> Mock(DummyEntity entity)
 {
     return(api.WithWebHostBuilder(a => a.ConfigureServices(s =>
     {
         s.Add(new ServiceDescriptor(typeof(IEnumerable <DummyEntity>), new List <DummyEntity>
         {
             Copy(entity)
         }));
     })));
 }
Example #32
0
        public async void Remove_Should_Invoke_Cache()
        {
            var service       = MoqHelper.CreateWithMocks <EntityCacheService>();
            var ICacheService = Mock.Get(service.ICacheService);

            var dummy = new DummyEntity();
            await service.RemoveAsync <DummyEntity>("123");

            ICacheService.Verify(x => x.RemoveAsync(It.IsAny <string>()), Times.Once);
        }
Example #33
0
 public override void Begin()
 {
     base.Begin();
     GameCore.Instance.RenderManager.ClearColor = new Color(159, 182, 205);
     dummy = new DummyEntity();
     Add(dummy);
     Add(new DummyEntityBis());
     Add(new DummyEntityBis("r"));
     Add(new Platform(new Vector2(0, 0)));
 }
        public void ShouldUsePreProcessCreate()
        {
            var model = new DummyEntity {
                Name = "New Model"
            };
            var newModel = _repository.Create(model);

            Assert.Equal(model.Name, newModel.Name);
            Assert.Equal("New Model_CREATED", model.Name);
        }
        public async Task ShouldUpdateModelAsync()
        {
            var toEditModel = new DummyEntity {
                Name = "Edited Model", Id = 1
            };
            var editedModel = await _repository.UpdateAsync(toEditModel);

            Assert.Equal(toEditModel.Name, editedModel.Name);
            Assert.Equal(toEditModel.Id, editedModel.Id);
        }
        public void ShouldUpdateModel()
        {
            var toEditModel = new DummyEntity {
                Name = "Edited Model", Id = 1
            };
            var editedModel = _repository.Update(toEditModel);

            Assert.Equal(toEditModel.Name, editedModel.Name);
            Assert.Equal(toEditModel.Id, editedModel.Id);
        }
Example #37
0
        // constructor
        public Wander(Entity _character, float _maxAcceleration, float _maxAngle, float _maxYSpeed, Bounds _bbox)
        {
            character = _character;
            maxAcceleration = _maxAcceleration;
            maxAngle = _maxAngle;
            maxYSpeed = _maxYSpeed;
            bbox = _bbox;

            target = new DummyEntity();
            seek = new Seek(character, target);
        }
Example #38
0
        public static void DoGraphicalEffect( Mobile m )
        {
            m.PlaySound( 0xF6 );
            m.PlaySound( 0x1F7 );

            m.FixedParticles( 0x3709, 1, 30, 9963, 13, 3, EffectLayer.Head );

            IEntity from = new DummyEntity( Serial.Zero, new Point3D( m.X, m.Y, m.Z - 10 ), m.Map );
            IEntity to = new DummyEntity( Serial.Zero, new Point3D( m.X, m.Y, m.Z + 50 ), m.Map );

            Effects.SendMovingParticles( from, to, 0x2255, 1, 0, false, false, 13, 3, 9501, 1, 0, EffectLayer.Head, 0x100 );
        }
Example #39
0
        public void Target( Mobile m )
        {
            if ( !m.Poisoned )
            {
                Caster.SendLocalizedMessage( 1060176 ); // That creature is not poisoned!
            }
            else if ( CheckBSequence( m ) )
            {
                SpellHelper.Turn( Caster, m );

                /* Cures the target of poisons, but causes the caster to be burned by fire damage for 13-55 hit points.
                 * The amount of fire damage is lessened if the caster has high Karma.
                 */

                Poison p = m.Poison;

                if ( p != null )
                {
                    // Cleanse by fire is now difficulty based
                    int chanceToCure = 10000 + (int) ( Caster.Skills[SkillName.Chivalry].Value * 75 ) - ( ( p.Level + 1 ) * 2000 );
                    chanceToCure /= 100;

                    if ( chanceToCure > Utility.Random( 100 ) )
                    {
                        if ( m.CurePoison( Caster ) )
                        {
                            if ( Caster != m )
                                Caster.SendLocalizedMessage( 1010058 ); // You have cured the target of all poisons!

                            m.SendLocalizedMessage( 1010059 ); // You have been cured of all poisons.
                        }
                    }
                    else
                    {
                        m.SendLocalizedMessage( 1010060 ); // You have failed to cure your target!
                    }
                }

                m.PlaySound( 0x1E0 );
                m.FixedParticles( 0x373A, 1, 15, 5012, 3, 2, EffectLayer.Waist );

                IEntity from = new DummyEntity( Serial.Zero, new Point3D( m.X, m.Y, m.Z - 5 ), m.Map );
                IEntity to = new DummyEntity( Serial.Zero, new Point3D( m.X, m.Y, m.Z + 45 ), m.Map );
                Effects.SendMovingParticles( from, to, 0x374B, 1, 0, false, false, 63, 2, 9501, 1, 0, EffectLayer.Head, 0x100 );

                Caster.PlaySound( 0x208 );
                Caster.FixedParticles( 0x3709, 1, 30, 9934, 0, 7, EffectLayer.Waist );

                int damage = 50 - ComputePowerValue( 4 );

                // TODO: Should caps be applied?
                Utility.FixMinMax( ref damage, 13, 55 );

                AOS.Damage( Caster, Caster, damage, 0, 100, 0, 0, 0, true );
            }

            FinishSequence();
        }
Example #40
0
        public override void OnCast()
        {
            BaseWeapon weapon = Caster.Weapon as BaseWeapon;

            if ( weapon == null || weapon is Fists )
            {
                Caster.SendLocalizedMessage( 501078 ); // You must be holding a weapon.
            }
            else if ( CheckSequence() )
            {
                /* Temporarily enchants the weapon the caster is currently wielding.
                 * The type of damage the weapon inflicts when hitting a target will
                 * be converted to the target's worst Resistance type.
                 * Duration of the effect is affected by the caster's Karma and lasts for 3 to 11 seconds.
                 */

                int itemID, soundID;

                switch ( weapon.Skill )
                {
                    case SkillName.Macing:
                        itemID = 0xFB4;
                        soundID = 0x232;
                        break;
                    case SkillName.Archery:
                        itemID = 0x13B1;
                        soundID = 0x145;
                        break;
                    default:
                        itemID = 0xF5F;
                        soundID = 0x56;
                        break;
                }

                Caster.PlaySound( 0x20C );
                Caster.PlaySound( soundID );
                Caster.FixedParticles( 0x3779, 1, 30, 9964, 3, 3, EffectLayer.Waist );

                IEntity from = new DummyEntity( Serial.Zero, new Point3D( Caster.X, Caster.Y, Caster.Z ), Caster.Map );
                IEntity to = new DummyEntity( Serial.Zero, new Point3D( Caster.X, Caster.Y, Caster.Z + 50 ), Caster.Map );
                Effects.SendMovingParticles( from, to, itemID, 1, 0, false, false, 33, 3, 9501, 1, 0, EffectLayer.Head, 0x100 );

                double seconds = ComputePowerValue( 20 );

                // TODO: Should caps be applied?
                Utility.FixMinMax( ref seconds, 3.0, 11.0 );

                TimeSpan duration = TimeSpan.FromSeconds( seconds );

                if ( m_Table.ContainsKey( Caster ) )
                {
                    Timer t = m_Table[Caster].Timer;

                    if ( t != null )
                        t.Stop();
                }

                double chivalry = Caster.Skills.Chivalry.Value;

                Timer expireTimer = new ExpireTimer( Caster, duration );
                int procChance = (int) ( ( chivalry - 20.0 ) / 0.6 );
                int bonusDamage = (int) ( ( chivalry - 90.0 ) / 2.0 );

                Utility.FixMinMax( ref procChance, 0, 100 );
                Utility.FixMinMax( ref bonusDamage, 0, 15 );

                BuffInfo.AddBuff( Caster, new BuffInfo( BuffIcon.ConsecrateWeapon, 1151385, 1151386, duration, Caster, String.Format( "{0}\t{1}", procChance, bonusDamage ) ) );

                ConsecrateContext context = new ConsecrateContext( expireTimer, procChance, bonusDamage );

                m_Table[Caster] = context;

                expireTimer.Start();
            }

            FinishSequence();
        }