Deserialize() public method

public Deserialize ( string packageContents ) : EmailPackage
packageContents string
return EmailPackage
        public void EmailPackageSerialiser_CanSerialiseAndDeserialiseIntoEqualObject()
        {
            EmailPackageSerialiser serialiser = new EmailPackageSerialiser();
            var package = serialiser.Deserialize(File.ReadAllText("SampleEmailPackage.xml"));
            var serialised = serialiser.Serialise(package);
            var deserialised = serialiser.Deserialize(serialised);

            foreach(var propertyInfo in typeof(EmailPackage).GetProperties())
            {
                object expected = propertyInfo.GetValue(package, null);
                object actual = propertyInfo.GetValue(deserialised, null);

                Assert.AreEqual(expected, actual);
            }
        }
        public void EmailPackageSerialiser_CanSerialiseAndDeserialiseIntoEqualObject()
        {
            EmailPackageSerialiser serialiser = new EmailPackageSerialiser();
            var expected = serialiser.Deserialize(File.ReadAllText("SampleEmailPackage.xml"));
            var serialised = serialiser.Serialise(expected);
            var actual = serialiser.Deserialize(serialised);

            Assert.That(actual.To[0].EmailAddress, Is.EqualTo(expected.To[0].EmailAddress));
            Assert.That(actual.To[0].Name, Is.EqualTo(expected.To[0].Name));
               Assert.That(actual.Attachments[0].Path, Is.EqualTo(expected.Attachments[0].Path));
            Assert.That(actual.From, Is.EqualTo(expected.From));
            Assert.That(actual.Subject, Is.EqualTo(expected.Subject));
            Assert.That(actual.Html, Is.EqualTo(expected.Html));
            Assert.That(actual.Text, Is.EqualTo(expected.Text));
        }
        public void EmailPackageSerialiser_Deserialisation_CanHydrateAnEmailPackage()
        {
            EmailPackageSerialiser serialiser = new EmailPackageSerialiser();
            var package = serialiser.Deserialize(File.ReadAllText("SampleEmailPackage.xml"));

            Assert.That(package.From, Is.EqualTo("*****@*****.**"));
            Assert.That(package.Subject, Is.EqualTo("test email subject: {subjectToken}"));
            Assert.That(package.To, Has.Count.EqualTo(1));
            Assert.That(package.To, Has.Some.StringMatching("*****@*****.**"));
            Assert.That(package.Html.Trim(), Is.StringContaining(@"<p>html body</p>"));
            Assert.That(package.Text.Trim(), Is.StringContaining(@"text body"));
            Assert.That(package.Attachments, Has.Count.EqualTo(1));
            Assert.That(package.Attachments, Has.Some.StringContaining("D:\\workspace\\git\\EmailSystem\\EmailRelay.App.Tests.Unit\\attachment.jpg"));
        }
        public void EmailPackageSerialiser_Deserialisation_CanHydrateAnEmailPackage()
        {
            EmailPackageSerialiser serialiser = new EmailPackageSerialiser();
            var package = serialiser.Deserialize(File.ReadAllText("SampleEmailPackage.xml"));

            Assert.That(package.From, Is.EqualTo("*****@*****.**"));
            Assert.That(package.Subject, Is.EqualTo("test email subject: {subjectToken}"));
            Assert.That(package.To, Has.Count.EqualTo(1));
            Assert.That(package.To, Has.Some.InstanceOf<Recipient>().With.Property("EmailAddress").StringMatching("*****@*****.**"));
            Assert.That(package.Html.Trim(), Is.StringContaining(@"<p>html body</p>"));
            Assert.That(package.Text.Trim(), Is.StringContaining(@"text body"));
            Assert.That(package.Attachments, Has.Count.EqualTo(1));
            Assert.That(package.Attachments,
                        Has.Some.InstanceOf<Attachment>().With.Property("Path").StringContaining(@"attachment.jpg"));
        }