コード例 #1
0
        public static void Q3_3StackOfPlatesTest()
        {
            int[] values = { 4, 2, 3, 1, 5, 1, 3 };

            DataSetOfStack dsm = new DataSetOfStack(3);

            dsm.buildStack(values);
            Assert.True(dsm.length().Equals(3));
            Assert.True(dsm.pop().Equals(3));
            Assert.True(dsm.length().Equals(2));
            for (int i = 0; i < 6; i++)
            {
                dsm.pop();
            }

            Assert.True(dsm.length().Equals(1));
            StackWithCapacity swc = dsm.getLastStack();

            Assert.True(swc.isEmpty());

            for (int i = 0; i < 3; i++)
            {
                dsm.push(i);
            }

            Assert.True(dsm.length().Equals(1));
            dsm.push(4);
            Assert.True(dsm.length().Equals(2));
            StackWithCapacity swc2 = dsm.getLastStack();

            Assert.True(swc2.Count.Equals(1));
        }
コード例 #2
0
        public static void Q3_3StackOfPlatesExceptionTest()
        {
            DataSetOfStack dsm       = new DataSetOfStack(3);
            var            exception = Record.Exception(() => dsm.pop());

            Assert.IsType <EmptyStackException>(exception);

            exception = Record.Exception(() => new DataSetOfStack(0));
            Assert.IsType <ArgumentException>(exception);
        }