public void TyrParse_Null_IsValid() { string str = null; Assert.IsTrue(CryptographicSeed.TryParse(str, out CryptographicSeed val), "Valid"); Assert.AreEqual(string.Empty, val.ToString(), "Value"); }
public void TyrParse_StringValue_IsNotValid() { string str = "string"; Assert.IsFalse(CryptographicSeed.TryParse(str, out CryptographicSeed val), "Valid"); Assert.AreEqual(string.Empty, val.ToString(), "Value"); }
public void TyrParse_StringValue_IsValid() { string str = "string=="; Assert.IsTrue(CryptographicSeed.TryParse(str, out CryptographicSeed val), "Valid"); Assert.AreEqual(str, val.ToString(), "Value"); }
public void Explicit_ByteArrayToCryptographicSeed_AreEqual() { CryptographicSeed exp = TestStruct; CryptographicSeed act = new Byte[] { 66, 140, 26, 138 }; Assert.AreEqual(exp, act); Assert.AreNotSame(exp, act); }
public void TyrParse_StringEmpty_IsValid() { CryptographicSeed val; string str = string.Empty; Assert.IsTrue(CryptographicSeed.TryParse(str, out val), "Valid"); Assert.AreEqual(string.Empty, val.ToString(), "Value"); }
public void TryParse_TestStructInput_AreEqual() { using (new CultureInfoScope("en-GB")) { var exp = TestStruct; var act = CryptographicSeed.TryParse(exp.ToString()); Assert.AreEqual(exp, act); } }
public void TryParse_InvalidInput_DefaultValue() { using (new CultureInfoScope("en-GB")) { var exp = default(CryptographicSeed); var act = CryptographicSeed.TryParse("!"); Assert.AreEqual(exp, act); } }
/// <summary>Converts a string to a cryptographic seed, using the specified /// context and culture information. /// </summary> /// <param name="context"> /// An System.ComponentModel.ITypeDescriptorContext that provides a format context. /// </param> /// <param name="culture"> /// The System.Globalization.CultureInfo to use as the current culture. /// </param> /// <param name="value"> /// The System.Object to convert. /// </param> /// <returns> /// An System.Object that represents the converted value. /// </returns> /// <exception cref="NotSupportedException"> /// The conversion cannot be performed. /// </exception> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var str = value as string; if (value == null || str != null) { return(CryptographicSeed.Parse(str)); } return(base.ConvertFrom(context, culture, value)); }
public void Create_UUID_BytesAreEqual() { var exp = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; Uuid id = new Guid(exp); var seed = CryptographicSeed.Create(id); var act = seed.ToByteArray(); CollectionAssert.AreEqual(exp, act); Assert.AreNotSame(exp, act); }
public void Parse_InvalidInput_ThrowsFormatException() { using (new CultureInfoScope("en-GB")) { Assert.Catch <FormatException> (() => { CryptographicSeed.Parse("!"); }, "Not a valid cryptographic seed"); } }
public void OrderByDescending_CryptographicSeed_AreEqual() { var item0 = CryptographicSeed.Create(new byte[] { 1 }); var item1 = CryptographicSeed.Create(new byte[] { 2 }); var item2 = CryptographicSeed.Create(new byte[] { 3, 6 }); var item3 = CryptographicSeed.Create(new byte[] { 4, 2 }); var inp = new List <CryptographicSeed> { CryptographicSeed.Empty, item3, item2, item0, item1, CryptographicSeed.Empty }; var exp = new List <CryptographicSeed> { item3, item2, item1, item0, CryptographicSeed.Empty, CryptographicSeed.Empty }; var act = inp.OrderByDescending(item => item).ToList(); CollectionAssert.AreEqual(exp, act); }
public void IsValid_Data_IsTrue() { Assert.IsTrue(CryptographicSeed.IsValid("ComplexPattern==")); }
public void IsValid_Data_IsFalse() { Assert.IsFalse(CryptographicSeed.IsValid("!"), "!"); Assert.IsFalse(CryptographicSeed.IsValid((String)null), "(String)null"); Assert.IsFalse(CryptographicSeed.IsValid(string.Empty), "string.Empty"); }