public void HappyParse() { var parser = new NoteParser(new FileInfo("TestNoteFiles/SimpleHappyPath.ntf")); var result = parser.GetTree(); Assert.IsNotNull(result); }
private NoteDAOImplementation() { Logging.singlton(nameof(NoteDAO)); parser = NoteParserImplementation.getInstance(); driver = DatabaseDriverImplementation.getInstance(); driver.createTable(DatabaseConstants.CREATE_NOTE_TABLE); }
public void Parse_Exception_BigSize() { NoteParser parser = new NoteParser(); Exception exception = Assert.Throws <Exception>(() => parser.Parse(2, 4, 4, 4, 8, 8, 8, 4).ToList()); Assert.That(exception.Message == NoteParser.NOTE_BIG_SIZE_ERROR); }
public void Parse_GroupCount_3() { NoteParser parser = new NoteParser(); List <ParseNoteResult> list = parser.Parse(2, 4, 4, 4, 8, 8, 4, 8, 4, 8).ToList(); Assert.AreEqual(3, list.Count); }
public void BareStringTree() { const string expected = "This is a test of the BareString method to see if it works"; var parser = new NoteParser(new FileInfo(BAREPATH)); var tree = parser.GetTree(); var result = tree.ToBareString(); Assert.AreEqual(expected, result); }
public void it_parses_note(string text, Note.Keys key, Note.Octaves octave) { var noteParser = new NoteParser(); var note = noteParser.Parse(text); Assert.That(note.Key, Is.EqualTo(key)); Assert.That(note.Octave, Is.EqualTo(octave)); }
public void MissingHeaderParse() { var parser = new NoteParser(new FileInfo(NOHEADERPATH)); var tree = parser.GetTree(); var tags = tree.GetTags(); Assert.IsTrue(tags.Contains("intro"), "Tag \"intro\" is missing from the list of tags"); Assert.IsTrue(tags.Contains("date"), "Tag \"date\" is missing from the list of tags"); Assert.IsTrue(tags.Contains("name"), "Tag \"name\" is missing from the list of tags"); Assert.IsTrue(tags.Contains("context"), "Tag \"context\" is missing from the list of tags"); }
public void RealTreeToString() { var parser = new NoteParser(new FileInfo(PATH)); var tree = parser.GetTree(); var output = tree.ToString(); var parser2 = new NoteParser(output); var tree2 = parser2.GetTree(); var result = tree2.ToString(); Assert.AreEqual(output, result); }
public void NotesToString() { var note = new NoteNode("test", "test"); var tree = new NoteTree(note); var output = tree.ToString(); var parser = new NoteParser(output); var tree2 = parser.GetTree(); var output2 = tree2.ToString(); Assert.AreEqual(output, output2); }
public RecursiveTower(string noteLine) { var match = NoteParser.Match(noteLine); Name = match.Groups["name"].Value; Weight = int.Parse(match.Groups["weight"].Value); if (match.Groups["held"].Success) { SupportedTowerNames = match.Groups["held"].Value.Split(',').Select(name => name.Trim()).ToArray(); } else { SupportedTowerNames = new string[0]; } }
public void LoadNotePattern() { if (csv_FileName == "") { Debug.Log("파일 이름을 적어주세요."); return; } noteDic.Clear(); NoteParser theParser = GetComponent <NoteParser>(); NoteData[] notes = theParser.Parse(csv_FileName); for (int i = 0; i < notes.Length; i++) { noteDic.Add(i + 1, notes[i]); } loadFinish = true; }
/// <summary> /// Read notes file and parse lines to notes /// </summary> /// <returns>List of notes</returns> private List <Note> GetNotes() { //File path var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Notes.txt"); //Read file if (File.Exists(path)) { string[] fileLines = File.ReadAllLines(path); var notes = new List <Note>(); foreach (var line in fileLines) { //Parse each line into a note notes.Add(NoteParser.DeserializeNote(line)); } return(notes); } return(new List <Note>()); }
public void PresentationFunctionCauseWebWontWork() { if (!Directory.Exists("output")) { Directory.CreateDirectory("output"); } var videoURL = "https://www.youtube.com/watch?v=pN_gruOjM9I"; var firstNote = new NoteInstance() { Note = Notes.D, Octave = 3 }; //------------------------------------------------------------------------// //var videoURL = "https://www.youtube.com/watch?v=aCJxjDzyAT8"; // //var firstNote = new NoteInstance() { Note = Notes.F, Octave = 3 }; // // // //var videoURL = "https://www.youtube.com/watch?v=M4hAK4bTdl4"; // //var firstNote = new NoteInstance() { Note = Notes.A, Octave = 3 }; // // // //var videoURL = "https://www.youtube.com/watch?v=p1WCR7vNcIw"; // //var firstNote = new NoteInstance() { Note = Notes.E, Octave = 3 }; // //------------------------------------------------------------------------// var videoDownloader = new VideoDownloader(); var video = videoDownloader.GetVideoByUrl(new Uri(videoURL)); var keyboardTiles = new NoteParser().ParseToKeyboardTiles(video, firstNote); var musicXmlParser = new MusicXMLParser(); var musicXML = musicXmlParser.KeyboardTilesToMusicXML(keyboardTiles.ToList(), video.Framecount); File.WriteAllText(@"output\musicxml.xml", musicXML); // The output file will be inside the /bin/output folder of the NotesheetR.AppTests project // Webiste to view the musicxml.xml => https://www.soundslice.com/musicxml-viewer/ }
//TODO: Fix the tag completion logic, its shit right now /// <summary> /// Method that is called when the composer text box is edited in any way. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnTextEntryChanged(object sender, RoutedEventArgs e) { var textBox = (RichEditBox)sender; var data = ""; this.Document.GetText(TextGetOptions.None, out data); if (!_skipEvent && data.Trim().Any()) { //Debug.WriteLine(data[textBox.SelectionStart - 1]); if (data[textBox.Document.Selection.StartPosition - 1] == '<') { _enteringTagMode = true; _inTagMode = false; _skipEvent = true; var start = textBox.Document.Selection.StartPosition; data = data.Insert(textBox.Document.Selection.StartPosition, "></>"); textBox.Document.SetText(TextSetOptions.None, data); textBox.Document.Selection.StartPosition = start; textBox.Document.Selection.EndPosition = start; } } else { _skipEvent = false; } try { NoteParser parser = new NoteParser("<NoteTag>" + data + "</>"); var tree = parser.GetTree(); Tags = tree.GetTags(); TagsUpdated(Tags); } catch (BadFormedTagFileException ex) { } }
public void NoNoteTags() { var parser = new NoteParser("test123"); var tree = parser.GetTree(); var tags = tree.GetTags(); }
public void Parse(ILineProvider lineProvider) { GedcomLine lastLine = default; var firstRawLine = lineProvider.ReadLine(); if (firstRawLine == null) { throw new InvalidOperationException("File empty"); } var firstLine = ParserHelper.ParseLine(firstRawLine); if (firstLine.Level != 0 && !ParserHelper.Equals(firstLine.GetFirstItem(), "HEAD")) { throw new InvalidOperationException("GEDCOM Header Not Found"); } var gedcomHeaderParse = HeaderParser.Parse(firstLine, lineProvider); _headerCallback?.Invoke(gedcomHeaderParse.Result); var newLine = gedcomHeaderParse.Line; lastLine = newLine; while (newLine.LineContent.Length > 0) { var content = newLine.GetLineContent(); if (content.Length == 0) { var unrecognisedRawLine = lineProvider.ReadLine(); if (unrecognisedRawLine != null) { newLine = ParserHelper.ParseLine(unrecognisedRawLine); lastLine = newLine; } else { newLine = default; } continue; } var unknown = false; if (ParserHelper.Equals(content, "INDI")) { var individualParseResult = IndividualParser.Parse(newLine, lineProvider); _individualCallback?.Invoke(individualParseResult.Result); newLine = individualParseResult.Line; lastLine = newLine; } else if (ParserHelper.Equals(content, "FAM")) { var familyParseResult = FamilyParser.Parse(newLine, lineProvider); _familyCallback?.Invoke(familyParseResult.Result); newLine = familyParseResult.Line; lastLine = newLine; } else if (ParserHelper.Equals(content, "NOTE")) { var noteParseResult = NoteParser.Parse(newLine, lineProvider); _noteCallback?.Invoke(noteParseResult.Result); newLine = noteParseResult.Line; lastLine = newLine; } else if (ParserHelper.Equals(content, "OBJE")) { var objParserResult = ObjectParser.Parse(newLine, lineProvider); _imageCallback?.Invoke(objParserResult.Result); newLine = objParserResult.Line; lastLine = newLine; } else { var unrecognisedRawLine = lineProvider.ReadLine(); if (unrecognisedRawLine != null) { newLine = ParserHelper.ParseLine(unrecognisedRawLine); lastLine = newLine; } else { newLine = default; } unknown = true; } if (unknown) { continue; } } if (lastLine.LineContent.Length == 0) { throw new InvalidOperationException("file contains no content"); } if (lastLine.Level != 0 || !ParserHelper.Equals(lastLine.GetFirstItem(), "TRLR")) { throw new InvalidOperationException("GEDCOM TRLR not found"); } }