|
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Core;
using NUnit.Framework;
using System.Reflection;
namespace NinjaCross.Classes.Nunit.TestPerformance
{
[TestFixture]
public class NJC_TestPerformanceDescriptorTest : NJC_TestPerformanceBaseTest
{
private const String TEST_Name = "Test 1";
private const String TEST_Description = "Test description";
private const NJC_TestPerformanceTargetWriteMode TEST_OutputTargetWriteMode = NJC_TestPerformanceTargetWriteMode.Overwrite;
private const NJC_TestPerformanceTargetKind TEST_OutputTargetKind = NJC_TestPerformanceTargetKind.FileSystem;
private const NJC_TestPerformanceTargetFormat TEST_OutputTargetFormat = NJC_TestPerformanceTargetFormat.Csv;
//----------------------------------------------------------------------------
#region Test methods
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
[Test]
[ExpectedException(ExceptionType = typeof(ArgumentException))]
public void Allocation_NotNull_FailDueToMissingAttribute()
{
MethodInfo mi = (MethodInfo)MethodBase.GetCurrentMethod();
NJC_TestPerformanceDescriptor descriptor = new NJC_TestPerformanceDescriptor(mi);
}
//----------------------------------------------------------------------------
[Test]
[NJC_TestPerformanceRecorder(
TestName = TEST_Name,
TestDescription = TEST_Description,
OutputTargetWriteMode = TEST_OutputTargetWriteMode,
OutputTargetKind = TEST_OutputTargetKind,
OutputTargetFormat = TEST_OutputTargetFormat,
OutputTarget = TEST_OutputTarget)]
public void Allocation_NotNull_Success()
{
MethodInfo mi = (MethodInfo)MethodBase.GetCurrentMethod();
NJC_TestPerformanceDescriptor descriptor = new NJC_TestPerformanceDescriptor(mi);
Assert.IsTrue(descriptor.IsExecuting);
RandomSleep();
descriptor.EndTime = DateTime.Now;
Assert.IsFalse(descriptor.IsExecuting);
Assert.AreEqual(mi, descriptor.TestMethod);
Assert.Greater(descriptor.ExecutionTime.Ticks, 0);
Assert.AreEqual(TEST_Name, descriptor.TestMethodAttribute.TestName);
Assert.AreEqual(TEST_Description, descriptor.TestMethodAttribute.TestDescription);
Assert.AreEqual(TEST_OutputTargetWriteMode, descriptor.TestMethodAttribute.OutputTargetWriteMode);
Assert.AreEqual(TEST_OutputTargetKind, descriptor.TestMethodAttribute.OutputTargetKind);
Assert.AreEqual(TEST_OutputTargetFormat, descriptor.TestMethodAttribute.OutputTargetFormat);
Assert.AreEqual(TEST_OutputTarget, descriptor.TestMethodAttribute.OutputTarget);
}
//----------------------------------------------------------------------------
[Test]
[ExpectedException(ExceptionType = typeof(ArgumentNullException))]
public void Allocation_Null()
{
NJC_TestPerformanceDescriptor descriptor = new NJC_TestPerformanceDescriptor(null);
}
//----------------------------------------------------------------------------
#endregion
//----------------------------------------------------------------------------
}
}
|
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'm a senior developer in .NET, COM & Win32 and I work for an Italian company involved in e-learning and competency-analisys systems.
My work is also my main hobby, and I spend a lot of my spare time writing tutorials and codes for video games and multimedia-related arguments.