示例#1
0
        public void SharedAssembliesManaged_Types()
        {
            string projectPath = null;
            string outputPath  = null;

            TestHelper.GetProjectPaths("", out projectPath, out outputPath);
            string        clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath);
            List <string> assemblies        = CodeGenHelper.ClientClassLibReferences(clientProjectPath, true);

            ConsoleLogger logger = new ConsoleLogger();

            using (var sa = CreatedSharedAssembliesService(assemblies, CodeGenHelper.GetClientAssemblyPaths(), logger))
            {
                string sharedTypeLocation = GetSharedTypeLocation(sa, typeof(TestEntity));
                Assert.IsNotNull(sharedTypeLocation, "Expected TestEntity type to be shared");
                Assert.IsTrue(sharedTypeLocation.Contains("ClientClassLib"), "Expected to find type in client class lib");

                sharedTypeLocation = GetSharedTypeLocation(sa, typeof(TestValidator));
                Assert.IsNotNull(sharedTypeLocation, "Expected TestValidator type to be shared");
                Assert.IsTrue(sharedTypeLocation.Contains("ClientClassLib"), "Expected to find type in client class lib");

                sharedTypeLocation = GetSharedTypeLocation(sa, typeof(DomainService));
                Assert.IsNull(sharedTypeLocation, "Expected DomainService type not to be shared");

                sharedTypeLocation = GetSharedTypeLocation(sa, typeof(TestValidatorServer));
                Assert.IsNull(sharedTypeLocation, "Expected TestValidatorServer type not to be shared");
            }

            TestHelper.AssertNoErrorsOrWarnings(logger);
        }
示例#2
0
        public void SharedAssembliesManaged_Methods()
        {
            string projectPath = null;
            string outputPath  = null;

            TestHelper.GetProjectPaths("", out projectPath, out outputPath);
            string        clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath);
            List <string> assemblies        = CodeGenHelper.ClientClassLibReferences(clientProjectPath, true);

            ConsoleLogger logger = new ConsoleLogger();

            using (var sa = CreatedSharedAssembliesService(assemblies, CodeGenHelper.GetClientAssemblyPaths(), logger))
            {
                var sharedMethodLocation = GetSharedMethodLocation(sa, typeof(TestValidator), "IsValid", new[] { typeof(TestEntity), typeof(ValidationContext) });
                Assert.IsNotNull(sharedMethodLocation, "Expected TestValidator.IsValid to be shared");
                Assert.IsTrue(sharedMethodLocation.Contains("ClientClassLib"), "Expected to find method in client class lib");

                sharedMethodLocation = GetSharedMethodLocation(sa, typeof(TestEntity), "ServerAndClientMethod", Type.EmptyTypes);
                Assert.IsNotNull(sharedMethodLocation, "Expected TestEntity.ServerAndClientMethod to be shared");
                Assert.IsTrue(sharedMethodLocation.Contains("ClientClassLib"), "Expected to find method in client class lib");

                sharedMethodLocation = GetSharedMethodLocation(sa, typeof(TestValidator), "ServertMethod", Type.EmptyTypes);
                Assert.IsNull(sharedMethodLocation, "Expected TestValidator.ServerMethod not to be shared");
            }

            TestHelper.AssertNoErrorsOrWarnings(logger);
        }
示例#3
0
        public void SharedAssemblies_Methods()
        {
            string projectPath = null;
            string outputPath  = null;

            TestHelper.GetProjectPaths(string.Empty, 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.GetClientAssemblyPaths(), 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", Array.Empty <string>());
            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", Array.Empty <string>());
            Assert.IsNull(sharedMethod, "Expected TestValidator.ServerMethod not to be shared");

            TestHelper.AssertNoErrorsOrWarnings(logger);
        }
示例#4
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);
            }
        }
示例#5
0
        public void SharedAssemblies_Types()
        {
            string projectPath = null;
            string outputPath  = null;

            TestHelper.GetProjectPaths(string.Empty, 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.GetClientAssemblyPaths(), logger);

            Type sharedType = sa.GetSharedType(typeof(TestEntity).AssemblyQualifiedName);

            Assert.IsNotNull(sharedType, "Expected TestEntity type to be shared");
            Assert.IsTrue(sharedType.Assembly.Location.Contains("ClientClassLib"), "Expected to find type in client class lib");

            sharedType = sa.GetSharedType(typeof(TestValidator).AssemblyQualifiedName);
            Assert.IsNotNull(sharedType, "Expected TestValidator type to be shared");
            Assert.IsTrue(sharedType.Assembly.Location.Contains("ClientClassLib"), "Expected to find type in client class lib");

            sharedType = sa.GetSharedType(typeof(DomainService).AssemblyQualifiedName);
            Assert.IsNull(sharedType, "Expected DomainService type not to be shared");

            sharedType = sa.GetSharedType(typeof(TestValidatorServer).AssemblyQualifiedName);
            Assert.IsNull(sharedType, "Expected TestValidatorServer type not to be shared");

            TestHelper.AssertNoErrorsOrWarnings(logger);
        }
示例#6
0
        public void SharedSourceFiles_Methods()
        {
            string projectPath = null;
            string outputPath  = null;

            TestHelper.GetProjectPaths("SFT", out projectPath, out outputPath);
            string        clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath);
            List <string> sourceFiles       = CodeGenHelper.ClientClassLibSourceFiles(clientProjectPath);
            ConsoleLogger logger            = new ConsoleLogger();
            FilenameMap   filenameMap       = new FilenameMap();

            using (SourceFileLocationService locationService = new SourceFileLocationService(new[] { new PdbSourceFileProviderFactory(/*symbolSearchPath*/ null, logger) }, filenameMap))
            {
                SharedSourceFiles ssf = new SharedSourceFiles(locationService, filenameMap, sourceFiles);

                int[] fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateMethodKey(typeof(TestValidator).GetMethod("IsValid")));
                Assert.IsNotNull(fileIds, "Expected TestValidator.IsValid to have non-null file ID's because it is shared");
                Assert.AreEqual(1, fileIds.Length, "Expected TestValidator.IsValid to be found in exactly one file");
                Assert.IsTrue(filenameMap[fileIds[0]].Contains("TestValidator.linked.cs"), "Expected TestValidator.IsValid to be in TestValidator.linked.cs");

                fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateMethodKey(typeof(TestEntity).GetMethod("ServerAndClientMethod")));
                Assert.IsNotNull(fileIds, "Expected TestEntity.ServerAndClientMethod to have non-null file ID's because it is shared");
                Assert.AreEqual(1, fileIds.Length, "Expected TestEntity.ServerAndClientMethod to be found in exactly one file");
                Assert.IsTrue(filenameMap[fileIds[0]].Contains("TestEntity.linked.cs"), "Expected TestEntity.ServerAndClientMethod to be in TestEntity.linked.cs");

                fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateMethodKey(typeof(TestEntity).GetMethod("ServerMethod")));
                Assert.IsNull(fileIds, "Expected TestEntity.ServerMethod to have null file ids");

                fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateMethodKey(typeof(TestValidatorServer).GetMethod("IsValid")));
                Assert.IsNull(fileIds, "Expected TestValidatorServer.IsValid to have null file ids");
            }
        }
示例#7
0
        public void SharedAssembliesManaged_Matches_MsCorLib()
        {
            Type[] sharedTypes = new Type[] {
                typeof(Int32),
                typeof(string),
                typeof(Decimal),
                typeof(List <int>),
                typeof(Dictionary <int, string>)
            };

            Type[] nonSharedTypes = new Type[] {
                typeof(DomainService),
                typeof(List <DomainService>),
                typeof(DomainService[])
                // Below is fomr System.IO.Compression.Filesystem which is not referenced by client
                //typeof(System.Xml.Linq.XElement)
            };

            MethodBase[] sharedMethods = new MethodBase[] {
                typeof(string).GetMethod("CopyTo"),
            };

            string projectPath = null;
            string outputPath  = null;

            TestHelper.GetProjectPaths("", out projectPath, out outputPath);
            string        clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath);
            List <string> assemblies        = CodeGenHelper.ClientClassLibReferences(clientProjectPath, true);

            ConsoleLogger logger = new ConsoleLogger();

            using (var sa = CreatedSharedAssembliesService(assemblies, CodeGenHelper.GetClientAssemblyPaths(), logger))
            {
                foreach (Type t in sharedTypes)
                {
                    var sharedTypeLocation = GetSharedTypeLocation(sa, t);
                    Assert.IsNotNull(sharedTypeLocation, "Expected type " + t.Name + " to be considered shared.");
                }

                foreach (MethodBase m in sharedMethods)
                {
                    Type[] parameterTypes       = m.GetParameters().Select(p => p.ParameterType).ToArray();
                    var    sharedMethodLocation = GetSharedMethodLocation(sa, m.DeclaringType, m.Name, parameterTypes);
                    Assert.IsNotNull(sharedMethodLocation, "Expected method " + m.DeclaringType.Name + "." + m.Name + " to be considered shared.");
                }

                foreach (Type t in nonSharedTypes)
                {
                    var sType = GetSharedTypeLocation(sa, t);
                    Assert.IsNull(sType, "Expected type " + t.Name + " to be considered *not* shared.");
                }
            }
        }
示例#8
0
        /// <summary>
        /// Creates a new CreateOpenRiaClientFilesTask instance to use to generate code
        /// using the TestWap project.
        /// </summary>
        /// <param name="relativeTestDir"></param>
        /// <returns>A new task instance that can be invoked to do code gen</returns>
        public static CreateOpenRiaClientFilesTask CreateOpenRiaClientFilesTaskInstanceForWAP(string relativeTestDir)
        {
            string deploymentDir = Path.GetDirectoryName(typeof(CodeGenHelper).Assembly.Location);
            string projectPath   = null;
            string outputPath    = null;

            TestHelper.GetProjectPaths(relativeTestDir, out projectPath, out outputPath);

            Assert.IsTrue(File.Exists(projectPath), "Could not locate " + projectPath + " necessary for test.");
            string serverProjectPath = CodeGenHelper.ServerWapProjectPath(projectPath);
            string clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath);

            return(CodeGenHelper.CreateOpenRiaClientFilesTaskInstance(serverProjectPath, clientProjectPath, false));
        }
示例#9
0
        [Microsoft.VisualStudio.TestTools.UnitTesting.Ignore] // Add this test for all other target frameworks where client is different from server
        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(string.Empty, 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.GetClientAssemblyPaths(), 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.");
            }
        }
示例#10
0
        public void SharedAssembliesManaged_Properties()
        {
            string projectPath = null;
            string outputPath  = null;

            TestHelper.GetProjectPaths("", out projectPath, out outputPath);
            string        clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath);
            List <string> assemblies        = CodeGenHelper.ClientClassLibReferences(clientProjectPath, true);

            ConsoleLogger logger = new ConsoleLogger();

            using (var sa = CreatedSharedAssembliesService(assemblies, CodeGenHelper.GetClientAssemblyPaths(), logger))
            {
                string sharedTypeLocation = GetSharedPropertyLocation(sa, typeof(TestEntity), nameof(TestEntity.ClientAndServerValue));
                Assert.IsNotNull(sharedTypeLocation, "Expected TestEntity type to be shared");
                Assert.IsTrue(sharedTypeLocation.Contains("ClientClassLib"), "Expected to find type in client class lib");

                sharedTypeLocation = GetSharedPropertyLocation(sa, typeof(TestEntity), nameof(TestEntity.ServerAndClientValue));
                Assert.IsNotNull(sharedTypeLocation, "Expected TestEntity type to be shared");
                Assert.IsTrue(sharedTypeLocation.Contains("ClientClassLib"), "Expected to find type in client class lib");

                sharedTypeLocation = GetSharedPropertyLocation(sa, typeof(TestEntity), nameof(TestEntity.TheValue));
                Assert.IsNull(sharedTypeLocation, "Expected TestEntity.TheValue type to not be shared");

                // We should detect properties from derived types
                sharedTypeLocation = GetSharedPropertyLocation(sa, "ServerClassLib.TestDomainSharedContext", "ValidationContext");
                Assert.IsNotNull(sharedTypeLocation, "Expected to detect properties from base classes (DomainContext.ValidationContext)");
                StringAssert.Contains(sharedTypeLocation, "OpenRiaServices.DomainServices.Client");

                // We should not detect internal properties
                sharedTypeLocation = GetSharedPropertyLocation(sa, "OpenRiaServices.DomainServices.Client.Entity", "ValidationErrors");
                Assert.IsNotNull(sharedTypeLocation, "Should detect properties in other assemblies");
                StringAssert.Contains(sharedTypeLocation, "OpenRiaServices.DomainServices.Client");

                sharedTypeLocation = GetSharedPropertyLocation(sa, "OpenRiaServices.DomainServices.Client.Entity", "ParentAssociation");
                Assert.IsNull(sharedTypeLocation, "Expected to not detect internal properties");

                sharedTypeLocation = GetSharedPropertyLocation(sa, "OpenRiaServices.DomainServices.Client.Entity", "IsMergingState");
                Assert.IsNull(sharedTypeLocation, "Expected to not detect protected internal properties");
            }

            TestHelper.AssertNoErrorsOrWarnings(logger);
        }
示例#11
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);
            }
        }
示例#12
0
        public void SharedCodeService_Properties()
        {
            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.GetPropertyShareKind(typeof(TestEntity).AssemblyQualifiedName, "ServerAndClientValue");
                Assert.AreEqual(CodeMemberShareKind.SharedByReference, shareKind, "Expected TestEntity.ServerAndClientValue property to be shared by reference.");

                shareKind = sts.GetPropertyShareKind(typeof(TestEntity).AssemblyQualifiedName, "TheValue");
                Assert.AreEqual(CodeMemberShareKind.NotShared, shareKind, "Expected TestEntity.TheValue property not to be shared in source.");
            }
        }
示例#13
0
        public void PdbReader_Finds_Types_Files()
        {
            string projectPath = null;
            string outputPath  = null;

            TestHelper.GetProjectPaths("PDB", out projectPath, out outputPath);
            string        serverProjectPath = CodeGenHelper.ServerClassLibProjectPath(projectPath);
            string        clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath);
            ConsoleLogger logger            = new ConsoleLogger();
            FilenameMap   filenameMap       = new FilenameMap();

            using (SourceFileLocationService locationService = new SourceFileLocationService(new[] { new PdbSourceFileProviderFactory(/*symbolSearchPath*/ null, logger) }, filenameMap))
            {
                List <string> files = new List <string>(locationService.GetFilesForType(typeof(TestEntity)));
                Assert.AreEqual(4, files.Count);

                CodeGenHelper.AssertContainsFiles(files, serverProjectPath, new string[] { "TestEntity.cs", "TestEntity.shared.cs", "TestEntity.linked.cs" });
                CodeGenHelper.AssertContainsFiles(files, clientProjectPath, new string[] { "TestEntity.reverse.linked.cs" });
            }
        }
示例#14
0
        public void SharedCodeService_Types()
        {
            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))
            {
                // TestEntity is shared because it is linked
                CodeMemberShareKind shareKind = sts.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 = sts.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 = sts.GetTypeShareKind(typeof(SharedClass).AssemblyQualifiedName);
                Assert.IsTrue(shareKind == CodeMemberShareKind.SharedBySource, "Expected SharedClass type to be shared in source");

                // DomainService exists only in the server and is not shared
                shareKind = sts.GetTypeShareKind(typeof(DomainService).AssemblyQualifiedName);
                Assert.IsTrue(shareKind == CodeMemberShareKind.NotShared, "Expected DomainService type not to be shared");

                // TestValidatorServer exists only on the server and is not shared
                shareKind = sts.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 = sts.GetTypeShareKind(typeof(CodelessType).AssemblyQualifiedName);
                Assert.IsTrue(shareKind == CodeMemberShareKind.SharedByReference, "Expected CodelessType type to be shared in assembly");
            }
        }
示例#15
0
        public void SharedSourceFiles_Types()
        {
            string projectPath = null;
            string outputPath  = null;

            TestHelper.GetProjectPaths("SFT", out projectPath, out outputPath);
            string        clientProjectPath = CodeGenHelper.ClientClassLibProjectPath(projectPath);
            List <string> sourceFiles       = CodeGenHelper.ClientClassLibSourceFiles(clientProjectPath);
            ConsoleLogger logger            = new ConsoleLogger();
            FilenameMap   filenameMap       = new FilenameMap();

            using (SourceFileLocationService locationService = new SourceFileLocationService(new[] { new PdbSourceFileProviderFactory(/*symbolSearchPath*/ null, logger) }, filenameMap))
            {
                SharedSourceFiles ssf = new SharedSourceFiles(locationService, filenameMap, sourceFiles);

                int[] fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateTypeKey(typeof(TestEntity)));
                Assert.IsNotNull(fileIds, "Expected TestEntity to have non-null file ID's because it is shared");
                Assert.AreEqual(2, fileIds.Length, "Expected TestEntity to be found in exactly 2 files");
                foreach (int i in fileIds)
                {
                    string file = filenameMap[i];
                    Assert.IsTrue(file.Contains("TestEntity.linked.cs") || file.Contains("TestEntity.reverse.linked.cs"), "Expected exactly these 2 files to be shared");
                }

                fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateTypeKey(typeof(TestValidator)));
                Assert.IsNotNull(fileIds, "Expected TestValidator to have non-null file ID's because it is shared");
                Assert.AreEqual(1, fileIds.Length, "Expected TestValidator to be found in exactly one file");
                Assert.IsTrue(filenameMap[fileIds[0]].Contains("TestValidator.linked.cs"), "expected this to be the sole shared file for TestValidator");

                fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateTypeKey(typeof(DomainService)));
                Assert.IsNull(fileIds, "Expected DomainService to have no shared file ids");

                fileIds = ssf.GetSharedFileIds(CodeMemberKey.CreateTypeKey(typeof(TestValidatorServer)));
                Assert.IsNull(fileIds, "Expected DomainService to have no shared file ids");
            }
        }