static void Main(string[] args) { bool inputLoop = false; string input = " "; FeedAccessor feed = new FeedAccessor(); ReadTextFile txt = new ReadTextFile(); DisplayOutput display = new DisplayOutput(); FileWriter writer = new FileWriter(); GenerateStory story = new GenerateStory(); feed.readStream(); Console.WriteLine("Read stream"); writer.WriteKeysToFile(feed.keys); Console.WriteLine("Written Keys to file"); Console.WriteLine(feed.keys.Count + " total keys"); while (!String.Equals(input, "n", StringComparison.OrdinalIgnoreCase)) { input = Console.ReadLine(); Console.Clear(); story.GenerateHeadline(feed.keys); string sentence = story.Sentence; Console.WriteLine(sentence); } }
public void Test_ReadTextFile_Query() { ReadTextFile file = new ReadTextFile(); List <Item> Items = file.ReadFile("Test/test1.txt"); for (int i = 0; i < Items.Count; i++) { Assert.AreEqual(_expected[i].query, Items[i].query); } }
public static ReadTextFile Create(string file) { ReadTextFile rf = new ReadTextFile(); rf.m_file = file; rf.m_bHttp = file.Contains("http:") || file.Contains("https:"); rf.m_error = null; rf.Read(); return(rf); }
public async Task ReadWriteTextFiles() { string fromFile = @"C:\Тест1\1.txt"; string toFile = @"C:\Тест1\2.txt"; var file = new ReadTextFile(); IDictionary <string, int> dictionary = await file.ParseTextAsync(fromFile, ReadTextFile.ParamSortDic.ValueDesc); var textFormatting = file.TextFormatting(dictionary); var writeTextFile = new WriteTextFile(); await writeTextFile.WriteAsync(toFile, textFormatting); }
public void ReadTest_Pass() { //Arrange string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"TestInputFiles/testInput.txt"); IEnumerable <string> inputLines = null; //Act using (ReadTextFile readFile = new ReadTextFile()) { inputLines = readFile.Read(path); } //Assert Assert.True(inputLines != null); }
public void ReadTest_Fail() { //Arrange string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"input99.txt"); ActualValueDelegate <object> testDelegate; //Act using (ReadTextFile readFile = new ReadTextFile()) { testDelegate = () => readFile.Read(path); } //Assert Assert.That(testDelegate, Throws.TypeOf <FileNotFoundException>()); }
public void Test_ReadTextFile_Relation() { ReadTextFile file = new ReadTextFile(); List <Item> Items = file.ReadFile("Test/test1.txt"); for (int i = 0; i < Items.Count; i++) { for (int j = 0; j < Items[i].relations.Count; j++) { for (int k = 0; k < Items[i].relations[j].name.Count; k++) { Assert.AreEqual(_expected[i].relations[j].name[k], Items[i].relations[j].name[k]); } Assert.AreEqual(_expected[i].relations[j].clause, Items[i].relations[j].clause); } } }
//this tests our method to write a text file and the method to read it public void checkWriteFile() { //arrange FullName nameOne = new FullName("Sally Anne ", "Smith"); FullName[] names = new FullName[1]; names[0] = nameOne; //act WriteTextFile wf = new WriteTextFile(); ReadTextFile rf = new ReadTextFile(); //create a new text file for testing wf.WriteFile(names, "testtxt.txt"); //now read it back System.Collections.Generic.List <string> actual = rf.ReadFile("testtxt.txt"); System.Collections.Generic.List <string> expected = new System.Collections.Generic.List <string>(); expected.Add("Sally Anne Smith"); //assert Assert.AreEqual(expected[0], actual[0]); }
/// <summary> /// Prepares the game setup. /// </summary> /// <param name="inputInstructionsFilePath">The input instructions file path.</param> /// <exception cref="InvalidInputFileException"></exception> public override void PrepareGameSetup(string inputInstructionsFilePath) { if (!string.IsNullOrWhiteSpace(inputInstructionsFilePath)) { //fetch Setup details using (IRead reader = new ReadTextFile()) { try { var arrayOfDataLines = reader.Read(inputInstructionsFilePath).ToArray(); if (arrayOfDataLines != null && arrayOfDataLines.Length > 0) { PrepareBattleGameSetupInstance(inputInstructionsFilePath, arrayOfDataLines, this); } else { throw new InvalidInputFileException(inputInstructionsFilePath); } } catch (FileNotFoundException) { Handler.HandleException("Setup file Path not found in system", false); return; } catch (InvalidInputFileException exception) { Handler.HandleException(exception.Message, true); return; } catch (Exception exception) { Handler.HandleException(exception.Message, true); } } } else { Handler.HandleException("Setup Input file Path not provided.", false); } }
private void UniqContent(ReadTextFile txt) { txt = reg_exp.Replace(txt, " "); txt = txt.ToLower(); string[] str_words = txt.Split( new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); Quant_Uniq Aizek = new Quant_Uniq(); Aizek.all_words = words; Aizek.uniq_words_count = new Dictionary <string, int>(); foreach (string element in obj.all_words) { if (obj.uniq_words_count.ContainsKey(element)) { obj.uniq_words_count[element]++; } else { obj.uniq_words_count.Add(element, 1); } } }
public async Task ParseTextAsync_must_return_error_if_format_file_not_txt() { var readTextFile = new ReadTextFile(); await readTextFile.ParseTextAsync("test.doc", ReadTextFile.ParamSortDic.ValueDesc); }
public async Task ParseTextAsync_must_return_error_if_file_path_empty() { var readTextFile = new ReadTextFile(); await readTextFile.ParseTextAsync("", ReadTextFile.ParamSortDic.ValueDesc); }