예제 #1
0
        public OutputControlsViewModel()
        {
            ISortTypeFactory     sortTypeFactory     = new SortTypeFactory();
            ISortStrategyFactory sortStrategyFactory = new SortStrategyFactory(sortTypeFactory);
            IStringValidator     stringValidator     = new StringToDecimalValidator();

            this.stringToCollectionParser = new StringToDecimalCollectionParser(stringValidator);
            this.sortHandler = new SortHandler(this.stringToCollectionParser, sortStrategyFactory);
        }
예제 #2
0
        public void Should_Return_Single_File_Sort_If_File_Can_Fit_Into_Memory()
        {
            var memoryChecker = Substitute.For <IMemoryChecker>();

            memoryChecker.CanFitWholeFileToMemory(Arg.Any <string>()).Returns(true);

            var strategyFactory = new SortStrategyFactory(memoryChecker);
            var strategy        = strategyFactory.ChooseSortStrategy("pathToFile");

            strategy.Should().BeOfType <SingleFileSort>();
        }
        public void SortStrategyFactory_CreateSort_MergeSortValue_CreateMergeSortInstance()
        {
            ISortTypeFactory sortTypeFactory = CreateSortTypeFactory();
            var          sortStrategyFactory = new SortStrategyFactory(sortTypeFactory);
            IStepCounter stepCounter         = new StubIStepCounter()
            {
                CountSwapOperation    = () => { },
                CountCompareOperation = () => { }
            };

            ISortStrategy sortStrategy = sortStrategyFactory.CreateSort(SortAlgorithmEnum.MergeSort, SortTypeEnum.Ascending, stepCounter);

            Assert.IsInstanceOfType(sortStrategy, typeof(MergeSort));
        }