private int AddComplexCatchments()
 {
     gd.RandomCatchments(22, 2, 2);
     gd.RandomCatchments(12, 12, 12);
     gd.RandomCatchments(4, 31, 31);
     return(gd.GetFlatCellList().Count);
 }
示例#2
0
        public static void AssertThatDefinitionsAreEquivalent(GlobalDefinition a, GlobalDefinition b)
        {
            // compare the catchments
            Assert.That(a.Count, Is.EqualTo(b.Count));
            for (int i = 0; i < b.Count; i++)
            {
                CatchmentDefinition aCatchment = a[i];
                CatchmentDefinition bCatchment = b[i];
                Assert.That(aCatchment.Id, Is.EqualTo(bCatchment.Id));
                Assert.That(aCatchment.Cells.Count, Is.EqualTo(bCatchment.Cells.Count));

                for (int j = 0; j < bCatchment.Cells.Count; j++)
                {
                    Assert.That(aCatchment.Cells[j].Id, Is.EqualTo(bCatchment.Cells[j].Id));
                }
            }

            // Compare the cells
            List <CellDefinition> aCells = a.GetFlatCellList();
            List <CellDefinition> bCells = b.GetFlatCellList();

            Assert.That(aCells.Count, Is.EqualTo(bCells.Count));
            for (int i = 0; i < bCells.Count; i++)
            {
                CellDefinition ac = aCells[i];
                CellDefinition bc = bCells[i];
                Assert.That(ac.Id, Is.EqualTo(bc.Id));
                AssertThatModelRunDefinitionsAreEqual(ac.ModelRunDefinition, bc.ModelRunDefinition);
            }
        }
示例#3
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);
        }
示例#4
0
        public void AddCatchment()
        {
            GlobalDefinition    gd        = new GlobalDefinition();
            CatchmentDefinition catchment = new CatchmentDefinition {
                Id = "catchment-124"
            };

            const int numCells = 9;

            for (int cells = 0; cells < numCells; cells++)
            {
                CellDefinition cell = new CellDefinition {
                    Id = "cell-" + cells
                };
                catchment.Cells.Add(cell);
            }

            gd.AddCatchment(catchment);

            Assert.That(gd.Count, Is.EqualTo(1));

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

            Assert.AreEqual(gdCells.Count, numCells);
            foreach (CellDefinition cell in gdCells)
            {
                Assert.That(catchment.Cells, Contains.Item(cell));
            }
        }
示例#5
0
        public void TestCellLists()
        {
            GlobalDefinition gd = new GlobalDefinition();

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

            foreach (CatchmentDefinition catchment in gd)
            {
                Assert.That(catchment.Cells, Is.SubsetOf(gdCells));
            }
        }
示例#6
0
 public void DefaultCounts()
 {
     Assert.That(globalDef.Count, Is.EqualTo(0));
     Assert.That(globalDef.GetFlatCellList().Count, Is.EqualTo(0));
 }