Пример #1
0
        public void Test_SubGridTreeBitmapSubGridBitsTests_Equality()
        {
            SubGridTreeBitmapSubGridBits bits  = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled);
            SubGridTreeBitmapSubGridBits bits2 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled);
            SubGridTreeBitmapSubGridBits bits3 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled);

            Assert.True(bits.Equals(bits2), "Bits does not equal bits2, which it should");
            Assert.False(bits.Equals(bits3), "Bits equals bits3, which it should not");
            Assert.False(bits.Equals(null), "Bits equals null, which it should not");
        }
Пример #2
0
        public void Test_SubGridTreeBitmapSubGridBitsTests_Assignment()
        {
            SubGridTreeBitmapSubGridBits bits  = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled);
            SubGridTreeBitmapSubGridBits bits2 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled);
            SubGridTreeBitmapSubGridBits bits3 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled);

            Assert.True(bits.Equals(bits2), "Bits does not equal bits2, which it should");
            Assert.False(bits.Equals(bits3), "Bits equals bits3, which it should not");

            bits2.Assign(bits3);
            Assert.True(bits2.Equals(bits3), "Bits2 does not equal bits3 after assignment of bits3 to bits2, which it should");
        }
Пример #3
0
        public void Test_SubGridTreeBitmapSubGridBitsTests_Serialisation_Arbitrary()
        {
            // Test serialisation with arbitrary bits set
            SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled);

            bits.SetBit(0, 0);
            bits.SetBit(10, 10);
            bits.SetBit(20, 20);
            bits.SetBit(31, 31);

            MemoryStream ms = new MemoryStream(Consts.TREX_DEFAULT_MEMORY_STREAM_CAPACITY_ON_CREATION);
            BinaryWriter bw = new BinaryWriter(ms, Encoding.UTF8, true);

            bits.Write(bw);
            BinaryReader br = new BinaryReader(ms, Encoding.UTF8, true);

            ms.Position = 0;

            SubGridTreeBitmapSubGridBits bits2 = SubGridTreeBitmapSubGridBits.FullMask;

            bits2.Read(br);

            Assert.True(bits.Equals(bits2), "Bits not equal after serialisation with arbitrary mask");
            Assert.Equal(4, bits.CountBits());
        }
Пример #4
0
        public void Test_SubGridTreeBitmapSubGridBitsTests_Serialisation_Empty()
        {
            // Test serialisation with full mask
            SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled);

            MemoryStream ms = new MemoryStream(Consts.TREX_DEFAULT_MEMORY_STREAM_CAPACITY_ON_CREATION);
            BinaryWriter bw = new BinaryWriter(ms, Encoding.UTF8, true);

            bits.Write(bw);
            BinaryReader br = new BinaryReader(ms, Encoding.UTF8, true);

            ms.Position = 0;

            SubGridTreeBitmapSubGridBits bits2 = SubGridTreeBitmapSubGridBits.FullMask;

            bits2.Read(br);

            Assert.True(bits.Equals(bits2), "Bits not equal after serialisation with empty mask");
        }