Tortuga-TestMonkey icon indicating copy to clipboard operation
Tortuga-TestMonkey copied to clipboard

Exception Tests

Open Grauenwolf opened this issue 3 years ago • 0 comments

public partial class @Test.ClassName
{

    @Tag("Exception")
	@TestAttribute
	public void @(Test.ClassName + "_Exception_Serializer")()
	{
		var objectUnderTest = CreateObject();

		var formatter = new BinaryFormatter();
		var stream = new MemoryStream();
		formatter.Serialize(stream, objectUnderTest);
		stream.Seek(0, SeekOrigin.Begin);

		var newObject = (@Class.FullName)formatter.Deserialize(stream);
		Assert.AreEqual(objectUnderTest.Message, newObject.Message, "Message is incorrect.");
	}

public partial class @Test.ClassName
{

    @Tag("Exception")
	@TestAttribute
	public void @(Test.ClassName + "_Exception_DataContractSerializer")()
	{
		var objectUnderTest = CreateObject();

		var stream = new MemoryStream();
		var serializer = new DataContractSerializer(typeof(@Class.FullName));
		serializer.WriteObject(stream, objectUnderTest);
		stream.Seek(0, SeekOrigin.Begin);

		var result = (@Class.FullName)serializer.ReadObject(stream);
		Assert.AreEqual(objectUnderTest.Message, newObject.Message, "Message is incorrect.");
	}

}

Grauenwolf avatar Jun 02 '21 01:06 Grauenwolf