Exemplo n.º 1
0
        private AuthProperty PtrToAuthProperty(IntPtr authPropertyPtr)
        {
            var nativeAuthProperty = (NativeAuthProperty)Marshal.PtrToStructure(authPropertyPtr, typeof(NativeAuthProperty));
            var name       = Marshal.PtrToStringAnsi(nativeAuthProperty.Name);
            var valueBytes = new byte[(int)nativeAuthProperty.ValueLength];

            Marshal.Copy(nativeAuthProperty.Value, valueBytes, 0, (int)nativeAuthProperty.ValueLength);
            return(AuthProperty.CreateUnsafe(name, valueBytes));
        }
Exemplo n.º 2
0
 private AuthProperty PtrToAuthProperty(IntPtr authPropertyPtr)
 {
     #pragma warning disable 0618
     // We need to use the obsolete non-generic version of Marshal.PtrToStructure, because the generic version is not available in net45
     var nativeAuthProperty = (NativeAuthProperty)Marshal.PtrToStructure(authPropertyPtr, typeof(NativeAuthProperty));
     #pragma warning restore 0618
     var name       = Marshal.PtrToStringAnsi(nativeAuthProperty.Name);
     var valueBytes = new byte[(int)nativeAuthProperty.ValueLength];
     Marshal.Copy(nativeAuthProperty.Value, valueBytes, 0, (int)nativeAuthProperty.ValueLength);
     return(AuthProperty.CreateUnsafe(name, valueBytes));
 }
Exemplo n.º 3
0
        public void CreateUnsafe()
        {
            var valueBytes   = new byte[] { 68, 69, 70 };
            var authProperty = AuthProperty.CreateUnsafe("abc", valueBytes);

            Assert.AreEqual("abc", authProperty.Name);
            Assert.AreSame(valueBytes, authProperty.ValueBytesUnsafe);
            Assert.AreNotSame(valueBytes, authProperty.ValueBytes);
            CollectionAssert.AreEqual(valueBytes, authProperty.ValueBytes);
            CollectionAssert.AreEqual(valueBytes, authProperty.ValueBytesUnsafe);
            Assert.AreEqual("DEF", authProperty.Value);
        }
Exemplo n.º 4
0
 public void Create_ValueIsNotNull()
 {
     Assert.Throws(typeof(ArgumentNullException), () => AuthProperty.Create("abc", null));
     Assert.Throws(typeof(ArgumentNullException), () => AuthProperty.CreateUnsafe("abc", null));
 }
Exemplo n.º 5
0
 public void Create_NameIsNotNull()
 {
     Assert.Throws(typeof(ArgumentNullException), () => AuthProperty.Create(null, new byte[0]));
     Assert.Throws(typeof(ArgumentNullException), () => AuthProperty.CreateUnsafe(null, new byte[0]));
 }