Files
Umbraco-CMS/tests/Umbraco.Tests.UnitTests/Umbraco.Core/ReflectionTests.cs

40 lines
1022 B
C#
Raw Normal View History

// Copyright (c) Umbraco.
// See LICENSE for more details.
using System;
using System.Linq;
2017-09-27 21:16:09 +02:00
using NUnit.Framework;
using Umbraco.Extensions;
2017-09-27 21:16:09 +02:00
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core
2017-09-27 21:16:09 +02:00
{
[TestFixture]
public class ReflectionTests
{
[Test]
public void GetBaseTypesIsOk()
{
// tests that the GetBaseTypes extension method works.
Type type = typeof(Class2);
Type[] types = type.GetBaseTypes(true).ToArray();
2017-09-27 21:16:09 +02:00
Assert.AreEqual(3, types.Length);
Assert.Contains(typeof(Class2), types);
Assert.Contains(typeof(Class1), types);
Assert.Contains(typeof(object), types);
types = type.GetBaseTypes(false).ToArray();
Assert.AreEqual(2, types.Length);
Assert.Contains(typeof(Class1), types);
Assert.Contains(typeof(object), types);
}
2020-05-03 15:28:56 +01:00
private class Class1
2017-09-27 21:16:09 +02:00
{
}
2020-05-03 15:28:56 +01:00
private class Class2 : Class1
2017-09-27 21:16:09 +02:00
{
}
}
}