|
1 | 1 | using System.Collections.Generic; |
2 | 2 | using System.IO; |
3 | 3 | using System.Linq; |
| 4 | +using System.Text; |
4 | 5 | using OSPSuite.BDDHelper; |
5 | 6 | using OSPSuite.BDDHelper.Extensions; |
6 | 7 | using OSPSuite.Core.Domain; |
7 | 8 | using OSPSuite.Core.Domain.Data; |
8 | | -using OSPSuite.Core.Helpers; |
9 | 9 | using OSPSuite.Core.Serialization.Exchange; |
10 | 10 | using OSPSuite.Core.Serialization.Xml; |
11 | 11 | using OSPSuite.Core.Serializers; |
@@ -37,12 +37,30 @@ public override void Cleanup() |
37 | 37 | } |
38 | 38 | } |
39 | 39 |
|
| 40 | + internal class When_serializing_and_deserializing_an_entity_with_illegal_xml_characters : concern_for_SimulationPersistor |
| 41 | + { |
| 42 | + [Observation] |
| 43 | + public void should_return_a_simulation_transfer_containing_a_valid_simulation() |
| 44 | + { |
| 45 | + var x1 = new SimulationTransfer { Simulation = _simulation }; |
| 46 | + var illegalXmlString = Encoding.ASCII.GetString(Encoding.ASCII.GetBytes("F1").Concat(new byte[] { 0x1F }).ToArray()); |
| 47 | + x1.Favorites.Add(illegalXmlString); |
| 48 | + |
| 49 | + _simulationPersistor.Save(x1, _filePath); |
| 50 | + File.Exists(_filePath).ShouldBeTrue(); |
| 51 | + var deserializationObjectBaseRepository = IoC.Resolve<IWithIdRepository>(); |
| 52 | + |
| 53 | + var x2 = _simulationPersistor.Load(_filePath, deserializationObjectBaseRepository); |
| 54 | + x2.Favorites.First().ShouldBeEqualTo(illegalXmlString); |
| 55 | + } |
| 56 | + } |
| 57 | + |
40 | 58 | internal class When_deserializing_a_valid_simulation_file_containing_some_licenses : concern_for_SimulationPersistor |
41 | 59 | { |
42 | 60 | [Observation] |
43 | 61 | public void should_return_a_simulation_transfer_containing_a_valid_simulation() |
44 | 62 | { |
45 | | - var x1 = new SimulationTransfer {Simulation = _simulation}; |
| 63 | + var x1 = new SimulationTransfer { Simulation = _simulation }; |
46 | 64 | x1.Favorites.Add("F1"); |
47 | 65 | x1.Favorites.Add("F2"); |
48 | 66 | _simulationPersistor.Save(x1, _filePath); |
@@ -90,12 +108,12 @@ protected override void Context() |
90 | 108 | WeightedObservedData = new WeightedObservedData(_obsData), |
91 | 109 | OutputSelection = new SimulationQuantitySelection(_simulation, new QuantitySelection("A|B|C", QuantityType.Complex)) |
92 | 110 | }; |
93 | | - _outputMappings = new OutputMappings {_outputMapping}; |
| 111 | + _outputMappings = new OutputMappings { _outputMapping }; |
94 | 112 |
|
95 | | - _simulationTransfer = new SimulationTransfer |
| 113 | + _simulationTransfer = new SimulationTransfer |
96 | 114 | { |
97 | 115 | Simulation = _simulation, |
98 | | - AllObservedData = new List<DataRepository>{ _obsData }, |
| 116 | + AllObservedData = new List<DataRepository> { _obsData }, |
99 | 117 | OutputMappings = _outputMappings |
100 | 118 | }; |
101 | 119 | } |
|
0 commit comments