Пример #1
0
        public void Test_NetworkEntityGuid_Index_Set_Causes_Dirty_Bit_Set_After_Changing([EntityDataCollectionTestRange] int index, [Values(1, 2, 3, 4, 5, 6, 7)] int value)
        {
            if (index == 7)
            {
                return;
            }

            //arrange
            ChangeTrackingEntityFieldDataCollectionDecorator collection = new ChangeTrackingEntityFieldDataCollectionDecorator(base.CreateEntityDataCollection());

            var guid = NetworkEntityGuidBuilder.New()
                       .WithType(EntityType.Creature)
                       .WithId((int)value)
                       .Build();

            var guid2 = NetworkEntityGuidBuilder.New()
                        .WithType(EntityType.Player)
                        .WithId((int)value)
                        .Build();

            var guid3 = NetworkEntityGuidBuilder.New()
                        .WithType(EntityType.Player)
                        .WithId((int)value + 1)
                        .Build();

            var guid4 = NetworkEntityGuidBuilder.New()
                        .WithType(EntityType.Player)
                        .WithId((int)value)
                        .Build();

            //act
            collection.SetFieldValue(index, guid);
            collection.ClearTrackedChanges();
            collection.SetFieldValue(index, guid2);
            bool isSet = collection.ChangeTrackingArray.Get(index) && collection.ChangeTrackingArray.Get(index + 1);

            collection.ClearTrackedChanges();
            collection.SetFieldValue(index, guid3);
            isSet &= collection.ChangeTrackingArray.Get(index) && collection.ChangeTrackingArray.Get(index + 1);
            collection.ClearTrackedChanges();
            collection.SetFieldValue(index, guid4);
            isSet &= collection.ChangeTrackingArray.Get(index) && collection.ChangeTrackingArray.Get(index + 1);

            //assert
            Assert.True(isSet, $"Set Value: {value} at Index: {index} did not set change tracked bit.");
        }
Пример #2
0
        public void Test_PendingChanges_Not_True_When_EquivalentValues_Set_Float([EntityDataCollectionTestRange] int index, [Values(1.2f, 2.5f, 3.6335f, 4.673f, 5.22222f, 6.63f, 7.123f, 8.789f)] float value)
        {
            //arrange
            ChangeTrackingEntityFieldDataCollectionDecorator collection = new ChangeTrackingEntityFieldDataCollectionDecorator(base.CreateEntityDataCollection());

            //act
            collection.SetFieldValue(index, value);
            collection.ClearTrackedChanges();                       //clear to remove set track bits
            collection.SetFieldValue(index, value);                 //re set the same value at the same index
            bool isSet = collection.ChangeTrackingArray.Get(index); //this should be false because it should not have been a new value

            //assert
            Assert.False(isSet, $"Set Value: {value} at Index: {index} should not have a set bit since clearing and re setting same value.");
            Assert.False(collection.HasPendingChanges, $"Set Value: {value} at Index: {index} should cause changes pending after setting same value after clear.");
        }
        public void Test_PendingChanges_Not_True_When_EquivalentValues_Set([EntityDataCollectionTestRange] int index, [Values(1, 2, 3, 4, 5, 6, 7, 8)] int value)
        {
            //arrange
            ChangeTrackingEntityFieldDataCollectionDecorator <TestFieldType> collection = new ChangeTrackingEntityFieldDataCollectionDecorator <TestFieldType>(base.CreateEntityDataCollection());

            //act
            collection.SetFieldValue <int>(index, value);
            collection.ClearTrackedChanges();                       //clear to remove set track bits
            collection.SetFieldValue <int>(index, value);           //re set the same value at the same index
            bool isSet = collection.ChangeTrackingArray.Get(index); //this should be false because it should not have been a new value

            //assert
            Assert.False(isSet, $"Set Value: {value} at Index: {index} should not have a set bit since clearing and re setting same value.");
            Assert.False(collection.HasPendingChanges, $"Set Value: {value} at Index: {index} should cause changes pending after setting same value after clear.");
        }
Пример #4
0
        public void Test_8byte_Index_Set_Causes_Dirty_Bit_Set_After_Changing_Half_Chunk([EntityDataCollectionTestRange] int index, [Values(1, 2, 3, 4, 5, 6, 7)] long value)
        {
            if (index == 7)
            {
                return;
            }

            //arrange
            ChangeTrackingEntityFieldDataCollectionDecorator collection = new ChangeTrackingEntityFieldDataCollectionDecorator(base.CreateEntityDataCollection());

            //act
            collection.SetFieldValue <long>(index, value);
            collection.ClearTrackedChanges();
            collection.SetFieldValue <long>(index, 50000000000000);
            bool isSet = collection.ChangeTrackingArray.Get(index) && collection.ChangeTrackingArray.Get(index + 1);

            //assert
            Assert.True(isSet, $"Set Value: {value} at Index: {index} did not set change tracked bit.");
        }
Пример #5
0
        public void Test_Can_Clear_TrackedChanges()
        {
            //arrange
            ChangeTrackingEntityFieldDataCollectionDecorator collection = new ChangeTrackingEntityFieldDataCollectionDecorator(base.CreateEntityDataCollection());

            //act
            for (int i = 0; i < 4; i++)
            {
                collection.SetFieldValue <int>(i, 3);
            }

            collection.ClearTrackedChanges();

            //assert
            for (int i = 0; i < 4; i++)
            {
                Assert.False(collection.ChangeTrackingArray.Get(i), $"Change tracking has Index: {i} set. No index should be set.");
            }
        }