- nantgenie-12305.zip
- Agile
- Agile.Common
- Components
- nunit.framework.dll
- Silverlight
- Blacklight.Silverlight.Controls.dll
- Unity
- Wintellect
- Wintellect.Threading.CompactFx.dll
- Wintellect.Threading.CompactFx.pdb
- Wintellect.Threading.CompactFx.XML
- Wintellect.Threading.dll
- Wintellect.Threading.pdb
- Wintellect.Threading.Silverlight.dll
- Wintellect.Threading.Silverlight.pdb
- Wintellect.Threading.Silverlight.XML
- Wintellect.Threading.XML
- Descriptors
- Descriptors
- GeneratorDetails
- Generators
- Generator.Tests
- Generators
- NantGenie.sln
- NantGenie
|
// WARNING: This file has been generated. Any manual changes must be made within preserved regions or they will be lost.
//===============================================================================
//
// TypesTests
//
// PURPOSE:
// Tests the functionality of Types.
//
// NOTES:
//
//
//===============================================================================
//
// Copyright (C) 2003 Wallis Software Solutions
// All rights reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
// FITNESS FOR A PARTICULAR PURPOSE.
//
//===============================================================================
using System.Reflection;
using Agile.Common.Reflections;
using Agile.Common.Reflections.Tests;
using Agile.Common.Testing;
using Agile.Common.UI;
using NUnit.Framework;
namespace Agile.Common.Tests
{
/// <summary>
/// Tests the functionality of Types.
/// </summary>
[TestFixture]
public class TypesTests
{
/// <summary>
/// Verifies ContainsTypeNamed returns true when a type exists in an Assembly
/// - Get the Common Assembly
/// - Check ContainsTypeNamed returns true for Asserts
/// - Check ContainsTypeNamed returns true for Strings
/// - Check ContainsTypeNamed returns false for FakeClassForTest
/// </summary>
[Test]
public void ContainsTypeNamedTests()
{
// Get the Common Assembly
Assembly commonAssembly = Assemblies.GetAssemblyNamed(Assemblies.Instance.OurAssemblies
, "Agile.Common");
// Check ContainsTypeNamed returns true for Asserts
Assert.IsTrue(Types.ContainsTypeNamed(commonAssembly, "Dates")
, "Check ContainsTypeNamed returns true for Dates");
// Check ContainsTypeNamed returns true for Strings
Assert.IsTrue(Types.ContainsTypeNamed(commonAssembly, "Strings")
, "Check ContainsTypeNamed returns true for Strings");
// Check ContainsTypeNamed returns false for FakeClassForTest
Assert.IsFalse(Types.ContainsTypeNamed(commonAssembly, "FakeClassForTest")
, "Check ContainsTypeNamed returns true for FakeClassForTest");
}
/// <summary>
/// Verifies we can load all types in an assembly that implement
/// a specific Type.
/// - Check the collection contains AssembliesTester
/// - Check the collection contains AssembliesTesterChild
/// - Check the collection DOES NOT contain AssembliesTesterAbstract
/// - Now include abstract classes
/// - Check the collection NOW DOES contain AssembliesTesterAbstract
/// </summary>
[Test]
public void GetAllSubClassesOfTests()
{
AgileTypeCollection agileTypes = Types.GetAllSubClassesOf(Assemblies.Instance.OurAssemblies
, typeof (AgileCollection), false);
// Check the collection contains AssembliesTester
Assert.IsTrue(agileTypes.Contains(typeof (AssembliesTester))
, "Check the collection contains AssembliesTester");
// Check the collection contains AssembliesTesterChild
Assert.IsTrue(agileTypes.Contains(typeof (AssembliesTesterChild))
, "Check the collection contains AssembliesTesterChild");
// Check the collection DOES NOT contain AssembliesTesterAbstract
Assert.IsFalse(agileTypes.Contains(typeof (AssembliesTesterAbstract))
, "Check the collection contains AssembliesTesterAbstract");
// Now include abstract classes
agileTypes = Types.GetAllSubClassesOf(Assemblies.Instance.OurAssemblies
, typeof (AgileCollection), true);
// Check the collection NOW DOES contain AssembliesTesterAbstract
Assert.IsTrue(agileTypes.Contains(typeof (AssembliesTesterAbstract))
, "Check the collection contains AssembliesTesterAbstract");
}
/// <summary>
/// Verifies GetClassesImpementing returns all classes implementing a particular interface.
/// - Create a collection of types using GetClassesImpementing, find classes implementing IAgileControlDetails
/// - Check the collection contains Widget
/// - Check the collection contains WidgetSubClass (which does implement the interface itself, but its base class does).
/// </summary>
[Test]
public void GetClassesImpementingTests()
{
// Create a collection of types using GetClassesImpementing, find classes implementing IAgileControlDetails
AgileTypeCollection factories = Types.GetClassesImpementing(Assemblies.Instance.OurAssemblies
, typeof (IAgileControlDetails));
// Check the collection contains Widget
Assert.IsTrue(factories.Contains(typeof (Widget)), "Check the collection contains Widget");
// Check the collection contains WidgetSubClass (which does implement the interface itself, but its base class does).
Assert.IsTrue(factories.Contains(typeof (WidgetSubClass)), "Check the collection contains WidgetSubClass");
}
/// <summary>
/// Verifies the functionality of the IsDecendantOf method
/// - Check IsDecendantOf returns true for AssembliesTester as a decendant of AgileCollection
/// - Check IsDecendantOf returns true for AssembliesTesterChild as a decendant of AgileCollection
/// </summary>
[Test]
public void IsDecendantOfTests()
{
// Check IsDecendantOf returns true for AssembliesTester as a decendant of AgileCollection
Assert.IsTrue(Types.IsDecendantOf(typeof (AssembliesTester), typeof (AgileCollection))
, "Check IsDecendantOf returns true for AssembliesTester as a decendant of AgileCollection");
// Check IsDecendantOf returns true for AssembliesTesterChild as a decendant of AgileCollection
Assert.IsTrue(Types.IsDecendantOf(typeof (AssembliesTesterChild), typeof (AgileCollection))
,
"Check IsDecendantOf returns true for AssembliesTesterChild as a decendant of AgileCollection");
}
/// <summary>
/// Verifies the functionality of the IsDirectDecendantOf method
/// - Check IsDirectDecendantOf returns true for AssembliesTester as a decendant of AgileCollection
/// - Check IsDirectDecendantOf returns FALSE for AssembliesTesterChild as a decendant of AgileCollection
/// </summary>
[Test]
public void IsDirectDecendantOfTests()
{
// Check IsDirectDecendantOf returns true for AssembliesTester as a decendant of AgileCollection
Assert.IsTrue(Types.IsDirectDecendantOf(typeof (AssembliesTester), typeof (AgileCollection))
,
"Check IsDirectDecendantOf returns true for AssembliesTester as a decendant of AgileCollection");
// Check IsDirectDecendantOf returns false for AssembliesTesterChild as a decendant of AgileCollection
Assert.IsFalse(Types.IsDirectDecendantOf(typeof (AssembliesTesterChild), typeof (AgileCollection))
,
"Check IsDirectDecendantOf returns true for AssembliesTesterChild as a decendant of AgileCollection");
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I live in Sydney and have been a developer for almost a decade now. I have a passion for technology and a strong interest in discovering 'better, cleaner, faster' ways to get systems out the door because I believe software development takes too long. If I have an idea I want to realise it as quickly as possible...plus writing systems for someone else I want to deliver quickly so I can move onto the next interesting project!