Beispiel #1
0
        public void CodeGen_Attribute_CustomValidation_UnsharedValidator()
        {
            ConsoleLogger logger        = new ConsoleLogger();
            string        generatedCode = TestHelper.GenerateCode("C#", typeof(UnsharedValidatorTestEntity), logger);

            TestHelper.AssertNoErrorsOrWarnings(logger);
            Assert.IsFalse(string.IsNullOrEmpty(generatedCode), "Expected generated code");
            TestHelper.AssertGeneratedCodeDoesNotContain(generatedCode, "typeof(UnsharedValidator)");
        }
Beispiel #2
0
        public void SharedTypes_CodeGen_Warns_Unshared_Property_Type()
        {
            var logger = new ConsoleLogger();

            // Create a shared type service that says the entity's attribute is "shared" when asked whether it is shared
            var mockSts = new MockSharedCodeService(new Type[0], new MethodBase[0], new string[0]);

            var generatedCode = TestHelper.GenerateCode("C#", new[] { typeof(Mock_CG_Shared_Entity) }, logger, mockSts);

            Assert.IsFalse(string.IsNullOrEmpty(generatedCode), "Code should have been generated");

            TestHelper.AssertGeneratedCodeDoesNotContain("XProperty");
            //string entityWarning = String.Format(CultureInfo.CurrentCulture, Resource.ClientCodeGen_PropertyType_Not_Shared, "XProperty", typeof(Mock_CG_Shared_Entity).FullName, typeof(X).FullName, "MockProject");
            //TestHelper.AssertContainsWarnings(logger, entityWarning);
        }
Beispiel #3
0
        public void CodeGen_Attribute_KeyAttribute_SharedAttribute()
        {
            ConsoleLogger logger = new ConsoleLogger();

            // For this test, consider K2 shared and K1 not shared
            ISharedCodeService sts = new MockSharedCodeService(
                new Type[] { typeof(Mock_CG_Attr_Entity_Shared_Key) },
                new MethodInfo[] { typeof(Mock_CG_Attr_Entity_Shared_Key).GetProperty("K2").GetGetMethod() },
                new string[0]);

            string generatedCode = TestHelper.GenerateCode("C#", new Type[] { typeof(Mock_CG_Attr_Entity_Shared_Key) }, logger, sts);

            Assert.IsTrue(!string.IsNullOrEmpty(generatedCode));
            TestHelper.AssertGeneratedCodeDoesNotContain(generatedCode, "GetIdentity");
        }