public void UpdateText(string oldName, string newName = null, string author = null, bool?includeQuotes = null) { ITextModel model = _textStore.GetOne(x => x.Name == oldName); if (model == null) { throw new ArgumentException("Cannot update text because it does not exist."); } if (author != null) { if (string.IsNullOrWhiteSpace(author)) { throw new ArgumentException("Cannot update text's author to null or whitespace."); } _textStore.ModifyAuthor(model, author); model.SetAuthor(author); } if (includeQuotes != null) { _textStore.ModifyIncludeQuotes(model, (bool)includeQuotes); model.SetIncludeQuotes((bool)includeQuotes); } if (newName != null) { if (string.IsNullOrWhiteSpace(newName)) { throw new ArgumentException("Cannot update text's name to null or whitespace."); } if (_textStore.Exists(x => x.Name == newName) || _groupStore.Exists(x => x.Name == newName)) { throw new ArgumentException($"Cannot update text name because another item in the database already has the name {newName}."); } _textStore.ModifyName(model, newName); model.SetName(newName); } }
public void ValidSetName() { model.SetName("Gary"); Assert.AreEqual("Gary", model.GetName()); }