public void CodeGen_CustomAttrGen_AttributeType_Shared_Unknowable() { ConsoleLogger logger = new ConsoleLogger(); // Create a shared type service that says the entity's attribute is "unknowable" 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.AddUnknowableType(typeof(Mock_CG_Attr_Gen_TestAttribute)); 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_NoPDB, typeof(Mock_CG_Attr_Gen_TestAttribute), typeof(Mock_CG_Attr_Gen_TestAttribute).Assembly.GetName().Name, "MockProject"); // CodeDom injects comments after line breaks warningComment = warningComment.Replace("\r\n ", "\r\n // "); TestHelper.AssertGeneratedCodeContains(generatedCode, warningComment); }
public void CodeGen_CustomAttrGen_Attribute_References_Type_NotKnowable() { 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.AddUnknowableType(typeof(Mock_CG_Attr_Gen_Type)); string generatedCode = TestHelper.GenerateCodeAssertSuccess("C#", new Type[] { typeof(Mock_CG_Attr_Gen_DomainService) }, logger, mockSts); 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))]"); }