Ejemplo n.º 1
0
        public async Task GetChildrenIsRobustToMissingChildrenAsync()
        {
            var remoteValue = Substitute.For <RemoteValue>();

            remoteValue.GetTypeName().Returns("CustomType");

            string expressionPath;

            remoteValue.GetExpressionPath(out expressionPath).Returns(outArgs =>
            {
                outArgs[0] = "displayName";
                return(true);
            });

            remoteValue.GetNumChildren().Returns(1u);
            remoteValue.GetChildren(0, 1).Returns(
                new System.Collections.Generic.List <RemoteValue>()
            {
                null
            });

            RemoteValueVariableInformation varInfo = CreateVarInfo(remoteValue, "");

            IVariableInformation[] children = await varInfo.GetAllChildrenAsync();

            Assert.That(children, Is.Empty);
            Assert.That(logSpy.GetOutput(), Does.Contain("WARNING"));
            Assert.That(logSpy.GetOutput(), Does.Contain("0")); // Index
            Assert.That(logSpy.GetOutput(), Does.Contain("displayName"));
            Assert.That(logSpy.GetOutput(), Does.Contain("CustomType"));
            Assert.That(logSpy.GetOutput(), Does.Contain("1")); // num children
        }
Ejemplo n.º 2
0
        public void GetPropertyInfoHexadecimalDisplay()
        {
            // 175 is hex AF!
            int    valueInt = 175;
            string valueHex = "0xaf";

            var childAdapterFactory = new RemoteValueChildAdapter.Factory();
            var remoteValue         = RemoteValueFakeUtil.CreateSimpleInt("test", valueInt);
            var varInfo             = new RemoteValueVariableInformation(
                null, "", RemoteValueFormat.Default, ValueFormat.Default, remoteValue, "test",
                CustomVisualizer.None, childAdapterFactory);

            var debugProperty = createPropertyDelegate.Invoke(varInfo);
            var propertyInfos = new DEBUG_PROPERTY_INFO[1];

            // Radix 16 -> Int should be formatted as hex.
            debugProperty.GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE, 16, 0,
                                          null, 0, propertyInfos);

            Assert.AreEqual(propertyInfos[0].bstrValue, valueHex);

            // Radix 10 -> Int should be formatted as decimal.
            debugProperty.GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE, 10, 0,
                                          null, 0, propertyInfos);

            Assert.AreEqual(propertyInfos[0].bstrValue, valueInt.ToString());

            // Radix 8 -> Not supported, should fall back to decimal.
            debugProperty.GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE, 8, 0,
                                          null, 0, propertyInfos);

            Assert.AreEqual(propertyInfos[0].bstrValue, valueInt.ToString());
        }
Ejemplo n.º 3
0
        public async Task GetNumChildrenReturnsProperCountAsync()
        {
            var remoteValue = Substitute.For <RemoteValue>();

            remoteValue.GetTypeName().Returns("CustomType");
            remoteValue.GetNumChildren().Returns(42u);

            RemoteValueVariableInformation varInfo = CreateVarInfo(remoteValue, "");

            Assert.That(await varInfo.GetChildAdapter().CountChildrenAsync(), Is.EqualTo(42u));
            Assert.That(logSpy.GetOutput(), Does.Not.Contain("WARNING"));
            Assert.That(logSpy.GetOutput(), Does.Not.Contain("ERROR"));
        }
Ejemplo n.º 4
0
        public async Task CreateValueFromExpressionAsyncReturnsNullIfValueIsNullAsync()
        {
            var remoteValue = Substitute.For <RemoteValue>();

            remoteValue
            .CreateValueFromExpressionAsync("someName", "someExpression")
            .Returns(Task.FromResult <RemoteValue>(null));

            RemoteValueVariableInformation remoteVarInfo =
                CreateVarInfo(remoteValue, "remoteValue");

            IVariableInformation varInfo = await remoteVarInfo.CreateValueFromExpressionAsync(
                "someName", new VsExpression("someExpression", FormatSpecifier.EMPTY));
        }
Ejemplo n.º 5
0
        public async Task GetNumChildrenReturnsValueFromFormatterAsync()
        {
            var remoteValue = Substitute.For <RemoteValue>();

            remoteValue.GetTypeName().Returns("CustomType");
            remoteValue.GetNumChildren().Returns(42u);

            var format = Substitute.For <IRemoteValueFormat>();

            format.GetNumChildren(remoteValue).Returns(5u);

            var varInfo = new RemoteValueVariableInformation(
                varInfoBuilder, "5", RemoteValueFormatProvider.Get("5"), ValueFormat.Default,
                remoteValue, "displayName", CustomVisualizer.None, childAdapterFactory);

            Assert.That(await varInfo.GetChildAdapter().CountChildrenAsync(), Is.EqualTo(5u));
            Assert.That(logSpy.GetOutput(), Does.Not.Contain("WARNING"));
            Assert.That(logSpy.GetOutput(), Does.Not.Contain("ERROR"));
        }
Ejemplo n.º 6
0
        public async Task CreateValueFromExpressionAsyncSuccessWhenRemoteValueNotNullAsync()
        {
            const string outValueName   = "newName";
            const string format         = "format";
            var          outRemoteValue = Substitute.For <RemoteValue>();

            outRemoteValue.GetName()
            .Returns(outValueName);
            var remoteValue = Substitute.For <RemoteValue>();

            remoteValue
            .CreateValueFromExpressionAsync("someName", "someExpression")
            .Returns(Task.FromResult(outRemoteValue));

            RemoteValueVariableInformation remoteVarInfo =
                CreateVarInfo(remoteValue, "remoteValue");

            IVariableInformation varInfo = await remoteVarInfo.CreateValueFromExpressionAsync(
                "someName", new VsExpression("someExpression", new FormatSpecifier(format)));

            Assert.AreEqual(outValueName, varInfo.DisplayName);
            Assert.AreEqual(format, varInfo.FormatSpecifier);
        }