public unsafe void UnsafeConstructor () { try { SecureString ss = null; char[] data = new char[] { 'a', 'b', 'c' }; fixed (char* p = &data[0]) { ss = new SecureString (p, data.Length); } Assert.IsFalse (ss.IsReadOnly (), "IsReadOnly"); Assert.AreEqual (3, ss.Length, "3"); ss.AppendChar ('a'); Assert.AreEqual (4, ss.Length, "4"); ss.Clear (); Assert.AreEqual (0, ss.Length, "0b"); ss.InsertAt (0, 'b'); Assert.AreEqual (1, ss.Length, "1b"); ss.SetAt (0, 'c'); Assert.AreEqual (1, ss.Length, "1c"); ss.RemoveAt (0); Assert.AreEqual (0, ss.Length, "0c"); ss.Dispose (); } catch (NotSupportedException) { Assert.Ignore (NotSupported); } }
public void DefaultConstructor () { try { SecureString ss = new SecureString (); Assert.IsFalse (ss.IsReadOnly (), "IsReadOnly"); Assert.AreEqual (0, ss.Length, "0"); ss.AppendChar ('a'); Assert.AreEqual (1, ss.Length, "1"); ss.Clear (); Assert.AreEqual (0, ss.Length, "0b"); ss.InsertAt (0, 'b'); Assert.AreEqual (1, ss.Length, "1b"); ss.SetAt (0, 'c'); Assert.AreEqual (1, ss.Length, "1c"); Assert.AreEqual ("System.Security.SecureString", ss.ToString (), "ToString"); ss.RemoveAt (0); Assert.AreEqual (0, ss.Length, "0c"); ss.Dispose (); } catch (NotSupportedException) { Assert.Ignore (NotSupported); } }
public void SetAt_BiggerThanLength () { SecureString ss = new SecureString (); ss.SetAt (1, 'a'); }
public void SetAt_Negative () { SecureString ss = new SecureString (); ss.SetAt (-1, 'a'); }