public void TestSerializeShouldSerializeImage() { var image = CreateImage(); var result = _serializer.Serialize("Name", image); var expected = _serializer.Deserialize(result, typeof(BitmapImage)); Assert.That(((BitmapImage)expected).PixelHeight, Is.EqualTo(image.PixelHeight)); Assert.That(((BitmapImage)expected).PixelWidth, Is.EqualTo(image.PixelWidth)); }
public Task LoadStateCommand(string[] args) { AppState state = PropertySerializer.Deserialize <AppState>(PropertyFiles.STATE_FILE); service.TickerSymbol = state.TickerSymbol; Cash = state.Cash ?? 0; Shares = state.Shares ?? 0; IO.ShowMessage(Messages.LoadedStateFormat, PropertyFiles.STATE_FILE); return(Task.CompletedTask); }
public void TestDeserializeReadOnlyWithContinue() { HaveReadOnly o = new HaveReadOnly(); o.Value = "a"; PropertySerializer <HaveReadOnly> ser = new PropertySerializer <HaveReadOnly>("Value", "ReadOnly"); ser.ContinueOnError = true; Assert.AreEqual(true, ser.ContinueOnError); ser.Serialize(o, Dictionary); HaveReadOnly test = new HaveReadOnly(); ser.Deserialize(test, Dictionary); }
public void TestDeserializeReadOnly() { HaveReadOnly o = new HaveReadOnly(); o.Value = "a"; PropertySerializer <HaveReadOnly> ser = new PropertySerializer <HaveReadOnly>("Value", "ReadOnly"); ser.ContinueOnError = false; Assert.AreEqual(false, ser.ContinueOnError); ser.Serialize(o, Dictionary); HaveReadOnly test = new HaveReadOnly(); ser.Deserialize(test, Dictionary); //should go boom Assert.Fail(); }
public void TestSerialize() { PropertySerializer ser = new PropertySerializer(typeof(TestValues1), ValueNames); ser.ContinueOnError = false; Assert.AreEqual(false, ser.ContinueOnError); ser.Serialize(ValuesA, Dictionary); TestValues test = new TestValues(); ser.Deserialize(test, Dictionary); Assert.AreEqual(ValuesA._bool, test._bool); Assert.AreEqual(ValuesA._byte, test._byte); Assert.AreEqual(ValuesA._char, test._char); Assert.AreEqual(ValuesA._DateTime, test._DateTime); Assert.AreEqual(ValuesA._decimal, test._decimal); Assert.AreEqual(ValuesA._double, test._double); Assert.AreEqual(ValuesA._float, test._float); Assert.AreEqual(ValuesA._Guid, test._Guid); Assert.AreEqual(ValuesA._int, test._int); Assert.AreEqual(ValuesA._long, test._long); Assert.AreEqual(ValuesA._sbyte, test._sbyte); Assert.AreEqual(ValuesA._short, test._short); Assert.AreEqual(ValuesA._string, test._string); Assert.AreEqual(ValuesA._TimeSpan, test._TimeSpan); Assert.AreEqual(ValuesA._uint, test._uint); Assert.AreEqual(ValuesA._ulong, test._ulong); Assert.AreEqual(ValuesA._Uri, test._Uri); Assert.AreEqual(ValuesA._ushort, test._ushort); Assert.AreEqual(ValuesA._Version, test._Version); //ROK - note, it can not deserialize this since it does not know the type: Assert.AreEqual(null, test._object); }
public void TestDeserializeReadOnlyWithContinue() { HaveReadOnly o = new HaveReadOnly(); o.Value = "a"; PropertySerializer<HaveReadOnly> ser = new PropertySerializer<HaveReadOnly>("Value", "ReadOnly"); ser.ContinueOnError = true; Assert.AreEqual(true, ser.ContinueOnError); ser.Serialize(o, Dictionary); HaveReadOnly test = new HaveReadOnly(); ser.Deserialize(test, Dictionary); }
public void TestDeserializeReadOnly() { HaveReadOnly o = new HaveReadOnly(); o.Value = "a"; PropertySerializer<HaveReadOnly> ser = new PropertySerializer<HaveReadOnly>("Value", "ReadOnly"); ser.ContinueOnError = false; Assert.AreEqual(false, ser.ContinueOnError); ser.Serialize(o, Dictionary); HaveReadOnly test = new HaveReadOnly(); ser.Deserialize(test, Dictionary);//should go boom Assert.Fail(); }
static AppProperties() { Preferences = PropertySerializer.Deserialize <AppPreferences>(PropertyFiles.PREFERENCES_FILE); Messages = PropertySerializer.Deserialize <AppMessages>(PropertyFiles.MESSAGES_FILE); }