Esempio n. 1
0
        public void XmlSerialisationToFileRoundTrip()
        {
            GlobalDefinition gd = new GlobalDefinition();

            gd.RandomCatchments(3, 1, 5);
            var filename = Path.GetTempFileName();

            try
            {
                gd.XmlSerialize(filename);
                GlobalDefinition result = SerializationHelper.XmlDeserialize <GlobalDefinition>(new FileInfo(filename));
                AssertThatDefinitionsAreEquivalent(result, gd);

                // test the serialisation of the catchment id
                foreach (CatchmentDefinition cd in result)
                {
                    foreach (CellDefinition cell in cd.Cells)
                    {
                        Assert.That(cell.CatchmentId, Is.EqualTo(cd.Id));
                    }
                }
            }
            finally
            {
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }
            }
        }
Esempio n. 2
0
        public void XmlSerialisationRoundTrip()
        {
            GlobalDefinition gd = new GlobalDefinition();

            gd.RandomCatchments(5, 1, 5);
            string           sgd    = gd.XmlSerialize();
            GlobalDefinition result = SerializationHelper.XmlDeserialize <GlobalDefinition>(sgd);

            List <CellDefinition> gdCells = gd.GetFlatCellList();

            foreach (CatchmentDefinition catchment in gd)
            {
                Assert.That(catchment.Cells, Is.SubsetOf(gdCells));
            }

            List <CellDefinition> rCells = result.GetFlatCellList();

            foreach (CatchmentDefinition catchment in result)
            {
                Assert.That(catchment.Cells, Is.SubsetOf(rCells));
            }

            foreach (CatchmentDefinition cd in result)
            {
                foreach (CellDefinition cell in cd.Cells)
                {
                    Assert.That(cell.CatchmentId, Is.EqualTo(cd.Id));
                }
            }

            AssertThatDefinitionsAreEquivalent(result, gd);
        }