Exemplo n.º 1
0
        public static void MainMenu()
        {
            Facade facade = new Facade()
            {
                CountOfElements = Count,
                ResultPrinter   = new TxtWriter()
            };

            bool exit = false;

            while (!exit)
            {
                Console.WriteLine($"\n\t1.SortArray" +
                                  $"\n\t2.ChooseSortAlgorithm" +
                                  $"\n\t3.ChooseSortMode" +
                                  $"\n\t4.SearchData" +
                                  $"\n\t5.Exit\n");


                var consoleKey = Console.ReadKey();

                Console.WriteLine();

                switch (consoleKey.Key)
                {
                case ConsoleKey.D1:
                    facade.SortAlgorithm = SortAlgorithmFactory.GetAlgorithm(Algorithm, Mode);
                    facade.PathToFile    = $@"..\..\..\Files\ResultsOf{Algorithm}{Mode}.txt";
                    facade.StartMethod();

                    break;

                case ConsoleKey.D2:
                    ChooseSortAlgorithm();

                    break;

                case ConsoleKey.D3:
                    ChooseSortMode();

                    break;


                case ConsoleKey.D4:
                    SearchMethod();
                    break;

                case ConsoleKey.D5:
                    exit = true;
                    break;
                }

                Console.WriteLine("\nDone");
                Console.ReadKey();
                Console.Clear();
            }
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            _mockServiceProvider = new Mock <IServiceProvider>();
            _mockServiceProvider.Setup(m => m.GetService(typeof(AlphabeticalSorter))).Returns(new AlphabeticalSorter());
            _mockServiceProvider.Setup(m => m.GetService(typeof(WordSizeSorter))).Returns(new WordSizeSorter());
            _mockServiceProvider.Setup(m => m.GetService(typeof(CharacterWithinWordSorter))).Returns(new CharacterWithinWordSorter());

            _sortAlgorithmFactory = new SortAlgorithmFactory(_mockServiceProvider.Object);
        }
Exemplo n.º 3
0
        public object Do()
        {
            ISortAlgorithm sortAlgorithm = SortAlgorithmFactory.CreateAlgorithm(_model, _element, _algorithm);
            SortResult     sortResult    = sortAlgorithm.Sort();

            _model.ReorderChildren(_element, sortResult);
            _order = sortResult.Data;

            _model.AssignElementOrder();

            return(null);
        }
Exemplo n.º 4
0
        private void Partition(IProgress <ProgressInfo> progress, IDsmElement element, int totalElements, ref int progressedElements)
        {
            ISortAlgorithm algorithm = SortAlgorithmFactory.CreateAlgorithm(_dsmModel, element, PartitionSortAlgorithm.AlgorithmName);

            _dsmModel.ReorderChildren(element, algorithm.Sort());
            progressedElements++;
            UpdateProgress(progress, "Partition elements", totalElements, progressedElements);

            foreach (IDsmElement child in element.Children)
            {
                Partition(progress, child, totalElements, ref progressedElements);
            }
        }
Exemplo n.º 5
0
        public void Setup()
        {
            _model   = new Mock <IDsmModel>();
            _element = new Mock <IDsmElement>();

            SortAlgorithmFactory.RegisterAlgorithm(UsedAlgorithm, typeof(StubbedSortAlgorithm));

            _element.Setup(x => x.Id).Returns(ElementId);
            _model.Setup(x => x.GetElementById(ElementId)).Returns(_element.Object);

            _data = new Dictionary <string, string>
            {
                ["element"]   = ElementId.ToString(),
                ["algorithm"] = UsedAlgorithm,
                ["order"]     = SortResult
            };
        }
Exemplo n.º 6
0
        public void TestInitialize()
        {
            _dsmModel = new Mock <IDsmModel>();

            _createMetaDataItem = new Mock <IMetaDataItem>();

            _existingElement = new Mock <IDsmElement>();
            _createdElement  = new Mock <IDsmElement>();
            _elementParent   = new Mock <IDsmElement>();
            _elementChild    = new Mock <IDsmElement>();

            _createdRelation = new Mock <IDsmRelation>();

            _elementParent.Setup(x => x.Id).Returns(ElementParentId);

            SortAlgorithmFactory.RegisterAlgorithm(PartitionSortAlgorithm.AlgorithmName, typeof(StubbedSortAlgorithm));
        }
Exemplo n.º 7
0
 private void Start()
 {
     state       = SortState.Idle;
     sortFactory = gameObject.AddComponent <SortAlgorithmFactory>();
 }
Exemplo n.º 8
0
 /// <summary>
 /// String Sort Service constructor
 /// </summary>
 /// <param name="sortAlgorithmFactory"></param>
 /// <param name="stringSettings"></param>
 public StringSortService(SortAlgorithmFactory sortAlgorithmFactory, IOptions <StringSettings> stringSettings)
 {
     _sortAlgorithmFactory = sortAlgorithmFactory;
     _stringSettings       = stringSettings.Value;
 }
Exemplo n.º 9
0
 public IEnumerable <string> GetSupportedSortAlgorithms()
 {
     return(SortAlgorithmFactory.GetSupportedAlgorithms());
 }