|
using System;
using System.Reflection;
using Catel.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Catel.Test.Reflection
{
/// <summary>
/// Summary description for AssemblyInfoTest
/// </summary>
[TestClass]
public class AssemblyExtensionsTest
{
/// <summary>
/// Checks the title of the assembly automatically.
/// </summary>
[TestMethod]
public void TitleAutomatic()
{
// Declare variables
#if SILVERLIGHT
string expected = "Catel.Silverlight.Test";
#else
string expected = "Catel.Test";
#endif
string result = string.Empty;
// Call function
result = MethodBase.GetCurrentMethod().DeclaringType.Assembly.Title();
// Validate result
Assert.AreEqual(expected, result);
}
/// <summary>
/// Checks the version of the assembly automatically.
/// </summary>
[TestMethod]
public void VersionAutomatic()
{
// Declare variables
string expected = "1.0.0.0";
string result = string.Empty;
// Call function
result = MethodBase.GetCurrentMethod().DeclaringType.Assembly.Version();
// Validate result
Assert.AreEqual(expected, result);
}
/// <summary>
/// Checks the version with a specified separator of the assembly automatically.
/// </summary>
[TestMethod]
public void VersionWithSeparatorAutomatic()
{
// Declare variables
string expected = "1.0";
string result = string.Empty;
// Call function
result = MethodBase.GetCurrentMethod().DeclaringType.Assembly.Version(1);
// Validate result
Assert.AreEqual(expected, result);
}
/// <summary>
/// Checks the version with a specified separator of the assembly automatically.
/// </summary>
[TestMethod]
public void VersionWithSeparatorAutomaticWhereSeparatorCountIsTooHigh()
{
// Declare variables
string expected = "1.0.0.0";
string result = string.Empty;
// Call function
result = MethodBase.GetCurrentMethod().DeclaringType.Assembly.Version(8);
// Validate result
Assert.AreEqual(expected, result);
}
/// <summary>
/// Checks the informational version of the assembly automatically.
/// </summary>
[TestMethod]
public void InformationalVersionAutomatic()
{
// Declare variables
Version expected = new Version("1.0");
Version result = null;
// Call function
result = MethodBase.GetCurrentMethod().DeclaringType.Assembly.InformationalVersion();
// Validate result
Assert.AreEqual(expected, result);
}
/// <summary>
/// Checks the description of the assembly automatically.
/// </summary>
[TestMethod]
public void DescriptionAutomatic()
{
// Declare variables
#if SILVERLIGHT
string expected = "Catel Silverlight test library";
#else
string expected = "Catel test library";
#endif
string result = string.Empty;
// Call function
result = MethodBase.GetCurrentMethod().DeclaringType.Assembly.Description();
// Validate result
Assert.AreEqual(expected, result);
}
/// <summary>
/// Checks the product of the assembly automatically.
/// </summary>
[TestMethod]
public void ProductAutomatic()
{
// Declare variables
#if SILVERLIGHT
string expected = "Catel.Silverlight.Test";
#else
string expected = "Catel.Test";
#endif
string result = string.Empty;
// Call function
result = MethodBase.GetCurrentMethod().DeclaringType.Assembly.Product();
// Validate result
Assert.AreEqual(expected, result);
}
/// <summary>
/// Checks the copyright of the assembly automatically.
/// </summary>
[TestMethod]
public void CopyrightAutomatic()
{
// Declare variables
string expected = "Copyright © CatenaLogic 2010 - 2011";
string result = string.Empty;
// Call function
result = MethodBase.GetCurrentMethod().DeclaringType.Assembly.Copyright();
// Validate result
Assert.AreEqual(expected, result);
}
/// <summary>
/// Checks the company of the assembly automatically.
/// </summary>
[TestMethod]
public void CompanyAutomatic()
{
// Declare variables
string expected = "CatenaLogic";
string result = string.Empty;
// Call function
result = MethodBase.GetCurrentMethod().DeclaringType.Assembly.Company();
// Validate result
Assert.AreEqual(expected, result);
}
#if !SILVERLIGHT
[TestMethod]
public void PathAutomatic()
{
// Declare variables
string result = string.Empty;
// Current directory
string currentDirectory = Environment.CurrentDirectory;
string outputDirectory = Catel.IO.Path.GetFullPath("..\\..\\..\\..\\", currentDirectory);
// Call function
Assembly assembly = Assembly.LoadFrom(Catel.IO.Path.Combine(outputDirectory, "Catel.Core.dll"));
result = Catel.IO.Path.AppendTrailingSlash(assembly.Path());
// Validate result
Assert.AreEqual(outputDirectory, result);
}
#endif
}
}
|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.