public void ReadResourceContentShouldSkipInstanceAnnotationsBasedOnReaderSettings() { var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"@odataa.unknown\":123,\"@custom.annotation\":456}", shouldReadAndValidateCustomInstanceAnnotations: false); AdvanceReaderToFirstProperty(deserializer.JsonReader); var entryState = new TestJsonLightReaderEntryState(); deserializer.ReadResourceContent(entryState); Assert.Equal(0, entryState.Resource.InstanceAnnotations.Count); }
public void ParsingInstanceAnnotationsInEntityPropertyShouldSkipBaseOnSettings() { var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"[email protected]\":true,\"[email protected]\":123,\"[email protected]\":\"annotation\",\"ID\":1}", shouldReadAndValidateCustomInstanceAnnotations: false); AdvanceReaderToFirstProperty(deserializer.JsonReader); var entryState = new TestJsonLightReaderEntryState(); deserializer.ReadResourceContent(entryState); entryState.Resource.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.ReadResourceContent(entryState); action.ShouldThrow <ODataException>(ErrorStrings.ODataJsonLightResourceDeserializer_PropertyWithoutValueWithWrongType("ID", "Edm.Int32")); }
public void ParsingInstanceAnnotationInEntityPropertyShouldReadEntity() { var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"[email protected]\":123,\"ID\":1}"); AdvanceReaderToFirstProperty(deserializer.JsonReader); var entryState = new TestJsonLightReaderEntryState(); deserializer.ReadResourceContent(entryState); entryState.Resource.Properties.First().InstanceAnnotations.Count.Should().Be(1); TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(123), entryState.Resource.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.Equal(1, entryState.Resource.InstanceAnnotations.Count); TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(123), entryState.Resource.InstanceAnnotations.Single(ia => ia.Name == "custom.Int32Annotation").Value); }
public void ReadResourceContentShouldReadAndApplyInstanceAnnotations() { var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"@odataa.unknown\":123,\"@custom.annotation\":456}"); AdvanceReaderToFirstProperty(deserializer.JsonReader); var entryState = new TestJsonLightReaderEntryState(); deserializer.ReadResourceContent(entryState); Assert.Equal(2, entryState.Resource.InstanceAnnotations.Count); TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(123), entryState.Resource.InstanceAnnotations.Single(ia => ia.Name == "odataa.unknown").Value); TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(456), entryState.Resource.InstanceAnnotations.Single(ia => ia.Name == "custom.annotation").Value); }
public void ParsingInstanceAnnotationsInEntityPropertyShouldReadEntity() { var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"[email protected]\":true,\"[email protected]\":123,\"[email protected]\":\"annotation\",\"ID\":1}", shouldReadAndValidateCustomInstanceAnnotations: true); AdvanceReaderToFirstProperty(deserializer.JsonReader); var entryState = new TestJsonLightReaderEntryState(); deserializer.ReadResourceContent(entryState); Assert.Equal(3, entryState.Resource.Properties.First().InstanceAnnotations.Count); TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(true), entryState.Resource.Properties.First().InstanceAnnotations.Single(ia => ia.Name == "Annotation.1").Value); TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(123), entryState.Resource.Properties.First().InstanceAnnotations.Single(ia => ia.Name == "Annotation.2").Value); TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue("annotation"), entryState.Resource.Properties.First().InstanceAnnotations.Single(ia => ia.Name == "Annotation.3").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.Equal(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.Equal(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.Equal(1, entryState.Entry.InstanceAnnotations.Count); TestUtils.AssertODataValueAreEqual(new ODataPrimitiveValue(123), entryState.Entry.InstanceAnnotations.Single(ia => ia.Name == "custom.Int32Annotation").Value); }