예제 #1
0
        public void MutableForEachTest_ShouldEnumerateEntryAsMutable1()
        {
            // Arrange
            var entries = new Hashtable();
            entries.Add("a", 1);
            entries.Add("d", 4);
            entries.Add("b", 2);
            entries.Add("c", 3);
            entries.Add("e", 5);

            // Act
            entries.MutableForEach((@this, entry) =>
            {
                @this[entry.Key] = (int)@this[entry.Key] * (int)@this[entry.Key];
            });

            // Assert
            CollectionAssert.AreEqual(
                new int[] { 1, 4, 9, 16, 25 }.AsEnumerable(),
                entries.OfType<DictionaryEntry>().Select(_ => (int)_.Value).OrderBy(_ => _)
            );
        }