public void Does_scope_chain_pop_properly_dispose_chain_links() { //given ScopeChain chain = new ScopeChain(); int cnt = 20; for (int i = 0; i < cnt; i++) { chain.Push(new { Index = i }); } //when int[] actual = new int[cnt]; for (int i = (cnt - 1); i > -1; i--) { actual[i] = (int)ReflectionHelper.Expression.ReflectItem(chain.Peek(), "Index"); chain.Pop(); } //then int[] expected = new int[cnt]; for (int i = 0; i < cnt; i++) { expected[i] = i; } Assert.Equal(expected, actual); }