Exemplo n.º 1
0
        public void TestClearExtensionTList()
        {
            TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, 0);
            Assert.AreEqual(1, builder.GetExtensionCount(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite));

            builder.ClearExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite);
            Assert.AreEqual(0, builder.GetExtensionCount(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite));
        }
Exemplo n.º 2
0
        public void TestClearFieldByDescriptor()
        {
            TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, 0);
            Assert.AreEqual(1, builder.GetExtensionCount(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite));

            IFieldDescriptorLite f = UnitTestLiteProtoFile.RepeatedInt32ExtensionLite.Descriptor;

            builder.ClearField(f);
            Assert.AreEqual(0, builder.GetExtensionCount(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite));
        }
        public void TestAddRepeatedFieldByDescriptor()
        {
            TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
                                                    .AddExtension(UnittestLite.RepeatedInt32ExtensionLite, 0);
            Assert.AreEqual(1, builder.GetExtensionCount(UnittestLite.RepeatedInt32ExtensionLite));

            IFieldDescriptorLite f = UnittestLite.RepeatedInt32ExtensionLite.Descriptor;

            builder.AddRepeatedField(f, 123);
            Assert.AreEqual(2, builder.GetExtensionCount(UnittestLite.RepeatedInt32ExtensionLite));
            Assert.AreEqual(123, builder.GetExtension(UnittestLite.RepeatedInt32ExtensionLite, 1));
        }
Exemplo n.º 4
0
        public void TestIndexedByDescriptorAndOrdinal()
        {
            TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, 0);
            Assert.AreEqual(1, builder.GetExtensionCount(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite));

            IFieldDescriptorLite f = UnitTestLiteProtoFile.RepeatedInt32ExtensionLite.Descriptor;

            builder[f, 0] = 123;

            Assert.AreEqual(1, builder.GetExtensionCount(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite));
            Assert.AreEqual(123, builder.GetExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, 0));
        }
Exemplo n.º 5
0
        public void TestGetExtensionCountT()
        {
            TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, 1)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, 2)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, 3);

            Assert.AreEqual(3, builder.GetExtensionCount(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite));
        }
        public void TestIndexedByDescriptorAndOrdinalOutOfRange()
        {
            TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder();
            Assert.AreEqual(0, builder.GetExtensionCount(UnittestLite.RepeatedInt32ExtensionLite));

            IFieldDescriptorLite f = UnittestLite.RepeatedInt32ExtensionLite.Descriptor;

            Assert.Throws <ArgumentOutOfRangeException>(() => builder[f, 0] = 123);
        }
Exemplo n.º 7
0
 public void TestGetExtensionCountTEmpty()
 {
     TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder();
     Assert.AreEqual(0, builder.GetExtensionCount(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite));
 }