ln.types/test/Test.cs

41 lines
1.3 KiB
C#

// /**
// * File: Test.cs
// * Author: haraldwolff
// *
// * This file and it's content is copyrighted by the Author and / or copyright holder.
// * Any use wihtout proper permission is illegal and may lead to legal actions.
// *
// *
// **/
using System;
using System.Reflection;
namespace ln.types.test
{
public static class Test
{
public static bool FieldsAreEqual(object expected,object test)
{
if (!expected.GetType().Equals(test.GetType()))
return false;
foreach (FieldInfo fieldInfo in expected.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
{
if (fieldInfo.FieldType.IsArray)
{
if (!Extensions.AreEqual<object>(fieldInfo.GetValue(expected) as object[], fieldInfo.GetValue(test) as object[]))
{
return false;
}
} else if (!Equals(fieldInfo.GetValue(expected), fieldInfo.GetValue(test)))
{
Console.WriteLine("Type={0} Field={1} {2}!={3}", expected.GetType().Name, fieldInfo.Name, fieldInfo.GetValue(expected), fieldInfo.GetValue(test));
return false;
}
}
return true;
}
}
}