public void ParsingInstanceAnnotationsInEntityPropertyShouldSkipBaseOnSettings()
        {
            var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"[email protected]\":true,\"[email protected]\":123,\"[email protected]\":\"annotation\",\"ID\":1}", false);

            AdvanceReaderToFirstProperty(deserializer.JsonReader);
            var entryState = new TestJsonLightReaderEntryState();

            deserializer.ReadEntryContent(entryState);
            entryState.Entry.Properties.First().InstanceAnnotations.Count.Should().Be(0);
        }
        public void ParsingInstanceAnnotationInNonExistingEntityPropertyShouldThrow()
        {
            var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"[email protected]\":123}");

            AdvanceReaderToFirstProperty(deserializer.JsonReader);
            var    entryState = new TestJsonLightReaderEntryState();
            Action action     = () => deserializer.ReadEntryContent(entryState);

            action.ShouldThrow <ODataException>(ErrorStrings.ODataJsonLightEntryAndFeedDeserializer_PropertyWithoutValueWithWrongType("ID", "Edm.Int32"));
        }
        public void ReadEntryContentShouldSkipInstanceAnnotationsBasedOnReaderSettings()
        {
            var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"@odataa.unknown\":123,\"@custom.annotation\":456}", shouldReadAndValidateCustomInstanceAnnotations: false);

            AdvanceReaderToFirstProperty(deserializer.JsonReader);
            var entryState = new TestJsonLightReaderEntryState();

            deserializer.ReadEntryContent(entryState);
            Assert.AreEqual(0, entryState.Entry.InstanceAnnotations.Count);
        }
        public void ParsingInstanceAnnotationInEntityPropertyShouldReadEntity()
        {
            var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"[email protected]\":123,\"ID\":1}");

            AdvanceReaderToFirstProperty(deserializer.JsonReader);
            var entryState = new TestJsonLightReaderEntryState();

            deserializer.ReadEntryContent(entryState);
            entryState.Entry.Properties.First().InstanceAnnotations.Count.Should().Be(1);
            TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(123), entryState.Entry.Properties.First().InstanceAnnotations.Single(ia => ia.Name == "custom.annotation").Value);
        }
        public void ApplyEntryInstanceAnnotationShouldSetCustomInstanceAnnotationValue()
        {
            var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"@custom.Int32Annotation\":123}");

            AdvanceReaderToFirstPropertyValue(deserializer.JsonReader);
            var entryState = new TestJsonLightReaderEntryState();

            deserializer.ApplyEntryInstanceAnnotation(entryState, "custom.Int32Annotation", 123);
            Assert.AreEqual(1, entryState.Entry.InstanceAnnotations.Count);
            TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(123), entryState.Entry.InstanceAnnotations.Single(ia => ia.Name == "custom.Int32Annotation").Value);
        }
        public void ReadEntryContentShouldReadAndApplyInstanceAnnotations()
        {
            var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"@odataa.unknown\":123,\"@custom.annotation\":456}");

            AdvanceReaderToFirstProperty(deserializer.JsonReader);
            var entryState = new TestJsonLightReaderEntryState();

            deserializer.ReadEntryContent(entryState);
            Assert.AreEqual(2, entryState.Entry.InstanceAnnotations.Count);
            TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(123), entryState.Entry.InstanceAnnotations.Single(ia => ia.Name == "odataa.unknown").Value);
            TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(456), entryState.Entry.InstanceAnnotations.Single(ia => ia.Name == "custom.annotation").Value);
        }
 public void ParsingInstanceAnnotationsInEntityPropertyShouldSkipBaseOnSettings()
 {
     var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"[email protected]\":true,\"[email protected]\":123,\"[email protected]\":\"annotation\",\"ID\":1}", false);
     AdvanceReaderToFirstProperty(deserializer.JsonReader);
     var entryState = new TestJsonLightReaderEntryState();
     deserializer.ReadEntryContent(entryState);
     entryState.Entry.Properties.First().InstanceAnnotations.Count.Should().Be(0);
 }
 public void ParsingInstanceAnnotationsInEntityPropertyShouldReadEntity()
 {
     var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"[email protected]\":true,\"[email protected]\":123,\"[email protected]\":\"annotation\",\"ID\":1}");
     AdvanceReaderToFirstProperty(deserializer.JsonReader);
     var entryState = new TestJsonLightReaderEntryState();
     deserializer.ReadEntryContent(entryState);
     entryState.Entry.Properties.First().InstanceAnnotations.Count.Should().Be(3);
     TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(true), entryState.Entry.Properties.First().InstanceAnnotations.Single(ia => ia.Name == "Annotation.1").Value);
     TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(123), entryState.Entry.Properties.First().InstanceAnnotations.Single(ia => ia.Name == "Annotation.2").Value);
     TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue("annotation"), entryState.Entry.Properties.First().InstanceAnnotations.Single(ia => ia.Name == "Annotation.3").Value);
 }
 public void ParsingInstanceAnnotationInNonExistingEntityPropertyShouldThrow()
 {
     var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"[email protected]\":123}");
     AdvanceReaderToFirstProperty(deserializer.JsonReader);
     var entryState = new TestJsonLightReaderEntryState();
     Action action = () => deserializer.ReadEntryContent(entryState);
     action.ShouldThrow<ODataException>(ErrorStrings.ODataJsonLightEntryAndFeedDeserializer_PropertyWithoutValueWithWrongType("ID", "Edm.Int32"));
 }
 public void ReadEntryContentShouldSkipInstanceAnnotationsBasedOnReaderSettings()
 {
     var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"@odataa.unknown\":123,\"@custom.annotation\":456}", shouldReadAndValidateCustomInstanceAnnotations: false);
     AdvanceReaderToFirstProperty(deserializer.JsonReader);
     var entryState = new TestJsonLightReaderEntryState();
     deserializer.ReadEntryContent(entryState);
     Assert.AreEqual(0, entryState.Entry.InstanceAnnotations.Count);
 }
 public void ReadEntryContentShouldReadAndApplyInstanceAnnotations()
 {
     var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"@odataa.unknown\":123,\"@custom.annotation\":456}");
     AdvanceReaderToFirstProperty(deserializer.JsonReader);
     var entryState = new TestJsonLightReaderEntryState();
     deserializer.ReadEntryContent(entryState);
     Assert.AreEqual(2, entryState.Entry.InstanceAnnotations.Count);
     TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(123), entryState.Entry.InstanceAnnotations.Single(ia => ia.Name == "odataa.unknown").Value);
     TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(456), entryState.Entry.InstanceAnnotations.Single(ia => ia.Name == "custom.annotation").Value);
 }
 public void ApplyEntryInstanceAnnotationShouldSetCustomInstanceAnnotationValue()
 {
     var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"@custom.Int32Annotation\":123}");
     AdvanceReaderToFirstPropertyValue(deserializer.JsonReader);
     var entryState = new TestJsonLightReaderEntryState();
     deserializer.ApplyEntryInstanceAnnotation(entryState, "custom.Int32Annotation", 123);
     Assert.AreEqual(1, entryState.Entry.InstanceAnnotations.Count);
     TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(123), entryState.Entry.InstanceAnnotations.Single(ia => ia.Name == "custom.Int32Annotation").Value);
 }