|
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using AltSerialize;
using NUnit.Framework;
namespace AltSerializeTest
{
[TestFixture]
public class TestValueTypes : SerializerTestBase
{
public override string Name
{
get { return "Value Type Test"; }
}
#region Tests
[Test]
public void ValueTypeTest()
{
foreach (Type type in ValueTypes)
{
DebugOut("Testing type " + type.FullName);
object defaultType = Activator.CreateInstance(type);
SerializeObject(defaultType);
FieldInfo[] fields = type.GetFields();
foreach (FieldInfo field in fields)
{
if (field.IsStatic == false || field.FieldType != type) continue;
object valueObject = field.GetValue(null);
object resultObject = SerializeObject(valueObject);
Assert.IsTrue(resultObject.Equals(valueObject), "Failed on type " + valueObject.GetType().FullName);
}
}
}
[Test]
public void TypeTest()
{
DebugOut("Testing System.Type");
Type type = typeof(int);
object resultObject = SerializeObject(type);
Assert.IsTrue(resultObject.Equals(type));
type = typeof(SerializerTestBase);
DebugOut("Testing " + type.FullName);
resultObject = SerializeObject(type);
Assert.IsTrue(resultObject.Equals(type));
}
#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.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
I've been writing code since I started learning BASIC on the Apple //c. Since then, I've learned C, C++, a few assembly languages. I went to college for Computer Science and Mathematics at the University of Texas at Dallas.