public void ExamineServer_Correctly_Identifies_Dot_Net_Core_Server()
        {
            //  Provide the structure that would be present for a .NET Framework server.
            _registry.AddStructure(RegistryView.Registry64, string.Join(Environment.NewLine,
                                                                        @"HKEY_CLASSES_ROOT",
                                                                        @"   CLSID",
                                                                        @"      {93DEE2FF-1446-4119-A78D-60858BD38E9D}",
                                                                        @"         (Default) = CoreCLR COMHost Server",
                                                                        @"         InprocServer32",
                                                                        @"            (Default) = \\\\Mac\\Home\\repos\\github\\dwmkerr\\sharpshell\\SharpShell\\Samples\\ContextMenu\\CountLinesExtension\\bin\\Debug\\netcoreapp3.1\\CountLinesExtension.comhost.dll",
                                                                        @"            ThreadingModel = Both",
                                                                        @"            ProgID",
                                                                        @"               (Default) = CountLinesExtension.CountLinesExtension"
                                                                        ));

            var registrationInfo = ComAdmin.ExamineServer(new Guid("{93DEE2FF-1446-4119-A78D-60858BD38E9D}"));

            Assert.That(registrationInfo.Clsid, Is.EqualTo(new Guid("{93DEE2FF-1446-4119-A78D-60858BD38E9D}")));
            Assert.That(registrationInfo.ClassName, Is.EqualTo(@"CoreCLR COMHost Server"));
            Assert.That(registrationInfo.ComServerPath,
                        Is.EqualTo(
                            @"\\\\Mac\\Home\\repos\\github\\dwmkerr\\sharpshell\\SharpShell\\Samples\\ContextMenu\\CountLinesExtension\\bin\\Debug\\netcoreapp3.1\\CountLinesExtension.comhost.dll"));
            Assert.That(registrationInfo.ThreadingModel, Is.EqualTo(@"Both"));
            Assert.That(registrationInfo.DotNetFrameworkServer, Is.Null);
            Assert.That(registrationInfo.DotNetCoreServer.ProgId,
                        Is.EqualTo(@"CountLinesExtension.CountLinesExtension"));
        }
Exemplo n.º 2
0
 public void SetUp()
 {
     //  When running a test, use the in-memory registry. Let the ComAdmin APIs know to use this instance instead
     //  of the default WindowsRegistry.
     _registry = new InMemoryRegistry();
     ComAdmin.SetRegistryImplementation(_registry);
 }
Exemplo n.º 3
0
        public void ExamineFile_Can_Identify_A_Dot_Net_Core_Assembly()
        {
            var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestFiles", "DotNetCoreComServer.dll");
            var fileShellExtensions = ComAdmin.ExamineFile(path);

            Assert.That(fileShellExtensions.FileType, Is.EqualTo(FileType.DotNetCoreAssembly));
            Assert.That(fileShellExtensions.Version, Is.EqualTo(new Version(1, 0, 0, 0)));
            Assert.That(fileShellExtensions.ProcessorArchitecture, Is.EqualTo(ProcessorArchitecture.MSIL));
            Assert.That(fileShellExtensions.FrameworkName, Is.EqualTo(".NETCoreApp,Version=v3.1"));
        }
Exemplo n.º 4
0
        public void ExamineFile_Can_Identify_A_Native_Dll()
        {
            var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestFiles", "NativeDll.dll");
            var fileShellExtensions = ComAdmin.ExamineFile(path);

            Assert.That(fileShellExtensions.FileType, Is.EqualTo(FileType.NativeDll));
            Assert.That(fileShellExtensions.Version, Is.Null);
            Assert.That(fileShellExtensions.ProcessorArchitecture, Is.EqualTo(ProcessorArchitecture.None));
            Assert.That(fileShellExtensions.FrameworkName, Is.Null);
        }
        public void ExamineServer_Correctly_Identifies_Unregistered_Server()
        {
            //  No servers, so we shouldn't find anything here...
            //  Provide the structure that would be present for a .NET Framework server.
            _registry.AddStructure(RegistryView.Registry64, string.Join(Environment.NewLine,
                                                                        @"HKEY_CLASSES_ROOT",
                                                                        @"   CLSID"
                                                                        ));

            Assert.That(ComAdmin.ExamineServer(new Guid("{00000000-1111-2222-3333-444444444444}")), Is.Null);
        }
        public void ExamineServer_Correctly_Identifies_Dot_Net_Framework_Server()
        {
            //  Provide the structure that would be present for a .NET Framework server. This is based on DotFrameworkComServer.
            _registry.AddStructure(RegistryView.Registry64, string.Join(Environment.NewLine,
                                                                        @"HKEY_CLASSES_ROOT",
                                                                        @"   CLSID",
                                                                        @"      {00000000-0000-0000-C0C0-000000000002}",
                                                                        @"         (Default) = DotNetFrameworkComServer.DotFrameworkComServer",
                                                                        @"         Implemented Categories",
                                                                        @"            {62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}",
                                                                        @"         InprocServer32",
                                                                        @"            (Default) = mscoree.dll",
                                                                        @"            Assembly = DotNetFrameworkComServer, Version=0.1.2.3, Culture=neutral, PublicKeyToken=4de4d67b1b2c36c0",
                                                                        @"            Class = DotNetFrameworkComServer.DotFrameworkComServer",
                                                                        @"            RuntimeVersion = v4.0.30319",
                                                                        @"            ThreadingModel = Both",
                                                                        @"            CodeBase = file://Mac/Home/repos/github/dwmkerr/dotnet-com-admin/src/ComAdmin.Tests/TestFiles/DotNetFrameworkComServer.DLL",
                                                                        @"            0.1.2.3",
                                                                        @"               Assembly = DotNetFrameworkComServer, Version=0.1.2.3, Culture=neutral, PublicKeyToken=4de4d67b1b2c36c0",
                                                                        @"               Class = DotNetFrameworkComServer.DotFrameworkComServer",
                                                                        @"               RuntimeVersion = v4.0.30319",
                                                                        @"               CodeBase = file://Mac/Home/repos/github/dwmkerr/dotnet-com-admin/src/ComAdmin.Tests/TestFiles/DotNetFrameworkComServer.DLL",
                                                                        @"         ProgId",
                                                                        @"            (Default) = DotNetFrameworkComServer.DotFrameworkComServer"
                                                                        ));

            var registrationInfo = ComAdmin.ExamineServer(new Guid("{00000000-0000-0000-C0C0-000000000002}"));

            Assert.That(registrationInfo.Clsid, Is.EqualTo(new Guid("{00000000-0000-0000-C0C0-000000000002}")));
            Assert.That(registrationInfo.ClassName, Is.EqualTo("DotNetFrameworkComServer.DotFrameworkComServer"));
            Assert.That(registrationInfo.ComServerPath, Is.EqualTo("mscoree.dll"));
            Assert.That(registrationInfo.ThreadingModel, Is.EqualTo("Both"));
            Assert.That(registrationInfo.DotNetFrameworkServer.RootAssemblyInfo.Assembly, Is.EqualTo("DotNetFrameworkComServer, Version=0.1.2.3, Culture=neutral, PublicKeyToken=4de4d67b1b2c36c0"));
            Assert.That(registrationInfo.DotNetFrameworkServer.RootAssemblyInfo.Class, Is.EqualTo("DotNetFrameworkComServer.DotFrameworkComServer"));
            Assert.That(registrationInfo.DotNetFrameworkServer.RootAssemblyInfo.RuntimeVersion, Is.EqualTo("v4.0.30319"));
            Assert.That(registrationInfo.DotNetFrameworkServer.RootAssemblyInfo.CodeBase, Is.EqualTo("file://Mac/Home/repos/github/dwmkerr/dotnet-com-admin/src/ComAdmin.Tests/TestFiles/DotNetFrameworkComServer.DLL"));
            Assert.That(registrationInfo.DotNetFrameworkServer.AssemblyVersions.Count, Is.EqualTo(1));
            Assert.That(registrationInfo.DotNetFrameworkServer.AssemblyVersions["0.1.2.3"].Assembly, Is.EqualTo("DotNetFrameworkComServer, Version=0.1.2.3, Culture=neutral, PublicKeyToken=4de4d67b1b2c36c0"));
            Assert.That(registrationInfo.DotNetFrameworkServer.AssemblyVersions["0.1.2.3"].Class, Is.EqualTo("DotNetFrameworkComServer.DotFrameworkComServer"));
            Assert.That(registrationInfo.DotNetFrameworkServer.AssemblyVersions["0.1.2.3"].RuntimeVersion, Is.EqualTo("v4.0.30319"));
            Assert.That(registrationInfo.DotNetFrameworkServer.AssemblyVersions["0.1.2.3"].CodeBase, Is.EqualTo("file://Mac/Home/repos/github/dwmkerr/dotnet-com-admin/src/ComAdmin.Tests/TestFiles/DotNetFrameworkComServer.DLL"));
            Assert.That(registrationInfo.DotNetCoreServer, Is.Null);
        }
Exemplo n.º 7
0
        public void RegisterDotNetCoreComServer_Correctly_Creates_A_Class_Entry()
        {
            //  Create a dummy guid and COM host and register the server as a .NET Core server with COM Admin.
            var          clsid         = new Guid("00000000-1111-2222-3333-444444444444");
            const string progId        = "SomeComServerName.MyServer";
            const string proxyHostPath = @"c:\Some Folder\SomeServer.comhost.dll";

            ComAdmin.RegisterDotNetCoreComServer(RegistryView.Registry64, clsid, progId, proxyHostPath);

            //  Assert we have the expected structure
            var print = _registry.Print(RegistryView.Registry64);

            Assert.That(print, Is.EqualTo(string.Join(Environment.NewLine,
                                                      @"HKEY_CLASSES_ROOT",
                                                      @"   CLSID",
                                                      @"      {00000000-1111-2222-3333-444444444444} = CoreCLR COMHost Server",
                                                      @"        InProcServer32 = c:\Some Folder\SomeServer.comhost.dll",
                                                      @"        ThreadinModel = Both",
                                                      @"      ProgId = SomeComServerName.MyServer")
                                          ));
        }
        public void ExamineServer_Correctly_Identifies_Native_Server()
        {
            //  Provide the structure that would be present for a .NET Framework server.
            _registry.AddStructure(RegistryView.Registry64, string.Join(Environment.NewLine,
                                                                        @"HKEY_CLASSES_ROOT",
                                                                        @"   CLSID",
                                                                        @"      {93CB110F-9189-4349-BD9F-392D9A4D0096}",
                                                                        @"         (Default) = Accessibility Control Panel",
                                                                        @"         InprocServer32",
                                                                        @"            (Default) = %SystemRoot%\System32\accessibilitycpl.dll",
                                                                        @"            ThreadingModel = Apartment"
                                                                        ));

            var registrationInfo = ComAdmin.ExamineServer(new Guid("{93CB110F-9189-4349-BD9F-392D9A4D0096}"));

            Assert.That(registrationInfo.Clsid, Is.EqualTo(new Guid("{93CB110F-9189-4349-BD9F-392D9A4D0096}")));
            Assert.That(registrationInfo.ClassName, Is.EqualTo(@"Accessibility Control Panel"));
            Assert.That(registrationInfo.ComServerPath, Is.EqualTo(@"%SystemRoot%\System32\accessibilitycpl.dll"));
            Assert.That(registrationInfo.ThreadingModel, Is.EqualTo(@"Apartment"));
            Assert.That(registrationInfo.DotNetFrameworkServer, Is.Null);
            Assert.That(registrationInfo.DotNetCoreServer, Is.Null);
        }
Exemplo n.º 9
0
 public void TearDown()
 {
     //  Reset the service registry to the standard Windows Registry implementation.
     ComAdmin.SetRegistryImplementation(new WindowsRegistry());
 }