Exemple #1
0
        public static void Test_Can_Build_Empty_Guid_With_0_Id()
        {
            //arrange
            NetworkEntityGuidBuilder builder = new NetworkEntityGuidBuilder();

            //act
            NetworkEntityGuid guid = builder.WithId(0).WithId(0).Build();

            //assert
            Assert.NotNull(guid);
            Assert.IsTrue(guid.isEmpty);
        }
Exemple #2
0
        public static void Test_Can_Build_Guid_With_Provided_EntityType(EntityType type)
        {
            //arrange
            NetworkEntityGuidBuilder builder = new NetworkEntityGuidBuilder();

            //act
            NetworkEntityGuid guid = builder.WithType(type).WithType(type).Build();

            //assert
            Assert.NotNull(guid);
            //won't be empty with an entity type.

            Assert.AreEqual(type, guid.EntityType);
        }
Exemple #3
0
        public static void Test_Can_Build_Guid_With_Provided_Id(int id)
        {
            //arrange
            NetworkEntityGuidBuilder builder = new NetworkEntityGuidBuilder();

            //act
            NetworkEntityGuid guid = builder.WithId(Math.Max(65, id - 5)).WithId(id).Build();

            //assert
            Assert.NotNull(guid);
            Assert.IsFalse(guid.isEmpty);

            Assert.AreEqual(id, guid.EntityId);
        }
Exemple #4
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.");
        }
Exemple #5
0
 public NetworkEntityGuid Create(EntityType entityType)
 {
     return(NetworkEntityGuidBuilder.New().WithType(entityType)
            .WithId(Interlocked.Increment(ref currentId))
            .Build());
 }