Пример #1
0
		/// <summary>
		/// Verifies that two <see cref="Konves.Testing.InstanceProxy">InstanceProxies</see> are equal by comparing the specified public and non-public properties. The assertion fails if the objects are not equal.
		/// </summary>
		/// <param name="expected">The first object to compare.  This is the obejct the unit test expects and is proxied by an <see cref="Konves.Testing.InstanceProxy">InstanceProxy</see>.</param>
		/// <param name="actual">The second object to compare. This is the object the unit test produced and is proxied by an <see cref="Konves.Testing.InstanceProxy">InstanceProxy</see>.</param>
		/// <param name="properties">The properties to compare.  If the array is <c>null</c> or does not contain any elements, all public and non-public properties are compared.</param>
		/// <exception cref="Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException"><paramref name="expected"/> is not equal to <paramref name="actual"/>.</exception>
		public static void AreEqual(InstanceProxy expected, InstanceProxy actual, params string[] properties)
		{
			if (properties == null || properties.Length == 0)
				properties = actual.Type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Select(p => p.Name).ToArray();

			foreach (string name in properties)
			{
				object a = expected.GetValue(name, null);
				object b = actual.GetValue(name, null);

				if (!NullSafeEquals(a, b))
					throw new AssertFailedException(string.Format("ProxyAssert.AreEqual failed at property '{0}'. Expected:<{1}>. Actual:<{2}>.", name, a, b));
			}
		}
Пример #2
0
		/// <summary>
		/// Verifies that an object proxied by an <see cref="Konves.Testing.InstanceProxy">InstanceProxy</see> is not equal to another object by comparing all public and non-public properties. The assertion fails if the objects are equal.
		/// </summary>
		/// <param name="notExpected">The first object to compare.  This is the obejct the unit test expects not to match <paramref name="actual"/> and is proxied by an <see cref="Konves.Testing.InstanceProxy">InstanceProxy</see>.</param>
		/// <param name="actual">The second object to compare. This is the object the unit test produced.</param>
		/// <exception cref="Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException"><paramref name="notExpected"/> is equal to <paramref name="actual"/>.</exception>
		public static void AreNotEqual(InstanceProxy notExpected, object actual)
		{
			AreNotEqual(notExpected, actual, null);
		}
Пример #3
0
		/// <summary>
		/// Verifies that two <see cref="Konves.Testing.InstanceProxy">InstanceProxies</see> are equal by comparing all public and non-public properties. The assertion fails if the objects are not equal.
		/// </summary>
		/// <param name="expected">The first object to compare.  This is the obejct the unit test expects and is proxied by an <see cref="Konves.Testing.InstanceProxy">InstanceProxy</see>.</param>
		/// <param name="actual">The second object to compare. This is the object the unit test produced and is proxied by an <see cref="Konves.Testing.InstanceProxy">InstanceProxy</see>.</param>
		/// <exception cref="Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException"><paramref name="expected"/> is not equal to <paramref name="actual"/>.</exception>
		public static void AreEqual(InstanceProxy expected, InstanceProxy actual)
		{
			AreEqual(expected, actual, null);
		}