public void ToStringWithPrivateReturnsPrivateValue() { var testString = new PrivateString { PrivateValue = "hidden" }; Assert.AreEqual(testString.PrivateValue, testString.ToString(SecureDataMode.Private)); }
public void ToStringReturnsPublicValue() { var testString = new PrivateString { PrivateValue = "hidden" }; Assert.AreEqual(testString.PublicValue, testString.ToString()); }
public void PublicIsHiddenPrivateIsSeen() { var testValue = "testValue"; var theString = new PrivateString { PrivateValue = testValue }; Assert.AreEqual(testValue, theString.PrivateValue); Assert.AreNotEqual(testValue, theString.PublicValue); }
/// <summary> /// Converts the given object to the type of this converter, using the specified context and culture information. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a format context.</param> /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo"/> to use as the current culture.</param> /// <param name="value">The <see cref="T:System.Object"/> to convert.</param> /// <returns> /// An <see cref="T:System.Object"/> that represents the converted value. /// </returns> /// <exception cref="T:System.NotSupportedException"> /// The conversion cannot be performed. /// </exception> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { object convertedValue = null; var stringValue = value as string; if (stringValue != null) { convertedValue = new PrivateString { PrivateValue = stringValue }; } return convertedValue; }
/// <summary> /// Converts the given object to the type of this converter, using the specified context and culture information. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a format context.</param> /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo"/> to use as the current culture.</param> /// <param name="value">The <see cref="T:System.Object"/> to convert.</param> /// <returns> /// An <see cref="T:System.Object"/> that represents the converted value. /// </returns> /// <exception cref="T:System.NotSupportedException"> /// The conversion cannot be performed. /// </exception> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { object convertedValue = null; var stringValue = value as string; if (stringValue != null) { convertedValue = new PrivateString { PrivateValue = stringValue }; } return(convertedValue); }
public void PlusOperatorAddsPrivateValue() { PrivateArguments args = "test args"; args += new PrivateString { PrivateValue = "value" }; Assert.AreEqual(2, args.Count); Assert.AreEqual("test args ********", args.ToString()); }