Skip to content
Prev Previous commit
Next Next commit
Ignore failling legacy test
Added legacy public class read test.
Add public class for testing.
  • Loading branch information
Rosuavio committed Jan 4, 2021
commit f3391344d0536bd6cebe0b13b821d342b90fa2dd
33 changes: 31 additions & 2 deletions UnitTests/UnitTests.UWP/Helpers/Test_StorageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,41 @@ public void Test_StorageHelper_LegacyDateTest()
Assert.AreEqual(input, output);
}

[Ignore]
[TestCategory("Helpers")]
[TestMethod]
public void Test_StorageHelper_LegacyPersonTest()
public void Test_StorageHelper_LegacyInternalClassTest()
{
string key = "Contact";

Person input = new Person() { Name = "Joe Bloggs", Age = 42 };
UI.Person input = new UI.Person() { Name = "Joe Bloggs", Age = 42 };

// simulate previous version by generating json and manually inserting it as string
string jsonInput = JsonSerializer.Serialize(input);

storageHelper.Save<string>(key, jsonInput);

// now read it as int to valid that the change works
UI.Person output = storageHelper.Read<UI.Person>(key, null);

Assert.IsNotNull(output);
Assert.AreEqual(input.Name, output.Name);
Assert.AreEqual(input.Age, output.Age);
}

[TestCategory("Helpers")]
[TestMethod]
public void Test_StorageHelper_LegacyPublicClassTest()
{
string key = "Contact";

UI.Person input = new UI.Person() { Name = "Joe Bloggs", Age = 42 };

// simulate previous version by generating json and manually inserting it as string
string jsonInput = JsonSerializer.Serialize(input);

storageHelper.Save(key, jsonInput);

// now read it as int to valid that the change works
Person output = storageHelper.Read<Person>(key, null);

Expand Down Expand Up @@ -123,5 +145,12 @@ public void Test_StorageHelper_NewPersonTest()
Assert.AreEqual(input.Name, output.Name);
Assert.AreEqual(input.Age, output.Age);
}

public class Person
{
public string Name { get; set; }

public int Age { get; set; }
}
}
}