public void Create(string name, string fontFamily, int fontSize) { name = name.Trim(); if (name.Length == 0) { throw new ValidationException("Name is required."); } if (_nameForbiddenChars.Any(x => name.Contains(x))) { throw new ValidationException("Name cannot contain any of the following characters: /, \\, <, >, :, \", |, ?, *"); } if (_notesRepository.Exists(name)) { throw new ValidationException("A note with the same name already exists."); } _notesRepository.Create(name); var note = new Note(name, string.Empty, DateTime.Now, new NoteMetadata(fontFamily, fontSize)); _notesMetadataService.Add(note.Name, note.Metadata); _notesMetadataService.Save(); Created.Invoke(this, new CreatedNoteEventArgs { CreatedNote = note }); }
public void Add() { const string noteName = "dummy name"; var metadata = new NoteMetadata(); _sut.Add(noteName, metadata); NoteMetadata retrieved = _sut.Get(noteName); Assert.Equal(metadata, retrieved); }