Ejemplo n.º 1
0
        public void TestWriteObject()
        {
            // Test writing with the value to write being ignored being null.
            // ToString cases are tested to a degree with non-constant structs.
            var testProperties     = new TestFlagProperties();
            var mockPacketProperty = new MockPacketProperty(typeof(TestFlagProperties).GetProperty("TestProperty4"));
            var flagPacketProperty = new FlagPacketProperty(mockPacketProperty, null);
            var writtenProperties  = new Dictionary <string, object>();
            var bitWriter          = new BitWriter(new MemoryStream());

            flagPacketProperty.Write(testProperties, bitWriter, writtenProperties);
            Assert.IsFalse(mockPacketProperty.DataWritten);
            testProperties.TestProperty4 = new TestFlagProperties();
            flagPacketProperty.Write(testProperties, bitWriter, writtenProperties);
            Assert.IsTrue(mockPacketProperty.DataWritten);
        }
Ejemplo n.º 2
0
        public void TestWriteEnum()
        {
            // Test writing with the value to write being ignored being null.
            var testProperties     = new TestFlagProperties();
            var mockPacketProperty = new MockPacketProperty(typeof(TestFlagProperties).GetProperty("TestProperty3"));
            var flagPacketProperty = new FlagPacketProperty(mockPacketProperty, null);
            var writtenProperties  = new Dictionary <string, object>();
            var bitWriter          = new BitWriter(new MemoryStream());

            flagPacketProperty.Write(testProperties, bitWriter, writtenProperties);
            Assert.IsFalse(mockPacketProperty.DataWritten);
            testProperties.TestProperty3 = TestFlagEnum.TestValue3;
            flagPacketProperty.Write(testProperties, bitWriter, writtenProperties);
            Assert.IsTrue(mockPacketProperty.DataWritten);
            mockPacketProperty.DataWritten = false;

            // Test writing with the value to write being ignored being defined.
            flagPacketProperty = new FlagPacketProperty(mockPacketProperty, TestFlagEnum.TestValue3);
            flagPacketProperty.Write(testProperties, bitWriter, writtenProperties);
            Assert.IsFalse(mockPacketProperty.DataWritten);
            testProperties.TestProperty3 = TestFlagEnum.TestValue2;
            flagPacketProperty.Write(testProperties, bitWriter, writtenProperties);
            Assert.IsTrue(mockPacketProperty.DataWritten);
        }
Ejemplo n.º 3
0
        public void TestWriteNonConstantProperty()
        {
            // Test writing with the value to write being ignored being null.
            var testProperties     = new TestFlagProperties();
            var mockPacketProperty = new MockPacketProperty(typeof(TestFlagProperties).GetProperty("TestProperty2"));
            var flagPacketProperty = new FlagPacketProperty(mockPacketProperty, null);
            var writtenProperties  = new Dictionary <string, object>();
            var bitWriter          = new BitWriter(new MemoryStream());

            flagPacketProperty.Write(testProperties, bitWriter, writtenProperties);
            Assert.IsFalse(mockPacketProperty.DataWritten);
            testProperties.TestProperty2 = new Vector3(2, 2, 2);
            flagPacketProperty.Write(testProperties, bitWriter, writtenProperties);
            Assert.IsTrue(mockPacketProperty.DataWritten);
            mockPacketProperty.DataWritten = false;

            // Test writing with the value to write being ignored being defined.
            flagPacketProperty = new FlagPacketProperty(mockPacketProperty, "<2, 2, 2>");
            flagPacketProperty.Write(testProperties, bitWriter, writtenProperties);
            Assert.IsFalse(mockPacketProperty.DataWritten);
            testProperties.TestProperty2 = new Vector3(3, 3, 3);
            flagPacketProperty.Write(testProperties, bitWriter, writtenProperties);
            Assert.IsTrue(mockPacketProperty.DataWritten);
        }