Ejemplo n.º 1
0
        public void GetSortedCutsAtIndex_IndexOutOfRangeThrowsException()
        {
            List <List <int?> > input = new List <List <int?> >
            {
                new List <int?> {
                    null, null, 4, null
                },
                new List <int?> {
                    null, null, 3, null
                },
                new List <int?> {
                    null, null, 5, null
                },
                new List <int?> {
                    null, null, 1, null
                },
                new List <int?> {
                    null, null, 7, null
                },
            };

            List <int?> output = PinningModelBase.GetSortedCutsAtIndex(input, 2);

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => { PinningModelBase.GetSortedCutsAtIndex(input, -1); });
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => { PinningModelBase.GetSortedCutsAtIndex(input, 7); });
        }
Ejemplo n.º 2
0
        public void GetSortedCutsAtIndex_ValidIndexReturnsProperlySortedCutsWithNullsAndDuplicatesOmitted()
        {
            List <List <int?> > input = new List <List <int?> >
            {
                new List <int?> {
                    null, null, 4, null
                },
                new List <int?> {
                    null, null, 3, null
                },
                new List <int?> {
                    null, null, 7, null
                },
                new List <int?> {
                    null, null, 5, null
                },
                new List <int?> {
                    null, null, null, null
                },
                new List <int?> {
                    null, null, 1, null
                },
                new List <int?> {
                    null, null, 3, null
                },
                new List <int?> {
                    null, null, 7, null
                }
            };

            List <int?> expected = new List <int?> {
                1, 3, 4, 5, 7
            };

            List <int?> output = PinningModelBase.GetSortedCutsAtIndex(input, 2);

            if (output.Count != expected.Count)
            {
                Assert.Fail($"Output had length {output.Count} instead of {expected.Count}.");
            }

            for (int index = 0; index < output.Count; index++)
            {
                int?currentOutput   = output[index];
                int?currentExpected = expected[index];

                if (currentOutput != currentExpected)
                {
                    Assert.Fail($"Output value {currentOutput} at index {index} did not match expected value {currentExpected}.");
                }
            }
        }