- ROP_IDE.zip
- Clifton.Collections.Generic
- Clifton.Data
- Clifton.Services
- Clifton.Tools.Data
- Clifton.Tools.Strings
- Clifton.Windows.Forms
- DataSetDataProvider
- IDE
- Interfaces.UI
- Myxaml 2.0
- MyXaml.Core
- MyXaml.WinForms
- ROPLib.Data
- ROPLib.Graphing
- ROPLib.Interfaces
- ROPLib.RendererInterfaces
- ROPLib.Reporting
- ROPLib.UIEvents
- ROPLib.UIRendering
- ROPLib
- SQLLiteDataProvider
- UI.DotNet
- UI.DX
- UnitTest
- XTreeInterfaces
|
using System;
using System.IO;
using System.Runtime.InteropServices;
using Clifton.Tools.Data;
using Vts.UnitTest;
namespace UnitTests
{
[TestFixture]
public class BoxedValueTests
{
MemoryStream ms;
RawSerializer rs;
RawDeserializer rd;
[SetUp]
public void Setup()
{
ms = new MemoryStream();
rs = new RawSerializer(ms);
rd = new RawDeserializer(ms);
}
[Test]
public void Bool()
{
bool b = true;
rs.Serialize((object)b);
rs.Flush();
ms.Position = 0;
b = rd.DeserializeBool();
Assertion.Assert(b, "bool failed");
}
[Test]
public void Byte()
{
byte val = byte.MaxValue;
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeByte();
Assertion.Assert(val == byte.MaxValue, "byte failed");
}
[Test]
public void Char()
{
char val = char.MaxValue;
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeChar();
Assertion.Assert(val == char.MaxValue, "char failed");
}
[Test]
public void Decimal()
{
decimal val = decimal.MaxValue;
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeDecimal();
Assertion.Assert(val == decimal.MaxValue, "decimal failed");
}
[Test]
public void Double()
{
double val = double.MaxValue;
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeDouble();
Assertion.Assert(val == double.MaxValue, "double failed");
}
[Test]
public void Short()
{
short val = short.MaxValue;
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeShort();
Assertion.Assert(val == short.MaxValue, "short failed");
}
[Test]
public void Int()
{
int val = int.MaxValue;
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeInt();
Assertion.Assert(val == int.MaxValue, "int failed");
}
[Test]
public void Long()
{
long val = long.MaxValue;
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeLong();
Assertion.Assert(val == long.MaxValue, "long failed");
}
[Test]
public void Sbyte()
{
sbyte val = sbyte.MaxValue;
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeSByte();
Assertion.Assert(val == sbyte.MaxValue, "sbyte failed");
}
[Test]
public void Float()
{
float val = float.MaxValue;
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeFloat();
Assertion.Assert(val == float.MaxValue, "float failed");
}
[Test]
public void String()
{
string val = "Hello World";
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeString();
Assertion.Assert(val == "Hello World", "string failed");
}
[Test]
public void Ushort()
{
ushort val = ushort.MaxValue;
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeUShort();
Assertion.Assert(val == ushort.MaxValue, "ushort failed");
}
[Test]
public void Uint()
{
uint val = uint.MaxValue;
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeUInt();
Assertion.Assert(val == uint.MaxValue, "uint failed");
}
[Test]
public void Ulong()
{
ulong val = ulong.MaxValue;
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeULong();
Assertion.Assert(val == ulong.MaxValue, "ulong failed");
}
[Test]
public void GuidStruct()
{
Guid val = Guid.NewGuid();
Guid saveGuid = val;
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeGuid();
Assertion.Assert(val == saveGuid, "guid failed");
}
[Test]
public void DateTimeStruct()
{
DateTime val = DateTime.Now;
DateTime saveDateTime = val;
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeDateTime();
Assertion.Assert(val == saveDateTime, "DateTime failed");
}
[Test]
public void ByteArray()
{
byte[] val = new byte[4] { 1, 2, 3, 4 };
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeBytes();
Assertion.Assert((val[0] == 1) && (val[1] == 2) && (val[2] == 3) && (val[3] == 4), "byte[] failed");
}
[Test]
public void CharArray()
{
char[] val = new char[4] { 'a', 'b', 'c', 'd' };
rs.Serialize((object)val);
rs.Flush();
ms.Position = 0;
val = rd.DeserializeChars();
Assertion.Assert((val[0] == 'a') && (val[1] == 'b') && (val[2] == 'c') && (val[3] == 'd'), "char[] failed");
}
}
}
|
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.