Example #1
0
        public void PatternTooLongThrowsException()
        {
            var grid    = new Grid1d(4);
            var pattern = new List <(string, double)>
            {
                ("Solid", 1),
                ("Glazing", 3),
                ("Fin", 0.2)
            };
            Exception ex = Assert.Throws <ArgumentException>(() => grid.DivideByPattern(pattern, PatternMode.None, FixedDivisionMode.RemainderAtBothEnds));

            Assert.Equal("The grid could not be constructed. Pattern length exceeds grid length.", ex.Message);
        }
Example #2
0
        public void DivideByPatternWithoutRemainder()
        {
            var grid    = new Grid1d(6);
            var pattern = new List <(string typename, double length)>
            {
                ("A", 2),
                ("B", 1)
            };

            grid.DivideByPattern(pattern, PatternMode.Cycle, FixedDivisionMode.RemainderAtEnd);
            var cells = grid.GetCells();

            for (int i = 0; i < cells.Count; i++)
            {
                Assert.Equal(pattern[i % pattern.Count].typename, cells[i].Type);
                Assert.Equal(pattern[i % pattern.Count].length, cells[i].Domain.Length, 3);
            }
        }
Example #3
0
        public void DivideByPattern()
        {
            var grid    = new Grid1d(new Domain1d(60, 150));
            var pattern = new List <(string typename, double length)>
            {
                ("Solid", 1),
                ("Glazing", 3),
                ("Fin", 0.2)
            };

            grid.DivideByPattern(pattern, PatternMode.Cycle, FixedDivisionMode.RemainderAtBothEnds);
            var cells = grid.GetCells();
            var types = cells.Select(c => c.Type);

            for (int i = 0; i < 10; i++)
            {
                Assert.Equal(pattern[i % pattern.Count].length, cells[i + 1].Domain.Length, 3);
                Assert.Equal(pattern[i % pattern.Count].typename, cells[i + 1].Type);
            }
        }