示例#1
0
        public void UpdateGroup(string oldName, string newName)
        {
            IGroupModel model = _groupStore.GetOne(x => x.Name == oldName);

            if (model == null)
            {
                throw new ArgumentException("Cannot update group since it doesn't exist.");
            }
            if (string.IsNullOrWhiteSpace(newName))
            {
                throw new ArgumentException("Name cannot be null.");
            }
            if (_groupStore.Exists(x => x.Name == newName) || _textStore.Exists(x => x.Name == newName))
            {
                throw new ArgumentException($"Cannot create group because another item in the database already has the name {newName}.");
            }
            _groupStore.ModifyName(model, newName);
            model.SetName(newName);
        }
 public void ValidSetName()
 {
     groupOne.SetName("Gary");
     Assert.AreEqual("Gary", groupOne.GetName());
 }