public void CodeGen_CustomAttrGen_AttributeType_NotShared() { ConsoleLogger logger = new ConsoleLogger(); // Create a shared type service that says the entity's attribute is "unshared" when asked whether it is shared MockSharedCodeService mockSts = new MockSharedCodeService( new Type[] { typeof(Mock_CG_Attr_Gen_Type) }, Array.Empty <MethodBase>(), Array.Empty <string>()); mockSts.AddUnsharedType(typeof(Mock_CG_Attr_Gen_TestAttribute)); string generatedCode = TestHelper.GenerateCode("C#", new Type[] { typeof(Mock_CG_Attr_Gen_DomainService) }, logger, mockSts); string expectedWarning = string.Format( CultureInfo.CurrentCulture, Resource.ClientCodeGen_Attribute_RequiresDataAnnotations, typeof(Mock_CG_Attr_Gen_TestAttribute), "MockProject"); TestHelper.AssertContainsWarnings(logger, expectedWarning); string warningComment = string.Format( CultureInfo.CurrentCulture, Resource.ClientCodeGen_Attribute_RequiresShared, typeof(Mock_CG_Attr_Gen_TestAttribute), "MockProject"); TestHelper.AssertGeneratedCodeContains(generatedCode, warningComment); }
public void CodeGen_CustomAttrGen_Attribute_References_Type_NotShared() { ConsoleLogger logger = new ConsoleLogger(); // Create a shared type service that says the entity's attribute is "shared" when asked whether it is shared MockSharedCodeService mockSts = new MockSharedCodeService( new Type[] { typeof(Mock_CG_Attr_Gen_TestAttribute) }, Array.Empty <MethodBase>(), Array.Empty <string>()); // Explicitly make the typeof() ref in the attribute say it is unshared mockSts.AddUnsharedType(typeof(Mock_CG_Attr_Gen_Type)); string generatedCode = TestHelper.GenerateCode("C#", new Type[] { typeof(Mock_CG_Attr_Gen_DomainService) }, logger, mockSts); TestHelper.AssertNoErrorsOrWarnings(logger); string warningComment = string.Format( CultureInfo.CurrentCulture, Resource.ClientCodeGen_Attribute_RequiresShared, typeof(Mock_CG_Attr_Gen_TestAttribute), "MockProject"); TestHelper.AssertGeneratedCodeContains(generatedCode, "[Mock_CG_Attr_Gen_Test(typeof(global::OpenRiaServices.DomainServices.Tools.Test.Mock_CG_Attr_Gen_Type))]"); }