|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using HAKGERSoft;
using NUnit.Framework;
using System.Diagnostics;
namespace HAKGERSoft {
public class HClonerTestObjectAttribute: Attribute {
}
[TestFixture]
public class AutoTest {
[Test]
public void ProcessTestObjects() {
List<object> testObjects=new List<object>();
Type[] types=Assembly.GetExecutingAssembly().GetTypes();
foreach(Type type in types){
object[] attribs=type.GetCustomAttributes(typeof(HClonerTestObjectAttribute),false);
if(attribs.Length>0) {
object newObject=Activator.CreateInstance(type);
testObjects.Add(newObject);
}
}
Debug.WriteLine("AutoTest + objects to diff :"+testObjects.Count.ToString());
foreach(var obj in testObjects){
var copy=HCloner.DeepCopy(obj);
Differ.Check(obj,copy);
}
}
[Test]
public void ProcessCLSObjects() {
CheckCLSType(0);
CheckCLSType(6);
CheckCLSType("abba");
CheckCLSType(new long[] {435343,54634,4356546});
CheckCLSType(new List<List<List<int>>>());
CheckCLSType(new Dictionary<string,int>(){{"a",1}});
CheckCLSType(new ArgumentNullException());
//CheckCLSType(new System.Text.RegularExpressions.Regex("d"));
}
void CheckCLSType<T>(T obj) {
T copy=HCloner.DeepCopy<T>(obj);
Differ.Check(obj,copy);
}
}
}
|
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.