public void WriteEmptyEntityTypeWithBaseType() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(ModelHasInheritanceEdmx, namespacePrefix) { UseDataServiceCollection = true }; ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmEntityType entityType = Context.GetSchemaElements("Namespace1").OfType<IEdmEntityType>().Last(); template.WriteEntityType(entityType, boundOperationMap); List<string> expectedActions = new List<string> { "WriteSummaryCommentForStructuredType(EntityTypeSingle)", "WriteClassStartForStructuredType(, EntityTypeSingle, EntityTypeSingle, ClassInheritDataServiceQuerySingle)", "WriteConstructorForSingleType(EntityTypeSingle, DataServiceQuerySingle)", "WriteClassEndForStructuredType()", "WriteSummaryCommentForStructuredType(EntityType)", "WriteEntityTypeAttribute()", "WriteClassStartForStructuredType(, EntityType, EntityType, ClassInheritBaseEntityType)", "WriteClassEndForStructuredType()" }; template.CalledActions.Should().Equal(expectedActions); }
public void OnlyComplexTypeShouldCallWriteComplexType() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(OneNamespaceAndEmptyComplexTypeEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); template.WriteNamespace("Namespace1"); List<string> expectedActions = new List<string> { "WriteNamespaceStart(Namespace1)", "WriteSummaryCommentForStructuredType(ComplexType)", "WriteClassStartForStructuredType(, ComplexType, ComplexType, )", "WriteClassEndForStructuredType()", "WriteNamespaceEnd()" }; template.CalledActions.Should().Equal(expectedActions); }
public void OnlyEntityTypeShouldCallWriteEntityType() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(EmptyEntityTypeEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); template.WriteNamespace("Namespace1"); List<string> expectedActions = new List<string> { "WriteNamespaceStart(Namespace1)", "WriteSummaryCommentForStructuredType(EntityTypeSingle)", "WriteClassStartForStructuredType(, EntityTypeSingle, EntityTypeSingle, ClassInheritDataServiceQuerySingle)", "WriteConstructorForSingleType(EntityTypeSingle, DataServiceQuerySingle)", "WriteClassEndForStructuredType()", "WriteSummaryCommentForStructuredType(EntityType)", "WriteEntityTypeAttribute()", "WriteClassStartForStructuredType(AbstractModifier, EntityType, EntityType, global::Microsoft.OData.Client.BaseEntityType)", "WriteClassEndForStructuredType()", "WriteExtensionMethodsStart()", "WriteExtensionMethodsEnd()", "WriteNamespaceEnd()" }; template.CalledActions.Should().Equal(expectedActions); }
public void FixParameterNameShouldReadKeywords() { ODataClientTemplateImp template = new ODataClientTemplateImp(new ODataT4CodeGenerator.CodeGenerationContext(FullEdmx, null)); template.GetFixedName("bool").Should().Be("@bool"); }
public void TwoNamespacesShouldCallWriteNamespaceStartTwice() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(TwoNamespacesEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); template.WriteNamespaces(); // Verify WriteNamespaceStart representing WriteNamepsace template.CalledActions.FindAll(act => act.StartsWith("WriteNamespaceStart")).Count.Should().Be(2); }
public void WriteMembersForEnumTypeWithMembers() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(EnumTypeWithMembersEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmEnumType enumType = Context.GetSchemaElements("Namespace1").OfType<IEdmEnumType>().First(); template.WriteMembersForEnumType(enumType.Members); List<string> expectedActions = new List<string> { "WriteMemberForEnumType(Liquid = 0, Liquid, False)", "WriteMemberForEnumType(Perishable = 1, Perishable, True)" }; template.CalledActions.Should().Equal(expectedActions); }
public void WriteDupNamesWithCamelCase() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(DupNamesEdmx, namespacePrefix); Context.EnableNamingAlias = true; ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmComplexType complexType = Context.GetSchemaElements("Namespace1").OfType<IEdmComplexType>().First(); template.SetPropertyIdentifierMappingsIfNameConflicts(complexType.Name, complexType); template.WritePropertiesForStructuredType(complexType.DeclaredProperties); List<string> expectedActions = new List<string> { "WritePropertyForStructuredType(String, Name, Name2, Name2, _Name21, , False)", "WritePropertyForStructuredType(String, name, Name3, Name3, _Name3, , False)", "WritePropertyForStructuredType(String, Name1, Name1, Name1, _Name1, , False)", "WritePropertyForStructuredType(String, _Name2, _Name2, _Name2, __Name2, , False)", }; template.CalledActions.Should().Contain(expectedActions); }
public void WriteAbstractModifier() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(AbstractComplexTypeEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmComplexType complexType = Context.GetSchemaElements("Namespace1").OfType<IEdmComplexType>().First(); template.WriteStructurdTypeDeclaration(complexType, string.Empty); List<string> expectedActions = new List<string> { "WriteClassStartForStructuredType(AbstractModifier, ComplexType, ComplexType, )" }; template.CalledActions.Should().Equal(expectedActions); }
public void WriteNoBaseTypeStructuredTypeWithUseDataServiceCollection() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(OneNamespaceAndEmptyComplexTypeEdmx, namespacePrefix) { UseDataServiceCollection = true }; ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmComplexType complexType = Context.GetSchemaElements("Namespace1").OfType<IEdmComplexType>().First(); template.WriteStructurdTypeDeclaration(complexType, string.Empty); List<string> expectedActions = new List<string> { "WriteClassStartForStructuredType(, ComplexType, ComplexType, ClassInheritNotifyPropertyChanged)" }; template.CalledActions.Should().Equal(expectedActions); }
public void WriteEnumTypeWithUnderlyingTypeNotInt32() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(EnumTypeWithUnderlyingTypeNotInt32Edmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmEnumType enumType = Context.GetSchemaElements("Namespace1").OfType<IEdmEnumType>().First(); template.WriteEnumType(enumType); List<string> expectedActions = new List<string> { "WriteSummaryCommentForEnumType(EnumType)", "WriteEnumDeclaration(EnumType, EnumType, : String)", "WriteEnumEnd()" }; template.CalledActions.Should().Equal(expectedActions); }
public void WriteEnumTypeWithMembers() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(EnumTypeWithMemberEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmEnumType enumType = Context.GetSchemaElements("Namespace1").OfType<IEdmEnumType>().First(); template.WriteEnumType(enumType); List<string> expectedActions = new List<string> { "WriteSummaryCommentForEnumType(ContentType)", "WriteEnumFlags()", "WriteEnumDeclaration(ContentType, ContentType, )", "WriteMemberForEnumType(Liquid = 0, Liquid, True)", "WriteEnumEnd()" }; template.CalledActions.Should().Equal(expectedActions); }
public void WriteComplexTypeWithBaseType() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(ComplexTypeWithBaseType, namespacePrefix) { UseDataServiceCollection = true }; ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmComplexType complexType = Context.GetSchemaElements("Namespace1").OfType<IEdmComplexType>().Last(); template.WriteComplexType(complexType, boundOperationMap); List<string> expectedActions = new List<string> { "WriteSummaryCommentForStructuredType(ComplexType)", "WriteClassStartForStructuredType(, ComplexType, ComplexType, ClassInheritBaseComplexType)", "WriteClassEndForStructuredType()" }; template.CalledActions.Should().Equal(expectedActions); }
public void WriteEntityTypeForOneEntitySetInEntityContainer() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(OneSingleEntitySet, namespacePrefix) { UseDataServiceCollection = true }; ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEnumerable<IEdmEntitySet> entitySets = Context.GetSchemaElements("Namespace1").OfType<IEdmEntityContainer>().First().EntitySets(); IEdmEntityType entityType = Context.GetSchemaElements("Namespace1").OfType<IEdmEntityType>().First(); foreach (var edmEntitySet in entitySets) { List<IEdmNavigationSource> navigationSourceList = null; if (!Context.ElementTypeToNavigationSourceMap.TryGetValue(edmEntitySet.EntityType(), out navigationSourceList)) { navigationSourceList = new List<IEdmNavigationSource>(); Context.ElementTypeToNavigationSourceMap.Add(edmEntitySet.EntityType(), navigationSourceList); } navigationSourceList.Add(edmEntitySet); } template.WriteEntityType(entityType, boundOperationMap); List<string> expectedActions = new List<string> { "WriteSummaryCommentForStructuredType(CustomerSingle)", "WriteClassStartForStructuredType(, CustomerSingle, CustomerSingle, ClassInheritDataServiceQuerySingle)", "WriteConstructorForSingleType(CustomerSingle, DataServiceQuerySingle)", "WriteClassEndForStructuredType()", "WriteSummaryCommentForStructuredType(Customer)", "WriteKeyPropertiesCommentAndAttribute(PersonId)", "WriteEntitySetAttribute(CustomerSet1)", "WriteClassStartForStructuredType(, Customer, Customer, global::Microsoft.OData.Client.BaseEntityType, NotifyPropertyChanged)", "WriteSummaryCommentForStaticCreateMethod(Customer)", "WriteParameterCommentForStaticCreateMethod(personId, PersonId)", "WriteDeclarationStartForStaticCreateMethod(Customer, Customer)", "WriteParameterForStaticCreateMethod(Int32, personId, )", "WriteDeclarationEndForStaticCreateMethod(Customer, customer)", "WritePropertyValueAssignmentForStaticCreateMethod(customer, PersonId, personId)", "WriteMethodEndForStaticCreateMethod(customer)", "WritePropertyForStructuredType(Int32, PersonId, PersonId, PersonId, _PersonId, , True)", "WriteINotifyPropertyChangedImplementation()", "WriteClassEndForStructuredType()" }; template.CalledActions.Should().Equal(expectedActions); }
public void WriteEntityTypeWithProperty() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(EntityTypeWithPropertyEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmEntityType entityType = Context.GetSchemaElements("Namespace1").OfType<IEdmEntityType>().First(); template.WriteEntityType(entityType, boundOperationMap); List<string> expectedActions = new List<string> { "WriteSummaryCommentForStructuredType(EntityTypeSingle)", "WriteClassStartForStructuredType(, EntityTypeSingle, EntityTypeSingle, ClassInheritDataServiceQuerySingle)", "WriteConstructorForSingleType(EntityTypeSingle, DataServiceQuerySingle)", "WriteClassEndForStructuredType()", "WriteSummaryCommentForStructuredType(EntityType)", "WriteKeyPropertiesCommentAndAttribute(Id)", "WriteClassStartForStructuredType(, EntityType, EntityType, global::Microsoft.OData.Client.BaseEntityType)", "WriteSummaryCommentForStaticCreateMethod(EntityType)", "WriteParameterCommentForStaticCreateMethod(ID, Id)", "WriteDeclarationStartForStaticCreateMethod(EntityType, EntityType)", "WriteParameterForStaticCreateMethod(Guid, ID, )", "WriteDeclarationEndForStaticCreateMethod(EntityType, entityType)", "WritePropertyValueAssignmentForStaticCreateMethod(entityType, Id, ID)", "WriteMethodEndForStaticCreateMethod(entityType)", "WritePropertyForStructuredType(Guid, Id, Id, Id, _Id, , False)", "WriteClassEndForStructuredType()" }; template.CalledActions.Should().Equal(expectedActions); }
public void WritePropertiesForStructuredTypeWithPropertyAndUseDataServiceCollection() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(ComplexTypeWithPropertyEdmx, namespacePrefix) { UseDataServiceCollection = true }; ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmComplexType complexType = Context.GetSchemaElements("Namespace1").OfType<IEdmComplexType>().First(); template.WritePropertiesForStructuredType(complexType.DeclaredProperties); List<string> expectedActions = new List<string> { "WritePropertyForStructuredType(String, Value, Value, Value, _Value, , True)" }; template.CalledActions.Should().Equal(expectedActions); }
public void WriteStructuredTypeWithSameNamespaceBaseType() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(ModelHasInheritanceEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmEntityType entityType = Context.GetSchemaElements("Namespace1").OfType<IEdmEntityType>().Last(); template.WriteStructurdTypeDeclaration(entityType, string.Empty); List<string> expectedActions = new List<string> { "WriteClassStartForStructuredType(, EntityType, EntityType, ClassInheritBaseEntityType)" }; template.CalledActions.Should().Equal(expectedActions); }
public void WriteMembersForEmptyEnumType() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(EmptyEnumTypeEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmEnumType enumType = Context.GetSchemaElements("Namespace1").OfType<IEdmEnumType>().First(); template.WriteMembersForEnumType(enumType.Members); template.CalledActions.Should().BeEmpty(); }
public void WriteStructuredTypeWithDifferentNamespaceBaseType() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(InheritedComplexTypeEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmComplexType complexType = Context.GetSchemaElements("Namespace1").OfType<IEdmComplexType>().First(); template.WriteStructurdTypeDeclaration(complexType, string.Empty); List<string> expectedActions = new List<string> { "WriteClassStartForStructuredType(, ComplexType, ComplexType, ClassInheritglobal::Namespace2.BaseComplexType)" }; template.CalledActions.Should().Equal(expectedActions); }
public void WritePrefixConfict() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(PrefixConflictEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmComplexType complexType = Context.GetSchemaElements("Namespace1").OfType<IEdmComplexType>().First(); template.WritePropertiesForStructuredType(complexType.DeclaredProperties); List<string> expectedActions = new List<string> { "WritePropertyForStructuredType(String, Name, Name, Name, _Name1, , False)", "WritePropertyForStructuredType(String, _Name, _Name, _Name, __Name1, , False)", "WritePropertyForStructuredType(String, __Name, __Name, __Name, ___Name, , False)" }; template.CalledActions.Should().Equal(expectedActions); }
public void WriteStaticCreateMethodForStructuredTypeWithProperties() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(ComplexTypeWithPropertiesEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmComplexType complexType = Context.GetSchemaElements("Namespace1").OfType<IEdmComplexType>().First(); template.WriteTypeStaticCreateMethod("ComplexType", complexType); List<string> expectedActions = new List<string> { "WriteSummaryCommentForStaticCreateMethod(ComplexType)", "WriteParameterCommentForStaticCreateMethod(name, Name)", "WriteParameterCommentForStaticCreateMethod(value, Value)", "WriteDeclarationStartForStaticCreateMethod(ComplexType, ComplexType)", "WriteParameterForStaticCreateMethod(String, name, , )", "WriteParameterForStaticCreateMethod(String, value, )", "WriteDeclarationEndForStaticCreateMethod(ComplexType, complexType)", "WritePropertyValueAssignmentForStaticCreateMethod(complexType, Name, name)", "WritePropertyValueAssignmentForStaticCreateMethod(complexType, Value, value)", "WriteMethodEndForStaticCreateMethod(complexType)" }; template.CalledActions.Should().Equal(expectedActions); }
public void GetFixedNameShouldReadNonKeywords() { ODataClientTemplateImp template = new ODataClientTemplateImp(new ODataT4CodeGenerator.CodeGenerationContext(FullEdmx, null)); template.GetFixedName("Name").Should().Be("Name"); }
public void WriteStaticCreateMethodForStructuredTypeWithCollectionProperty() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(ComplexTypeWithCollectionPropertyEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmComplexType complexType = Context.GetSchemaElements("Namespace1").OfType<IEdmComplexType>().First(); template.WriteTypeStaticCreateMethod("ComplexType", complexType); template.CalledActions.Should().BeEmpty(); }
public void OnlyOneNamespaceShouldCallWriteNamespaceStartJustOnce() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(OneNamespaceAndEmptyComplexTypeEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); template.WriteNamespaces(); // Verify WriteNamespaceStart to representing WriteNamepsace template.CalledActions.FindAll(act => act == "WriteNamespaceStart(Namespace1)").Count.Should().Be(1); }
public void WriteStaticCreateMethodParametersForEmptyStructuredType() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(OneNamespaceAndEmptyComplexTypeEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmComplexType complexType = Context.GetSchemaElements("Namespace1").OfType<IEdmComplexType>().First(); KeyValuePair<IEdmProperty, string>[] propertyToParameterNamePairs = complexType.Properties().Select(p => new KeyValuePair<IEdmProperty, string>(p, p.Name)).ToArray(); template.WriteStaticCreateMethodParameters(propertyToParameterNamePairs); template.CalledActions.Should().BeEmpty(); }
public void OnlyEntityContainerShouldCallWriteEntityContainer() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(EmptyEntityContainerEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); template.WriteNamespace("Namespace1"); List<string> expectedActions = new List<string> { "WriteNamespaceStart(Namespace1)", "WriteClassStartForEntityContainer(EntityContainer, EntityContainer, EntityContainer)", "WriteMethodStartForEntityContainerConstructor(EntityContainer, EntityContainer)", "WriteClassEndForEntityContainerConstructor()", "WriteGeneratedEdmModel(<edmx:Edmx Version=\"\"4.0\"\" xmlns:edmx=\"\"http://docs.oasis-open.org/odata/ns/edmx\"\">\r\n <edmx:DataServices>\r\n <Schema Namespace=\"\"Namespace1\"\" xmlns=\"\"http://docs.oasis-open.org/odata/ns/edm\"\">\r\n <EntityContainer Name=\"\"EntityContainer\"\" />\r\n </Schema>\r\n </edmx:DataServices>\r\n</edmx:Edmx>)", "WriteClassEndForEntityContainer()", "WriteNamespaceEnd()", }; template.CalledActions.Should().Equal(expectedActions); }
public void WriteStaticCreateMethodParametersForStructuredTypeWithMoreThan5Properties() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(ComplexTypeWithMorethan5PropertiesEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmComplexType complexType = Context.GetSchemaElements("Namespace1").OfType<IEdmComplexType>().First(); KeyValuePair<IEdmProperty, string>[] propertyToParameterNamePairs = complexType.Properties().Select(p => new KeyValuePair<IEdmProperty, string>(p, p.Name)).ToArray(); template.WriteStaticCreateMethodParameters(propertyToParameterNamePairs); List<string> expectedActions = new List<string> { "WriteParameterForStaticCreateMethod(Int32, Id, ParameterSeparator)", "WriteParameterForStaticCreateMethod(String, FirstName, ParameterSeparator)", "WriteParameterForStaticCreateMethod(String, MiddleName, ParameterSeparator)", "WriteParameterForStaticCreateMethod(String, LastName, ParameterSeparator)", "WriteParameterForStaticCreateMethod(Int32, Age, ParameterSeparator)", "WriteParameterForStaticCreateMethod(String, Gender, )" }; template.CalledActions.Should().Equal(expectedActions); }
public void OnlyEnumTypeShouldCallWriteEnumType() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(EmptyEnumTypeEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); template.WriteNamespace("Namespace1"); List<string> expectedActions = new List<string> { "WriteNamespaceStart(Namespace1)", "WriteSummaryCommentForEnumType(EnumType)", "WriteEnumDeclaration(EnumType, EnumType, )", "WriteEnumEnd()", "WriteNamespaceEnd()" }; template.CalledActions.Should().Equal(expectedActions); }
public void WritePropertiesForEmptyStructuredType() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(OneNamespaceAndEmptyComplexTypeEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEdmComplexType complexType = Context.GetSchemaElements("Namespace1").OfType<IEdmComplexType>().First(); template.WritePropertiesForStructuredType(complexType.DeclaredProperties); template.CalledActions.Should().BeEmpty(); }
public void SimpleEdmxShouldCallMethodsInOrder() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(SimpleEdmx, namespacePrefix); ODataClientTemplateImp template = new ODataClientTemplateImp(Context); template.WriteNamespace("Namespace1"); List<string> expectedActions = new List<string> { "WriteNamespaceStart(Namespace1)", "WriteClassStartForEntityContainer(EntityContainer, EntityContainer, EntityContainer)", "WriteMethodStartForEntityContainerConstructor(EntityContainer, EntityContainer)", "WriteClassEndForEntityContainerConstructor()", "WriteGeneratedEdmModel(<edmx:Edmx Version=\"\"4.0\"\" xmlns:edmx=\"\"http://docs.oasis-open.org/odata/ns/edmx\"\">\r\n <edmx:DataServices>\r\n <Schema Namespace=\"\"Namespace1\"\" xmlns=\"\"http://docs.oasis-open.org/odata/ns/edm\"\">\r\n <ComplexType Name=\"\"ComplexType\"\" />\r\n <EnumType Name=\"\"EnumType\"\" />\r\n <EntityType Name=\"\"EntityType\"\" Abstract=\"\"true\"\" />\r\n <EntityContainer Name=\"\"EntityContainer\"\" />\r\n </Schema>\r\n </edmx:DataServices>\r\n</edmx:Edmx>)", "WriteClassEndForEntityContainer()", "WriteSummaryCommentForStructuredType(ComplexType)", "WriteClassStartForStructuredType(, ComplexType, ComplexType, )", "WriteClassEndForStructuredType()", "WriteSummaryCommentForStructuredType(EntityTypeSingle)", "WriteClassStartForStructuredType(, EntityTypeSingle, EntityTypeSingle, ClassInheritDataServiceQuerySingle)", "WriteConstructorForSingleType(EntityTypeSingle, DataServiceQuerySingle)", "WriteClassEndForStructuredType()", "WriteSummaryCommentForStructuredType(EntityType)", "WriteEntityTypeAttribute()", "WriteClassStartForStructuredType(AbstractModifier, EntityType, EntityType, global::Microsoft.OData.Client.BaseEntityType)", "WriteClassEndForStructuredType()", "WriteSummaryCommentForEnumType(EnumType)", "WriteEnumDeclaration(EnumType, EnumType, )", "WriteEnumEnd()", "WriteExtensionMethodsStart()", "WriteExtensionMethodsEnd()", "WriteNamespaceEnd()" }; template.CalledActions.Should().Equal(expectedActions); }
public void WriteEmptyEntityTypeWithUseDataServiceCollectionAndEntitySet() { string namespacePrefix = string.Empty; Context = new ODataT4CodeGenerator.CodeGenerationContext(BasicEntityContainerEdmx, namespacePrefix) { UseDataServiceCollection = true }; ODataClientTemplateImp template = new ODataClientTemplateImp(Context); IEnumerable<IEdmEntitySet> entitySets = Context.GetSchemaElements("Namespace1").OfType<IEdmEntityContainer>().First().EntitySets(); IEdmEntityType entityType = Context.GetSchemaElements("Namespace1").OfType<IEdmEntityType>().First(); foreach (var edmEntitySet in entitySets) { List<IEdmNavigationSource> navigationSourceList = null; if (!Context.ElementTypeToNavigationSourceMap.TryGetValue(edmEntitySet.EntityType(), out navigationSourceList)) { navigationSourceList = new List<IEdmNavigationSource>(); Context.ElementTypeToNavigationSourceMap.Add(edmEntitySet.EntityType(), navigationSourceList); } navigationSourceList.Add(edmEntitySet); } template.WriteEntityType(entityType, boundOperationMap); List<string> expectedActions = new List<string> { "WriteSummaryCommentForStructuredType(EntityTypeSingle)", "WriteClassStartForStructuredType(, EntityTypeSingle, EntityTypeSingle, ClassInheritDataServiceQuerySingle)", "WriteConstructorForSingleType(EntityTypeSingle, DataServiceQuerySingle)", "WriteClassEndForStructuredType()", "WriteSummaryCommentForStructuredType(EntityType)", "WriteEntityTypeAttribute()", "WriteEntitySetAttribute(Set1)", "WriteClassStartForStructuredType(, EntityType, EntityType, global::Microsoft.OData.Client.BaseEntityType, NotifyPropertyChanged)", "WriteINotifyPropertyChangedImplementation()", "WriteClassEndForStructuredType()" }; template.CalledActions.Should().Equal(expectedActions); }