private static void VerifyCustomParameter(CustomParameter parameter) { Assert.NotNull(parameter); Assert.NotNull(parameter.Name); Assert.Equal("odata-debug", parameter.Name); Assert.NotNull(parameter.Description); Assert.Equal("Debug support for OData services", parameter.Description); Assert.NotNull(parameter.DocumentationURL); Assert.Equal("https://debug.html", parameter.DocumentationURL); Assert.NotNull(parameter.Required); Assert.False(parameter.Required.Value); Assert.NotNull(parameter.ExampleValues); Assert.Equal(2, parameter.ExampleValues.Count); // #1 PrimitiveExampleValue value = parameter.ExampleValues[0]; Assert.Null(value.Description); Assert.NotNull(value.Value); Assert.Equal("html", value.Value.Value); // #2 value = parameter.ExampleValues[1]; Assert.Null(value.Description); Assert.NotNull(value.Value); Assert.Equal(new TimeOfDay(3, 4, 5, 6), value.Value.Value); }
private static void VerifyInsertRestrictions(InsertRestrictionsType insert) { Assert.NotNull(insert); Assert.NotNull(insert.Insertable); Assert.False(insert.Insertable.Value); Assert.NotNull(insert.NonInsertableNavigationProperties); Assert.Equal(2, insert.NonInsertableNavigationProperties.Count); Assert.Equal("abc|RelatedEvents", String.Join("|", insert.NonInsertableNavigationProperties)); Assert.True(insert.IsNonInsertableNavigationProperty("RelatedEvents")); Assert.False(insert.IsNonInsertableNavigationProperty("MyUnknownNavigationProperty")); Assert.Null(insert.QueryOptions); Assert.Null(insert.Permissions); Assert.Null(insert.CustomHeaders); Assert.NotNull(insert.MaxLevels); Assert.Equal(8, insert.MaxLevels.Value); Assert.NotNull(insert.CustomQueryOptions); CustomParameter parameter = Assert.Single(insert.CustomQueryOptions); Assert.Equal("primitive name", parameter.Name); Assert.Equal("http://any3", parameter.DocumentationURL); Assert.NotNull(parameter.ExampleValues); PrimitiveExampleValue example = Assert.Single(parameter.ExampleValues); Assert.Equal("example desc", example.Description); Assert.Equal("example value", example.Value.Value); }
public void PrimitiveExamplevalueInitializeWorksForPrimitiveData(string data, object except) { // Arrange string annotation = $@"<Annotation Term=""Org.OData.Core.V1.Example""> <Record Type=""Org.OData.Core.V1.PrimitiveExampleValue""> <PropertyValue Property=""Description"" String=""Primitive example value"" /> <PropertyValue Property=""Value"" {data} /> </Record> </Annotation>"; IEdmModel model = GetEdmModel(annotation); Assert.NotNull(model); // guard IEdmEntityType customer = model.SchemaElements.OfType <IEdmEntityType>().First(c => c.Name == "Customer"); Assert.NotNull(customer); // guard IEdmProperty dataProperty = customer.FindProperty("Data"); Assert.NotNull(dataProperty); // Act PrimitiveExampleValue value = model.GetRecord <PrimitiveExampleValue>(dataProperty, "Org.OData.Core.V1.Example"); // Assert Assert.NotNull(value); Assert.Equal("Primitive example value", value.Description); Assert.NotNull(value.Value); Assert.Equal(except, value.Value.Value); }
public void InitializeWithNullRecordThrows() { // Arrange & Act PrimitiveExampleValue value = new PrimitiveExampleValue(); // Assert Assert.Throws <ArgumentNullException>("record", () => value.Initialize(record: null)); }
public void DefaultPropertyAsNull() { // Arrange PrimitiveExampleValue value = new PrimitiveExampleValue(); // Act & Assert Assert.Null(value.Description); Assert.Null(value.Value); }
public void InitializeWithPrimitiveValueRecordSuccess() { // Arrange IEdmRecordExpression record = new EdmRecordExpression( new EdmPropertyConstructor("Description", new EdmStringConstant("HelloWorld!")), new EdmPropertyConstructor("Value", new EdmBooleanConstant(true))); PrimitiveExampleValue value = new PrimitiveExampleValue(); Assert.Null(value.Description); Assert.Null(value.Value); // Act value.Initialize(record); // Assert Assert.NotNull(value.Description); Assert.Equal("HelloWorld!", value.Description); Assert.NotNull(value.Value); Assert.NotNull(value.Value.Value); Assert.Equal(true, value.Value.Value); }