Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception Tests #8

Open
Grauenwolf opened this issue Jun 2, 2021 · 0 comments
Open

Exception Tests #8

Grauenwolf opened this issue Jun 2, 2021 · 0 comments

Comments

@Grauenwolf
Copy link
Owner

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.");
	}

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant