public void DeclareVariableWithErrorRemoteValue()
        {
            RemoteValueFake remoteValue =
                RemoteValueFakeUtil.CreateClass("MyType", "myType", "myValue");

            remoteValue.AddValueFromExpression($"auto $test=5; $test",
                                               RemoteValueFakeUtil.CreateError("declaration error"));

            var natvisScope = new NatvisScope();

            natvisScope.AddScopedName("test", "$test");

            IVariableInformation varInfo = _varInfoFactory.Create(remoteValue);
            var exception = Assert.ThrowsAsync <ExpressionEvaluationFailed>(
                async() =>
                await _evaluator.DeclareVariableAsync(varInfo, "test", "5", natvisScope));

            Assert.That(exception.Message, Does.Contain("test"));
            Assert.That(exception.Message, Does.Contain("5"));
            Assert.That(exception.Message, Does.Contain("declaration error"));

            string logOutput = _nLogSpy.GetOutput();

            Assert.That(logOutput, Does.Contain("test"));
            Assert.That(logOutput, Does.Contain("5"));
            Assert.That(logOutput, Does.Contain("declaration error"));
        }
Exemple #2
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));
        }