Esempio n. 1
0
        public static void Set_InvalidIndex_ThrowsArgumentOutOfRangeException()
        {
            WireReadyBitArray WireReadyBitArray = new WireReadyBitArray(16);

            Assert.Throws <ArgumentOutOfRangeException>(() => WireReadyBitArray.Set(-1, true));
            Assert.Throws <ArgumentOutOfRangeException>(() => WireReadyBitArray.Set(WireReadyBitArray.Length, true));

            Assert.Throws <ArgumentOutOfRangeException>(() => WireReadyBitArray[-1] = true);
            Assert.Throws <ArgumentOutOfRangeException>(() => WireReadyBitArray[WireReadyBitArray.Length] = true);
        }
Esempio n. 2
0
        public static void Get_Set(bool def, bool[] newValues)
        {
            WireReadyBitArray WireReadyBitArray = new WireReadyBitArray(newValues.Length, def);

            for (int i = 0; i < newValues.Length; i++)
            {
                WireReadyBitArray.Set(i, newValues[i]);
                Assert.AreEqual(newValues[i], WireReadyBitArray[i]);
                Assert.AreEqual(newValues[i], WireReadyBitArray.Get(i));
            }
        }
Esempio n. 3
0
        public void Test_ChangeTracker_Doesnt_Set_Change_Bits_On_Same_Value_After_Clear_FieldValueUpdate()
        {
            //arrange
            WireReadyBitArray bitArray = new WireReadyBitArray(1328);

            bitArray.Set(1, true);
            bitArray.Set(2, true);
            bitArray.Set(4, true);

            //Reference the actual client's visibile field update computation.
            IEntityDataFieldContainer dataCollection = NetworkVisibilityCreationBlockToVisibilityEventFactory.CreateInitialEntityFieldContainer(new FieldValueUpdate(bitArray, new int[] { 5, 4, 7 }));

            ChangeTrackingEntityFieldDataCollectionDecorator collection = new ChangeTrackingEntityFieldDataCollectionDecorator(dataCollection, bitArray);
            FieldValueUpdateFactory updateFactory = new FieldValueUpdateFactory();

            //act
            FieldValueUpdate fieldValueUpdate = updateFactory.Create(new EntityFieldUpdateCreationContext(collection, collection.ChangeTrackingArray));

            Assert.AreEqual(3, fieldValueUpdate.FieldValueUpdateMask.EnumerateSetBitsByIndex().Count(), $"Found more than 1 set bit.");
            Assert.AreEqual(5, fieldValueUpdate.FieldValueUpdates.First(), $"Serialized value was not expected value.");
            Assert.AreEqual(1, fieldValueUpdate.FieldValueUpdateMask.EnumerateSetBitsByIndex().First(), $"Index: {1} was expected to be first index.");

            collection.ClearTrackedChanges();


            //Check they're event before setting them again
            Assert.AreEqual(collection.GetFieldValue <int>(1), 5, $"Values not the same.");
            Assert.AreEqual(collection.GetFieldValue <int>(2), 4, $"Values not the same.");
            collection.SetFieldValue(1, 5);
            collection.SetFieldValue(2, 4);

            fieldValueUpdate = updateFactory.Create(new EntityFieldUpdateCreationContext(collection, collection.ChangeTrackingArray));

            //assert
            Assert.AreEqual(0, fieldValueUpdate.FieldValueUpdateMask.EnumerateSetBitsByIndex().Count(), $"Found more than 1 set bit.");
            Assert.AreEqual(0, fieldValueUpdate.FieldValueUpdates.Count, $"Field updates should be empty due to no changes..");
        }