#region CPL License
/*
Nuclex Framework
Copyright (C) 2002-2010 Nuclex Development Labs
This library is free software; you can redistribute it and/or
modify it under the terms of the IBM Common Public License as
published by the IBM Corporation; either version 1.0 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
IBM Common Public License for more details.
You should have received a copy of the IBM Common Public
License along with this library
*/
#endregion
#if UNITTEST
using System;
using System.Reflection;
using NUnit.Framework;
namespace Nuclex.Support.Cloning {
/// Unit Test for the cloner helpers
[TestFixture]
internal class ClonerHelpersTest {
#region class Base
/// Base class used to test the helper methods
private class Base {
/// A simple public field
public int PublicBaseField;
/// An automatic property with a hidden backing field
public int PublicBaseProperty { get; set; }
}
#endregion // class Base
#region class Derived
/// Derived class used to test the helper methods
private class Derived : Base {
/// A simple public field
public int PublicDerivedField;
/// An automatic property with a hidden backing field
public int PublicDerivedProperty { get; set; }
}
#endregion // class Derived
///
/// Verifies that the GetFieldInfosIncludingBaseClasses() will include the backing
/// fields of automatically implemented properties in base classes
///
[Test]
public void CanGetBackingFieldsForPropertiesInBaseClasses() {
FieldInfo[] fieldInfos = ClonerHelpers.GetFieldInfosIncludingBaseClasses(
typeof(Derived), BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance
);
Assert.AreEqual(4, fieldInfos.Length);
}
}
} // namespace Nuclex.Support.Cloning
#endif // UNITTEST