コード例 #1
0
ファイル: StrategyTest.cs プロジェクト: tstune/designpattern
        public void SmallArray_ShouldBeSortedWith_Bubblesort()
        {
            // Arrange
            int[] data = { 5, 3, 7, 6 };

            // Act
            var sortStrategySelector = new SortStrategySelector<int>(data);
            var result = sortStrategySelector.Sort();

            // Assert
            Assert.IsInstanceOfType(sortStrategySelector.SortStrategy, typeof(BubbleSortStrategy<int>));
            CollectionAssert.AreEqual(new[] { 3, 5, 6, 7 }, data);
        }
コード例 #2
0
        public void BigArray_ShouldBeSortedWith_Quicksort()
        {
            // Arrange
            int[] data = { 5, 3, 50, 100, 7, 4, 6, 12, 2, 120, 114 };

            // Act
            var sortStrategySelector = new SortStrategySelector <int>(data);
            var result = sortStrategySelector.Sort();

            // Assert
            Assert.IsInstanceOfType(sortStrategySelector.SortStrategy, typeof(QuickSortStrategy <int>));
            CollectionAssert.AreEqual(new[] { 2, 3, 4, 5, 6, 7, 12, 50, 100, 114, 120 }, data);
        }
コード例 #3
0
ファイル: StrategyTest.cs プロジェクト: tstune/designpattern
        public void BigArray_ShouldBeSortedWith_Quicksort()
        {
            // Arrange
            int[] data = { 5, 3, 50, 100, 7, 4, 6, 12, 2, 120, 114 };

            // Act
            var sortStrategySelector = new SortStrategySelector<int>(data);
            var result = sortStrategySelector.Sort();

            // Assert
            Assert.IsInstanceOfType(sortStrategySelector.SortStrategy, typeof(QuickSortStrategy<int>));
            CollectionAssert.AreEqual(new[] { 2, 3, 4, 5, 6, 7, 12, 50, 100, 114, 120 }, data);
        }
コード例 #4
0
        public void SmallArray_ShouldBeSortedWith_Bubblesort()
        {
            // Arrange
            int[] data = { 5, 3, 7, 6 };

            // Act
            var sortStrategySelector = new SortStrategySelector <int>(data);
            var result = sortStrategySelector.Sort();

            // Assert
            Assert.IsInstanceOfType(sortStrategySelector.SortStrategy, typeof(BubbleSortStrategy <int>));
            CollectionAssert.AreEqual(new[] { 3, 5, 6, 7 }, data);
        }