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(); } }
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); }
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); }
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); } }
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 }; }
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)); }
private void Start() { state = SortState.Idle; sortFactory = gameObject.AddComponent <SortAlgorithmFactory>(); }
/// <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; }
public IEnumerable <string> GetSupportedSortAlgorithms() { return(SortAlgorithmFactory.GetSupportedAlgorithms()); }