예제 #1
0
        public void DeserializeMultipleAnnotatedIonToClassNameWithFirstAnnotated()
        {
            // Multiple annotations are ignored, it will only pick the first one.
            IIonValue ionTruck = valueFactory.NewEmptyStruct();

            ionTruck.AddTypeAnnotation("Amazon.IonObjectMapper.Test.Truck");
            ionTruck.AddTypeAnnotation("SecondAnnotation");

            IIonReader reader = IonReaderBuilder.Build(ionTruck);

            Vehicle truck = defaultSerializer.Deserialize <Vehicle>(reader);

            AssertIsTruck(truck);
        }
예제 #2
0
        public void DeserializeMultipleAnnotatedIonToClassNameWithSecondAnnotated()
        {
            // Multiple annotations are ignored, it will only pick the first one.
            IIonValue ionTruck = valueFactory.NewEmptyStruct();

            ionTruck.AddTypeAnnotation("FirstAnnotation");
            ionTruck.AddTypeAnnotation("Truck");

            IIonReader reader = IonReaderBuilder.Build(ionTruck);

            Vehicle truck = defaultSerializer.Deserialize <Vehicle>(reader);

            Assert.AreNotEqual(TestObjects.nativeTruck.ToString(), truck.ToString());
        }
예제 #3
0
        private static IIonValue FilterHashLog(IIonValue actualHashLog, IIonValue expectedHashLog)
        {
            HashSet <string>        methodCalls = new HashSet <string>();
            IEnumerator <IIonValue> enumerator  = expectedHashLog.GetEnumerator();

            while (enumerator.MoveNext())
            {
                IIonValue v = enumerator.Current;
                foreach (SymbolToken annotation in v.GetTypeAnnotationSymbols())
                {
                    methodCalls.Add(annotation.Text);
                }
            }

            IValueFactory valueFactory = new ValueFactory();
            IIonValue     result       = valueFactory.NewEmptySexp();

            if (methodCalls.Count == 1 && methodCalls.Contains("final_digest"))
            {
                IIonValue finalDigest = actualHashLog.GetElementAt(actualHashLog.Count - 1);
                finalDigest.ClearAnnotations();
                finalDigest.AddTypeAnnotation("final_digest");
                result.Add(finalDigest);
            }
            else
            {
                enumerator = actualHashLog.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    IIonValue v          = enumerator.Current;
                    String    methodCall = v.GetTypeAnnotationSymbols().ElementAt(0).Text;
                    if (methodCalls.Contains(methodCall))
                    {
                        result.Add(v);
                    }
                }
            }

            return(result);
        }