Click here to Skip to main content
15,885,244 members
Articles / Programming Languages / C# 4.0

Relationship Oriented Programming - The IDE plus More on Agile Project Management

Rate me:
Please Sign up or sign in to vote.
4.98/5 (25 votes)
12 Mar 2012CPOL81 min read 77.5K   1.2K   49  
An Integrated Development Environment (IDE) for the Relationship Oriented Programming Tool.
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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Interacx
United States United States
Blog: https://marcclifton.wordpress.com/
Home Page: http://www.marcclifton.com
Research: http://www.higherorderprogramming.com/
GitHub: https://github.com/cliftonm

All my life I have been passionate about architecture / software design, as this is the cornerstone to a maintainable and extensible application. As such, I have enjoyed exploring some crazy ideas and discovering that they are not so crazy after all. I also love writing about my ideas and seeing the community response. As a consultant, I've enjoyed working in a wide range of industries such as aerospace, boatyard management, remote sensing, emergency services / data management, and casino operations. I've done a variety of pro-bono work non-profit organizations related to nature conservancy, drug recovery and women's health.

Comments and Discussions