public void WrongSerializationDataGetBackZxSpectrum48K() { // --- Act var success = SpConfSerializer.Deserialize("wrong data", out var backVm); // --- Assert success.ShouldBeFalse(); backVm.ModelName.ShouldBe(SpectrumModels.ZX_SPECTRUM_48); backVm.EditionName.ShouldBe(SpectrumModels.PAL); backVm.ConfigurationData.ShouldNotBeNull(); }
/// <summary> /// Loads the Spectrum model information /// </summary> private void LoadSpectrumModelInfo() { var configItem = SpConfProjectItems.FirstOrDefault(); var data = ""; if (configItem != null) { try { data = File.ReadAllText(configItem.Filename); } catch { // --- This exception is intentionally ignored } } SpConfSerializer.Deserialize(data, out var confVm); ModelName = confVm.ModelName; EditionName = confVm.EditionName; SpectrumConfiguration = confVm.ConfigurationData; }
public void SerializationWorksAsExpected() { // --- Arrange var vm = new SpConfEditorViewModel { ModelName = SpectrumModels.ZX_SPECTRUM_48, EditionName = SpectrumModels.PAL }; // --- Act var data = SpConfSerializer.Serialize(vm); Console.WriteLine(data); // --- Assert var success = SpConfSerializer.Deserialize(data, out var backVm); success.ShouldBeTrue(); backVm.ModelName.ShouldBe(vm.ModelName); backVm.EditionName.ShouldBe(vm.EditionName); }