public void SharedCodeService_Types() { string projectPath, outputPath; TestHelper.GetProjectPaths("STS1", out projectPath, out outputPath); var clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath); var logger = new ConsoleLogger(); using (var scs = CodeGenHelper.CreateSharedCodeService(clientProjectPath, logger)) { // TestEntity is shared because it is linked CodeMemberShareKind shareKind = scs.GetTypeShareKind(typeof(TestEntity).AssemblyQualifiedName); Assert.AreEqual(CodeMemberShareKind.SharedByReference, shareKind, "Expected TestEntity type to be shared by reference"); // TestValidator is shared because it is linked shareKind = scs.GetTypeShareKind(typeof(TestValidator).AssemblyQualifiedName); Assert.AreEqual(CodeMemberShareKind.SharedByReference, shareKind, "Expected TestValidator type to be shared by reference"); // SharedClass is shared because it is linked shareKind = scs.GetTypeShareKind(typeof(SharedClass).AssemblyQualifiedName); Assert.IsTrue(shareKind == CodeMemberShareKind.SharedBySource, "Expected SharedClass type to be shared in source"); // TestValidatorServer exists only on the server and is not shared shareKind = scs.GetTypeShareKind(typeof(TestValidatorServer).AssemblyQualifiedName); Assert.IsTrue(shareKind == CodeMemberShareKind.NotShared, "Expected TestValidatorServer type not to be shared"); // CodelessType exists on both server and client, but lacks all user code necessary // to determine whether it is shared. Because it compiles into both projects, it should // be considered shared by finding the type in both assemblies shareKind = scs.GetTypeShareKind(typeof(CodelessType).AssemblyQualifiedName); Assert.IsTrue(shareKind == CodeMemberShareKind.SharedByReference, "Expected CodelessType type to be shared in assembly"); } }
public void SharedCodeService_Methods() { string projectPath, outputPath; TestHelper.GetProjectPaths("STS4", out projectPath, out outputPath); var clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath); var logger = new ConsoleLogger(); using (var scs = CodeGenHelper.CreateSharedCodeService(clientProjectPath, logger)) { CodeMemberShareKind shareKind = scs.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 = scs.GetMethodShareKind(typeof(TestEntity).AssemblyQualifiedName, "ServerAndClientMethod", new string[0]); Assert.AreEqual(CodeMemberShareKind.SharedByReference, shareKind, "Expected TestValidator.ServerAndClientMethod to be shared by reference"); shareKind = scs.GetMethodShareKind(typeof(TestEntity).AssemblyQualifiedName, "ServerMethod", new string[0]); Assert.AreEqual(CodeMemberShareKind.NotShared, shareKind, "Expected TestValidator.ServerMethod not to be shared"); shareKind = scs.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); } }
public void SharedCodeService_Properties() { string projectPath, outputPath; TestHelper.GetProjectPaths("STS2", out projectPath, out outputPath); var clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath); var logger = new ConsoleLogger(); using (var scs = CodeGenHelper.CreateSharedCodeService(clientProjectPath, logger)) { CodeMemberShareKind shareKind = scs.GetPropertyShareKind(typeof(TestEntity).AssemblyQualifiedName, "ServerAndClientValue"); Assert.AreEqual(CodeMemberShareKind.SharedByReference, shareKind, "Expected TestEntity.ServerAndClientValue property to be shared by reference."); shareKind = scs.GetPropertyShareKind(typeof(TestEntity).AssemblyQualifiedName, "TheValue"); Assert.AreEqual(CodeMemberShareKind.NotShared, shareKind, "Expected TestEntity.TheValue property not to be shared in source."); } }
public void SharedCodeService_Ctors() { string projectPath = null; string outputPath = null; TestHelper.GetProjectPaths("STS5", 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); } }