public void SetValueAsStringSuccess()
        {
            const string newValue = "newValue";
            string       error;

            mockVarInfo.Assign(newValue, out error).Returns(true);
            var debugProperty = createPropertyDelegate.Invoke(mockVarInfo);

            var result = debugProperty.SetValueAsString(newValue, 0, 0);

            Assert.That(result, Is.EqualTo(VSConstants.S_OK));
        }
        public void GetPropertyInfoNone()
        {
            var unexpectedCall = new Exception("Unexpected call");

            mockVarInfo.DisplayName.Throws(unexpectedCall);
            mockVarInfo.TypeName.Throws(unexpectedCall);
            mockVarInfo.AssignmentValue.Throws(unexpectedCall);
            mockVarInfo.ValueAsync().Throws(unexpectedCall);
            mockVarInfo.Error.Throws(unexpectedCall);
            mockVarInfo.MightHaveChildren().Throws(unexpectedCall);
            mockVarInfo.GetChildAdapter().Throws(unexpectedCall);
            mockVarInfo.FindChildByName(Arg.Any <string>()).ThrowsForAnyArgs(unexpectedCall);
            mockVarInfo.IsReadOnly.Throws(unexpectedCall);
            string error;

            mockVarInfo.Assign(Arg.Any <string>(), out error).ThrowsForAnyArgs(unexpectedCall);

            DEBUG_PROPERTY_INFO propertyInfo;
            int result = GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_NONE,
                                         out propertyInfo);

            // Also verifies exceptions are not raised.

            Assert.That(result, Is.EqualTo(VSConstants.S_OK));
            Assert.That(propertyInfo.dwFields,
                        Is.EqualTo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_NONE));
        }
示例#3
0
        public int SetValueAsStringWithError(string value, uint radix, uint timeout,
                                             out string error)
        {
            string outError = null;
            int    status   = _taskExecutor.Run(() =>
            {
                if (_varInfo.Assign(value, out outError))
                {
                    return(VSConstants.S_OK);
                }

                string logName = _varInfo.Fullname();
                if (string.IsNullOrWhiteSpace(logName))
                {
                    logName = _varInfo.DisplayName;
                }

                Trace.WriteLine($"Unable to set var '{logName}'='{value}'. Error: '{outError}'");
                return(AD7Constants.E_SETVALUE_VALUE_CANNOT_BE_SET);
            });

            error = outError;
            return(status);
        }