public void CodeGen_SharedEntity_EntityShapingWithIncludeAndExclude_Succeeds() { Type[] domainServices = new Type[] { typeof(SharedScenarios_IncludeExcludeShaping_ExposeBDomainService), typeof(SharedScenarios_IncludeExcludeShaping_ExposeBAndCDomainService), }; // Generated classes for A, B, and C exist // Generated property getter for A and C exists // Generated enumerables for B and C exist string[] codeContains = new string[] { "public sealed partial class SharedScenarios_LeafEntityA : Entity", "public sealed partial class SharedScenarios_LeafEntityB : Entity", "public sealed partial class SharedScenarios_LeafEntityC : Entity", "public SharedScenarios_LeafEntityA A", "public SharedScenarios_LeafEntityC C", "public EntitySet<SharedScenarios_LeafEntityB> SharedScenarios_LeafEntityBs", "public EntitySet<SharedScenarios_LeafEntityC> SharedScenarios_LeafEntityCs", }; // Generated property getter for B does not exist // Generated enumerable fo A does not exist // D does not exist string[] codeNotContains = new string[] { "public SharedScenarios_LeafEntityB B", "public EntitySet<SharedScenarios_LeafEntityA> SharedScenarios_LeafEntityAs", "SharedScenarios_LeafEntityD", }; CodeGenHelper.BaseSuccessTest(domainServices, codeContains, codeNotContains); }
public void CodeGen_SharedEntity_TwoNamedUpdateMethods_Succeeds() { Type[] domainServices = new Type[] { typeof(SharedScenarios_NamedUpdate_ExposeNamedUpdate1DomainService), typeof(SharedScenarios_NamedUpdate_ExposeNamedUpdate2DomainService), }; // Named update methods, other methods and guard properties exist for both methods string[] codeContains = new string[] { "base.InvokeAction(\"ChangeA1\", intProp);", "base.InvokeAction(\"ChangeA2\", boolProp);", "OnChangeA1Invoking", "OnChangeA2Invoking", "OnChangeA1Invoked", "OnChangeA2Invoked", "IsChangeA1Invoked", "IsChangeA2Invoked", "CanChangeA1", "CanChangeA2", }; CodeGenHelper.BaseSuccessTest(domainServices, codeContains, null); }
public void CodeGen_SharedEntity_EntityShapingByThreeDomainServices_Succeeds() { Type[] domainServices = new Type[] { typeof(SharedScenarios_EntityShaping_ExposeADomainService), typeof(SharedScenarios_EntityShaping_ExposeBDomainService), typeof(SharedScenarios_EntityShaping_ExposeCDomainService), }; // Generated property getter, classes, and enumerables for A, B and C exists string[] codeContains = new string[] { "public sealed partial class SharedScenarios_LeafEntityA : Entity", "public sealed partial class SharedScenarios_LeafEntityB : Entity", "public sealed partial class SharedScenarios_LeafEntityC : Entity", "public SharedScenarios_LeafEntityA A", "public SharedScenarios_LeafEntityB B", "public SharedScenarios_LeafEntityC C", "public EntitySet<SharedScenarios_LeafEntityA> SharedScenarios_LeafEntityAs", "public EntitySet<SharedScenarios_LeafEntityB> SharedScenarios_LeafEntityBs", "public EntitySet<SharedScenarios_LeafEntityC> SharedScenarios_LeafEntityCs", }; // D does not exist string[] codeNotContains = new string[] { "SharedScenarios_LeafEntityD", }; CodeGenHelper.BaseSuccessTest(domainServices, codeContains, codeNotContains); }
public void CodeGen_SharedEntity_EntityShapingWithComposition_Succeeds() { Type[] domainServices = new Type[] { typeof(SharedScenarios_CompositionShaping_ExposeBDomainService1), typeof(SharedScenarios_CompositionShaping_ExposeBDomainService2), }; // Generated class and property getter for B exists string[] codeContains = new string[] { "public sealed partial class SharedScenarios_LeafEntityB : Entity", "public SharedScenarios_LeafEntityB B", }; // Generated enumerable for B does not exist // A does not exist string[] codeNotContains = new string[] { "public EntitySet<SharedScenarios_LeafEntityB> SharedScenarios_LeafEntityBs", "SharedScenarios_LeafEntityA", }; CodeGenHelper.BaseSuccessTest(domainServices, codeContains, codeNotContains); }
public void CodeGen_SharedEntity_EntityShapingWithEvenInheritance_Succeeds() { Type[] domainServices = new Type[] { typeof(SharedScenarios_InheritanceShaping_ExposeXDomainService), typeof(SharedScenarios_InheritanceShaping_ExposeX2DomainService), }; // Generated classes and enumerables for X and Z exist // Z inherits from X directly string[] codeContains = new string[] { "public partial class SharedScenarios_InheritanceShaping_X : Entity", "public sealed partial class SharedScenarios_InheritanceShaping_Z : SharedScenarios_InheritanceShaping_X", "public EntitySet<SharedScenarios_InheritanceShaping_X> SharedScenarios_InheritanceShaping_Xes", }; // Z's entity set does not exist // Y does not exist string[] codeNotContains = new string[] { "EntitySet<SharedScenarios_InheritanceShaping_Z>", "SharedScenarios_InheritanceShaping_Y", }; CodeGenHelper.BaseSuccessTest(domainServices, codeContains, codeNotContains); }
public void CodeGenComplexTypes_ValidInvokeMethodSignature_Succeeds() { Type[] domainServices = new Type[] { typeof(ComplexTypes_TestService_ComplexMethodSignatures), }; string[] codeContains = new string[] { // named updates on the entity "public void CustomUpdateHomeAddress(Address newAddress)", "public void UpdateHomeAddress(Address newAddress)", // named updates on the domain context "public void CustomUpdateHomeAddress(ComplexType_Parent parent, Address newAddress)", "public void UpdateHomeAddress(ComplexType_Parent parent, Address newAddress)", // invokes "public InvokeOperation AppendMoreAddresses(IEnumerable<Address> addresses, Action<InvokeOperation> callback, object userState)", "public InvokeOperation AppendMoreAddresses(IEnumerable<Address> addresses)", "public InvokeOperation Bar(IEnumerable<Address> addresses, Action<InvokeOperation> callback, object userState)", "public InvokeOperation Bar(IEnumerable<Address> addresses)", "public InvokeOperation<IEnumerable<Address>> Foo(ContactInfo contact, Action<InvokeOperation<IEnumerable<Address>>> callback, object userState)", "public InvokeOperation<IEnumerable<Address>> Foo(ContactInfo contact)", "public InvokeOperation<IEnumerable<Phone>> GetAllPhoneNumbers(ContactInfo contact, Action<InvokeOperation<IEnumerable<Phone>>> callback, object userState)", "public InvokeOperation<IEnumerable<Phone>> GetAllPhoneNumbers(ContactInfo contact)", }; CodeGenHelper.BaseSuccessTest(domainServices, codeContains, null); }
public void CodeGenComplexTypes_ComplexTypes_Have_DataMember_And_Display() { // Case 1: Only entity exposes complex type property Type[] domainServices = new Type[] { typeof(CodeGenComplexTypes_Attributes_OnEntity), }; string[] codeContains = new string[] { @"[DataMember()] [Display(AutoGenerateField=false)] public CodeGenComplexTypes_Attributes_ComplexType ComplexType", @"[DataMember()] [Display(AutoGenerateField=false)] public IEnumerable<CodeGenComplexTypes_Attributes_ComplexType> ComplexTypes", }; CodeGenHelper.BaseSuccessTest(domainServices, codeContains, null); // Case 2: Only complex type exposes complex type property domainServices = new Type[] { typeof(CodeGenComplexTypes_Attributes_OnComplexType), }; CodeGenHelper.BaseSuccessTest(domainServices, codeContains, null); }
public void CodeGenComplexTypes_ComplexTypes_Roundtrip_Propagation() { Type[] domainServices = new Type[] { typeof(ComplexCodeGen_RTO), }; string[] codeContains = new string[] { // Entity itself has RTO @"[RoundtripOriginal()] public sealed partial class ComplexCodeGen_RTO_Entity : Entity", // Full members have RTO @"[RoundtripOriginal()] public int FullMember", @"[RoundtripOriginal()] public ComplexCodeGen_RTO_On_Type_And_Members FullTMMember", // TM has RTO on the type itself @"[RoundtripOriginal()] public sealed partial class ComplexCodeGen_RTO_On_Type_And_Members", }; string[] codeNotContains = new string[] { // Entity CT member skips RTO. @"[RoundtripOriginal()] public ComplexCodeGen_RTO_CT_Full_RTO EntityFullMember", // Full does not have type property @"[RoundtripOriginal()] public sealed partial class ComplexCodeGen_RTO_CT_Full_RTO", // TM members do not have RTO @"[RoundtripOriginal()] public int TMMember", @"[RoundtripOriginal()] public ComplexCodeGen_RTO_NoRTO TMNoMember", // None does not have type property @"[RoundtripOriginal()] public sealed partial class ComplexCodeGen_RTO_NoRTO", // None members do not have RTO @"[RoundtripOriginal()] public int NoMember", }; CodeGenHelper.BaseSuccessTest(domainServices, codeContains, codeNotContains); }
public void CodeGenComplexTypes_ComplexTypes_Are_Shared_By_DomainServices() { Type[] domainServices = new Type[] { typeof(ComplexCodeGen_SharedComplexTypes1), typeof(ComplexCodeGen_SharedComplexTypes2), }; string[] codeContains = new string[] { "public InvokeOperation Invoke1(ComplexCodeGen_SharedComplexType_SharedComplexTypes_CT complexType, Action<InvokeOperation> callback, object userState)", "public InvokeOperation Invoke1(ComplexCodeGen_SharedComplexType_SharedComplexTypes_CT complexType)", "public InvokeOperation Invoke2(ComplexCodeGen_SharedComplexType_SharedComplexTypes_CT complexType, Action<InvokeOperation> callback, object userState)", "public InvokeOperation Invoke2(ComplexCodeGen_SharedComplexType_SharedComplexTypes_CT complexType)", }; // compiling is enough validation that the type does not appear twice CodeGenHelper.BaseSuccessTest(domainServices, codeContains, null); }
public void CodeGenComplexTypes_ComplexTypes_Exclusion_Works() { Type[] domainServices = new Type[] { typeof(ComplexCodeGen_Exclude_ComplexType), }; string[] codeContains = new string[] { "public sealed partial class ComplexCodeGen_Exclude_CT : ComplexObject", "private ComplexCodeGen_Exclude_CT _excludeCT;", "public ComplexCodeGen_Exclude_CT ExcludeCT", }; string[] codeNotContains = new string[] { "ComplexCodeGen_CT_Excluded_Via_Property", }; CodeGenHelper.BaseSuccessTest(domainServices, codeContains, codeNotContains); }