1 // 2 // MonoTests.System.Security.Cryptography.Xml.AssertCrypto.cs 3 // 4 // Author: 5 // Sebastien Pouliot <sebastien@ximian.com> 6 // 7 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) 8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com) 9 // 10 // Licensed to the .NET Foundation under one or more agreements. 11 // See the LICENSE file in the project root for more information. 12 13 using Xunit; 14 15 namespace System.Security.Cryptography.Xml.Tests 16 { 17 18 public class AssertCrypto 19 { 20 21 // because most crypto stuff works with byte[] buffers AssertEquals(string msg, byte[] array1, byte[] array2)22 public static void AssertEquals(string msg, byte[] array1, byte[] array2) 23 { 24 if ((array1 == null) && (array2 == null)) 25 return; 26 Assert.NotNull(array1); 27 Assert.NotNull(array2); 28 29 bool a = (array1.Length == array2.Length); 30 if (a) 31 { 32 for (int i = 0; i < array1.Length; i++) 33 { 34 if (array1[i] != array2[i]) 35 { 36 a = false; 37 break; 38 } 39 } 40 } 41 msg += " -> Expected " + BitConverter.ToString(array1, 0); 42 msg += " is different than " + BitConverter.ToString(array2, 0); 43 Assert.True(a, msg); 44 } 45 46 private const string xmldsig = " xmlns=\"http://www.w3.org/2000/09/xmldsig#\""; 47 48 // not to be used to test C14N output AssertXmlEquals(string msg, string expected, string actual)49 public static void AssertXmlEquals(string msg, string expected, string actual) 50 { 51 expected = expected.Replace(xmldsig, String.Empty); 52 actual = actual.Replace(xmldsig, String.Empty); 53 Assert.Equal(expected, actual); 54 } 55 } 56 } 57