Ejemplo n.º 1
0
        public void SharedCodeService_Methods()
        {
            string projectPath = null;
            string outputPath  = null;

            TestHelper.GetProjectPaths("", out projectPath, out outputPath);
            string clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath);

            ConsoleLogger logger = new ConsoleLogger();

            using (SharedCodeService sts = CodeGenHelper.CreateSharedCodeService(clientProjectPath, logger))
            {
                CodeMemberShareKind shareKind = sts.GetMethodShareKind(typeof(TestValidator).AssemblyQualifiedName, "IsValid", new string[] { typeof(TestEntity).AssemblyQualifiedName, typeof(ValidationContext).AssemblyQualifiedName });
                Assert.AreEqual(CodeMemberShareKind.SharedByReference, shareKind, "Expected TestValidator.IsValid to be shared by reference");

                shareKind = sts.GetMethodShareKind(typeof(TestEntity).AssemblyQualifiedName, "ServerAndClientMethod", Array.Empty <string>());
                Assert.AreEqual(CodeMemberShareKind.SharedByReference, shareKind, "Expected TestValidator.ServerAndClientMethod to be shared by reference");

                shareKind = sts.GetMethodShareKind(typeof(TestEntity).AssemblyQualifiedName, "ServerMethod", Array.Empty <string>());
                Assert.AreEqual(CodeMemberShareKind.NotShared, shareKind, "Expected TestValidator.ServerMethod not to be shared");

                shareKind = sts.GetMethodShareKind(typeof(TestValidatorServer).AssemblyQualifiedName, "IsValid", new string[] { typeof(TestEntity).AssemblyQualifiedName, typeof(ValidationContext).AssemblyQualifiedName });
                Assert.AreEqual(CodeMemberShareKind.NotShared, shareKind, "Expected TestValidator.IsValid not to be shared");

                TestHelper.AssertNoErrorsOrWarnings(logger);
            }
        }
Ejemplo n.º 2
0
        public void SharedCodeService_Ctors()
        {
            string projectPath = null;
            string outputPath  = null;

            TestHelper.GetProjectPaths("", out projectPath, out outputPath);
            string clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath);

            ConsoleLogger logger = new ConsoleLogger();

            using (SharedCodeService sts = CodeGenHelper.CreateSharedCodeService(clientProjectPath, logger))
            {
                ConstructorInfo ctor = typeof(TestValidator).GetConstructor(new Type[] { typeof(string) });
                Assert.IsNotNull("Failed to find string ctor on TestValidator");
                CodeMemberShareKind shareKind = sts.GetMethodShareKind(typeof(TestValidator).AssemblyQualifiedName, ctor.Name, new string[] { typeof(string).AssemblyQualifiedName });
                Assert.AreEqual(CodeMemberShareKind.SharedByReference, shareKind, "Expected TestValidator ctor to be shared by reference");
                TestHelper.AssertNoErrorsOrWarnings(logger);
            }
        }