Esempio n. 1
0
        public void ValidRegistryLoad()
        {
            // User directory set up.
            _mockRegistry.GetValue(
                @"HKEY_CURRENT_USER\Microsoft\Visual Studio\1.2.3",
                "VisualStudioLocation", null).Returns(
                @"C:\dummy\user\dir\path");

            _mockFileSystem.AddFile(_userDirNatvisFilepath, new MockFileData(_validNatvis));

            // System directory set up.

            _mockRegistry.GetValue(
                @"HKEY_CURRENT_USER\Microsoft\Visual Studio\1.2.3_Config",
                "InstallDir", null).Returns(
                @"C:\dummy\system\dir\path\extra-sub-dir");

            _mockFileSystem.AddFile(_systemDirNatvisFilepath, new MockFileData(_validNatvis));

            // Exercise

            _natvisScanner.LoadFromRegistry(@"Microsoft\Visual Studio\1.2.3");

            Assert.That(_nLogSpy.GetOutput(), Does.Not.Contain("ERROR"));
            Assert.That(_nLogSpy.GetOutput(), Does.Not.Contain("WARNING"));
            Assert.That(_nLogSpy.GetOutput(), Does.Contain(_userDirNatvisFilepath));
            Assert.That(_nLogSpy.GetOutput(), Does.Contain(_systemDirNatvisFilepath));
        }
Esempio n. 2
0
        public void SystemDirectoryRegistryKeyDoesntExist()
        {
            // User directory set up.

            _mockRegistry.GetValue(
                @"HKEY_CURRENT_USER\Microsoft\Visual Studio\1.2.3",
                "VisualStudioLocation", null).Returns(
                @"C:\dummy\user\dir\path");

            _mockFileSystem.AddDirectory(@"C:\dummy\user\dir\path\Visualizers");

            // System directory set up.

            _mockRegistry.GetValue(
                @"HKEY_CURRENT_USER\Microsoft\Visual Studio\1.2.3_Config",
                "InstallDir", null).Returns(null);

            // Exercise

            _natvisScanner.LoadFromRegistry(@"Microsoft\Visual Studio\1.2.3");

            Assert.That(_nLogSpy.GetOutput(), Does.Contain("ERROR"));
            Assert.That(_nLogSpy.GetOutput(), Does.Not.Contain(
                            @"HKEY_CURRENT_USER\Microsoft\Visual Studio\1.2.3:InstallDir"));
            Assert.That(_nLogSpy.GetOutput(), Does.Not.Contain("WARNING"));
        }
Esempio n. 3
0
        public void DirectoryDoesntExistForRegstryLoading()
        {
            // User directory set up.

            _mockRegistry.GetValue(
                @"HKEY_CURRENT_USER\Microsoft\Visual Studio\1.2.3",
                "VisualStudioLocation", null).Returns(
                @"C:\dummy\user\dir\path");

            _mockFileSystem.AddDirectory(@"C:\dummy\user\dir\path\Visualizers");

            // System directory set up.

            _mockRegistry.GetValue(
                @"HKEY_CURRENT_USER\Microsoft\Visual Studio\1.2.3_Config",
                "InstallDir", null).Returns(
                @"C:\dummy\system\dir\path\extra-sub-dir");

            // Don't create the system directory.

            // Exercise

            _natvisScanner.LoadFromRegistry(@"Microsoft\Visual Studio\1.2.3");

            Assert.That(_nLogSpy.GetOutput(), Does.Contain("ERROR"));
            Assert.That(_nLogSpy.GetOutput(), Does.Contain("Could not find"));
            Assert.That(_nLogSpy.GetOutput(), Does.Contain(
                            @"C:\dummy\system\dir\path\Packages\Debugger\Visualizers"));

            Assert.That(_nLogSpy.GetOutput(), Does.Not.Contain("WARNING"));
        }
Esempio n. 4
0
        public void FileDoesntExist()
        {
            const string filePath = @"C:\dir\file.natvis";

            Assert.That(_mockFileSystem.FileExists(filePath), Is.False);

            // Exercise
            _natvisLoader.LoadFile(filePath, new List <NatvisVisualizerScanner.FileInfo>());

            Assert.That(_nLogSpy.GetOutput(), Does.Contain("ERROR"));
            Assert.That(_nLogSpy.GetOutput(), Does.Contain(filePath));
        }
Esempio n. 5
0
        public void FileLoadLogsSentToTrace()
        {
            _natvisLogger.SetLogLevel(NatvisLoggingLevel.OFF);

            const string filePath = @"C:\dir\file.natvis";

            _mockFileSystem.FileExists(filePath).Returns(false);

            // Exercise
            _natvisLoader.LoadFile(filePath, new List <NatvisVisualizerScanner.FileInfo>());

            Assert.That(_traceLogSpy.GetOutput(), Does.Contain("ERROR"));
            Assert.That(_traceLogSpy.GetOutput(), Does.Contain(filePath));
        }
Esempio n. 6
0
        public void ReloadLoadsFromRegistry()
        {
            // System directory set up.

            _mockRegistry.GetValue(
                @"HKEY_CURRENT_USER\Microsoft\Visual Studio\1.2.3_Config",
                "InstallDir", null).Returns(
                @"C:\dummy\system\dir\path\extra-sub-dir");

            _mockFileSystem.AddFile(_systemDirNatvisFilepath, new MockFileData(_validNatvis));

            _natvisScanner.LoadFromRegistry(@"Microsoft\Visual Studio\1.2.3");

            _nLogSpy.Clear();

            _natvisScanner.Reload();

            Assert.That(_nLogSpy.GetOutput(), Does.Contain(_systemDirNatvisFilepath));
        }