static void Main(string[] args) { var console = new ConsoleOutput(); var storage = new StoredResults(console); var downloader = new SeleniumWebDownloader(); var charsCounter = new CharsCounter(); var sinceLastUpdate = TimeSpan.FromMinutes(1); var results = new List <Dictionary <char, int> >(); DateTime lastUpdate = DateTime.Now; while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)) { if (sinceLastUpdate >= TimeSpan.FromMinutes(0.5)) { results = storage.Load(); var headers = downloader.DownloadHeaders("https://www.finai.pl/blog"); var charsCount = charsCounter.CountChars(headers); if (charsCount != null) { results.Add(charsCount); } if (results.Count > 5) { results.RemoveAt(0); } storage.Save(results); console.WriteAllChars(results); lastUpdate = DateTime.Now; } sinceLastUpdate = DateTime.Now - lastUpdate; } }
public void CharsCounter_CountChars_ShouldReturnCounter() { var downloader = new SeleniumWebDownloader(); var items = downloader.DownloadHeaders("https://www.finai.pl/blog"); var counter = new CharsCounter(); var lettersCounted = counter.CountChars(items); CollectionAssert.AllItemsAreUnique(lettersCounted); }
private SubMenu CreateActionsMenu() { CharsCounter charsCounter = new CharsCounter(); SpacesCounter spacesCounter = new SpacesCounter(); ActionItem charsCountItem = new ActionItem(InterfaceTestTexts.k_CharsCountTitle, charsCounter); ActionItem spacesCountItem = new ActionItem(InterfaceTestTexts.k_SpacesCountTitle, spacesCounter); SubMenu actionSubMenu = new SubMenu(InterfaceTestTexts.k_ActionsMenuTitle); actionSubMenu.AddItem(charsCountItem); actionSubMenu.AddItem(spacesCountItem); return(actionSubMenu); }
private static void runInterfaceImplementaion() { /* Prepare all menus */ //Menu Item 1 Interfaces.SubMenuItem actionsAndInfo = new Interfaces.SubMenuItem("Actions and Info"); //Menu Item 1.1 IExecuteFlowLogic displayVersion = new DisplayVersion(); actionsAndInfo.AddMenuItem(new ExecuteFlowMenueItem("Display Version", displayVersion)); //Menu Item 1.2 Interfaces.SubMenuItem actions = new Interfaces.SubMenuItem("Actions"); //Menu Item 1.2.1 IExecuteFlowLogic spaceCounter = new SpaceCounter(); actions.AddMenuItem(new ExecuteFlowMenueItem("Count Spaces", spaceCounter)); //Menu Item 1.2.2 IExecuteFlowLogic charsCounter = new CharsCounter(); actions.AddMenuItem(new ExecuteFlowMenueItem("Chars Count", charsCounter)); actionsAndInfo.AddMenuItem(actions); //Menu Item 2 Interfaces.SubMenuItem dateAndTime = new Interfaces.SubMenuItem("Show Date/Time"); //Menu Item 2.1 IExecuteFlowLogic showTime = new DisplayTime(); dateAndTime.AddMenuItem(new ExecuteFlowMenueItem("Show Time", showTime)); //Menu Item 2.2 IExecuteFlowLogic showDate = new DisplayDate(); dateAndTime.AddMenuItem(new ExecuteFlowMenueItem("Show Date", showDate)); /* Prepare main menu */ Interfaces.SubMenuItem mainMenu = new Interfaces.SubMenuItem("Main Menu - Interface Implemented"); mainMenu.AddMenuItem(actionsAndInfo); mainMenu.AddMenuItem(dateAndTime); Interfaces.MainMenu interfaceMainMenu = new Interfaces.MainMenu(mainMenu); /* execute */ interfaceMainMenu.Show(); }
public void GetCharsCountStartIndexEndIndexLimit_StrParameterIsNull_ThrowsException() { // Act Assert.Throws <ArgumentNullException>(() => CharsCounter.GetCharsCount(null, null, 0, 0, 0)); }
public int GetCharsCount_ParametersAreValid_ReturnsResult(string str, char[] chars, int startIndex, int endIndex) { // Act return(CharsCounter.GetCharsCount(str, chars, startIndex, endIndex)); }
public void GetCharsCountStartIndexEndIndex_StartIndexGreaterEndIndex_ThrowsException() { // Act Assert.Throws <ArgumentOutOfRangeException>(() => CharsCounter.GetCharsCount("aa", new char[] { 'a' }, 1, 0)); }
public void GetCharsCountStartIndexEndIndex_EndIndexGreaterStringLength_ThrowsException() { // Act Assert.Throws <ArgumentOutOfRangeException>(() => CharsCounter.GetCharsCount(string.Empty, new char[] { 'a' }, 0, 1)); }
public void GetCharsCountStartIndexEndIndex_StartIndexLessZero_ThrowsException() { // Act Assert.Throws <ArgumentOutOfRangeException>(() => CharsCounter.GetCharsCount(string.Empty, new char[] { 'a' }, -1, 0)); }
public void GetCharsCountStartIndexEndIndex_CharsParameterIsNull_ThrowsException() { // Act Assert.Throws <ArgumentNullException>(() => CharsCounter.GetCharsCount(string.Empty, null, 0, 0)); }
public int GetCharsCount_ParametersAreValid_ReturnsResult(string str, char[] chars) { // Act return(CharsCounter.GetCharsCount(str, chars)); }
public void GetCharsCountStartIndexEndIndexLimit_LimitLessZero_ThrowsException() { // Act Assert.Throws <ArgumentOutOfRangeException>(() => CharsCounter.GetCharsCount("aa", new char[] { 'a' }, 0, 1, -1)); }
public void GetCharsCount_StrParameterIsNull_ThrowsException() { // Act Assert.Throws <ArgumentNullException>(() => CharsCounter.GetCharsCount(null, null)); }