public void SharedAssemblies_Methods() { string projectPath = null; string outputPath = null; TestHelper.GetProjectPaths("SAT", out projectPath, out outputPath); string clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath); List<string> assemblies = CodeGenHelper.ClientClassLibReferences(clientProjectPath, true); ConsoleLogger logger = new ConsoleLogger(); SharedAssemblies sa = new SharedAssemblies(assemblies, CodeGenHelper.GetSilverlightPaths(), logger); MethodBase sharedMethod = sa.GetSharedMethod(typeof(TestValidator).AssemblyQualifiedName, "IsValid", new string[] { typeof(TestEntity).AssemblyQualifiedName, typeof(ValidationContext).AssemblyQualifiedName }); Assert.IsNotNull(sharedMethod, "Expected TestValidator.IsValid to be shared"); Assert.IsTrue(sharedMethod.DeclaringType.Assembly.Location.Contains("ClientClassLib"), "Expected to find method in client class lib"); sharedMethod = sa.GetSharedMethod(typeof(TestEntity).AssemblyQualifiedName, "ServerAndClientMethod", new string[0]); Assert.IsNotNull(sharedMethod, "Expected TestEntity.ServerAndClientMethod to be shared"); Assert.IsTrue(sharedMethod.DeclaringType.Assembly.Location.Contains("ClientClassLib"), "Expected to find method in client class lib"); sharedMethod = sa.GetSharedMethod(typeof(TestValidator).AssemblyQualifiedName, "ServertMethod", new string[0]); Assert.IsNull(sharedMethod, "Expected TestValidator.ServerMethod not to be shared"); TestHelper.AssertNoErrorsOrWarnings(logger); }
public void SharedAssemblies_Matches_MsCorLib() { Type[] sharedTypes = new Type[] { typeof(Int32), typeof(string), typeof(Decimal), }; Type[] nonSharedTypes = new Type[] { typeof(SerializableAttribute), typeof(System.Xml.Linq.XElement) }; MethodBase[] sharedMethods = new MethodBase[] { typeof(string).GetMethod("CopyTo"), }; string projectPath = null; string outputPath = null; TestHelper.GetProjectPaths("SAT", out projectPath, out outputPath); string clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath); List<string> assemblies = CodeGenHelper.ClientClassLibReferences(clientProjectPath, true); ConsoleLogger logger = new ConsoleLogger(); SharedAssemblies sa = new SharedAssemblies(assemblies, CodeGenHelper.GetSilverlightPaths(), logger); foreach (Type t in sharedTypes) { Type sharedType = sa.GetSharedType(t.AssemblyQualifiedName); Assert.IsNotNull(sharedType, "Expected type " + t.Name + " to be considered shared."); } foreach (MethodBase m in sharedMethods) { string[] parameterTypes = m.GetParameters().Select<ParameterInfo, string>(p => p.ParameterType.AssemblyQualifiedName).ToArray(); MethodBase sharedMethod = sa.GetSharedMethod(m.DeclaringType.AssemblyQualifiedName, m.Name, parameterTypes); Assert.IsNotNull(sharedMethod, "Expected method " + m.DeclaringType.Name + "." + m.Name + " to be considered shared."); } foreach (Type t in nonSharedTypes) { Type sType = sa.GetSharedType(t.AssemblyQualifiedName); Assert.IsNull(sType, "Expected type " + t.Name + " to be considered *not* shared."); } }