コード例 #1
0
        public void StructEquivalence_True()
        {
            var s1 = BuildFlatStruct(1, 10);
            var s2 = BuildFlatStruct(1, 10);

            Assert.IsTrue(s1.IsEquivalentTo(s2));

            //add fields with the same name
            s1.Add("new_field", new IonBool(true));
            s1.Add("new_field", new IonBool(true));
            s2.Add("new_field", new IonBool(true));
            s2.Add("new_field", new IonBool(true));
            Assert.IsTrue(s1.IsEquivalentTo(s2));

            var n1 = IonStruct.NewNull();
            var n2 = IonStruct.NewNull();

            Assert.IsTrue(n1.IsEquivalentTo(n2));
        }
コード例 #2
0
        public void StructEquivalence_False()
        {
            var s1 = BuildFlatStruct(1, 10);
            var s2 = BuildFlatStruct(1, 9);
            var n  = IonStruct.NewNull();

            Assert.IsFalse(s1.IsEquivalentTo(s2));
            Assert.IsFalse(s1.IsEquivalentTo(n));
            Assert.IsFalse(n.IsEquivalentTo(s1));
            s2["field10"] = new IonBool(true);
            Assert.IsFalse(s1.IsEquivalentTo(s2));

            s2.RemoveField("field10");
            s2["field10"] = new IonInt(10);
            Assert.IsTrue(s1.IsEquivalentTo(s2));

            //different field name
            s2.RemoveField("field10");
            s2["another"] = new IonInt(10);
            Assert.IsFalse(s1.IsEquivalentTo(s2));
        }
コード例 #3
0
 internal override IonContainer MakeNullValue()
 {
     return(IonStruct.NewNull());
 }
コード例 #4
0
ファイル: IonTreeWriter.cs プロジェクト: dhhoang/ion-dotnet
        public override void WriteNull(IonType type)
        {
            IonValue v;

            switch (type)
            {
            case IonType.Null:
                v = new IonNull();
                break;

            case IonType.Bool:
                v = IonBool.NewNull();
                break;

            case IonType.Int:
                v = IonInt.NewNull();
                break;

            case IonType.Float:
                v = IonFloat.NewNull();
                break;

            case IonType.Decimal:
                v = IonDecimal.NewNull();
                break;

            case IonType.Timestamp:
                v = IonTimestamp.NewNull();
                break;

            case IonType.Symbol:
                v = IonSymbol.NewNull();
                break;

            case IonType.String:
                v = new IonString(null);
                break;

            case IonType.Clob:
                v = IonClob.NewNull();
                break;

            case IonType.Blob:
                v = IonBlob.NewNull();
                break;

            case IonType.List:
                v = IonList.NewNull();
                break;

            case IonType.Sexp:
                v = IonSexp.NewNull();
                break;

            case IonType.Struct:
                v = IonStruct.NewNull();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            AppendValue(v);
        }
コード例 #5
0
 protected override IonContainer MakeNullValue()
 {
     return(IonStruct.NewNull());
 }