コード例 #1
0
        public void PeekShouldPeekSourceStack()
        {
            // arrange
            var source = new Stack<object>();
            var target = new StackAdapter<object>( source );

            // act
            target.Push( new object() );

            // assert
            Assert.Equal( source.Peek(), target.Peek() );
        }
コード例 #2
0
        public void CopyToShouldCopySourceStack()
        {
            // arrange
            var expected = new[] { new object(), new object(), new object() };
            var source = new Stack<object>( expected );
            var target = new StackAdapter<object>( source );
            var actual = new object[3];

            // act
            target.CopyTo( actual, 0 );

            // assert
            Assert.True( actual.SequenceEqual( expected.Reverse() ) );
        }
コード例 #3
0
        public void ClearShouldClearSourceStack()
        {
            // arrange
            var source = new Stack<object>();
            var target = new StackAdapter<object>( source );

            target.Push( new object() );

            // act
            target.Clear();

            // assert
            Assert.Equal( 0, source.Count );
            Assert.Equal( 0, target.Count );
        }
コード例 #4
0
        public void PopShouldPopSourceStack()
        {
            // arrange
            var source = new Stack<object>();
            var target = new StackAdapter<object>( source );

            target.Push( new object() );

            var expected = source.Peek();

            // act
            var actual = target.Pop();

            // assert
            Assert.Equal( expected, actual );
        }