public void PublicValueReturnsMask() { var value = "testData"; var privateString = new PrivateString { PrivateValue = value }; Assert.AreNotEqual(value, privateString); }
public void ToStringReturnsPrivateDataInPrivateMode() { var value = "testData"; var privateString = new PrivateString { PrivateValue = value }; var actual = privateString.ToString(SecureDataMode.Private); Assert.AreEqual(value, actual); }
public void ToStringReturnsPublicData() { var value = "testData"; var privateString = new PrivateString { PrivateValue = value }; var actual = privateString.ToString(); Assert.AreNotEqual(value, actual); }
/// <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 ConstructorStoresValue() { var value = "testData"; var privateString = new PrivateString(value); Assert.AreEqual(value, privateString.PrivateValue); }