public void Remove() { const string noteName = "dummy name"; _sut.Add(noteName, new NoteMetadata()); _sut.Remove(noteName); bool contains = _sut.Contains(noteName); Assert.False(contains); }
public void Update(string newName, Note note) { string originalName = note.Name; newName = newName.Trim(); if (newName.Length == 0) { throw new ValidationException("Name is required."); } if (_nameForbiddenChars.Any(x => newName.Contains(x))) { throw new ValidationException("Name cannot contain any of the following characters: /, \\, <, >, :, \", |, ?, *"); } var fileName = newName + ".txt"; if (!string.Equals(originalName, newName, StringComparison.InvariantCultureIgnoreCase) && _notesRepository.Exists(newName)) { throw new ValidationException("A note with the same name already exists."); } _notesRepository.Update(originalName, newName); _notesMetadataService.Remove(originalName); _notesMetadataService.Add(newName, note.Metadata); _notesMetadataService.Save(); note.Name = newName; Updated.Invoke(this, new UpdatedNoteEventArgs { OriginalName = originalName, UpdatedNote = note }); }