コード例 #1
0
        public void CreateGroup(string name, int length)
        {
            if (_groupStore.Exists(x => x.Name == name) || _textStore.Exists(x => x.Name == name))
            {
                throw new ArgumentException($"Cannot create group because another item in the database already has the name {name}.");
            }
            IGroupModel model = _modelFactory.GetGroupModel(name, length);

            _groupStore.Add(model);
        }
コード例 #2
0
        public void CreateText(string name, TextReader input, int length, string author = null)
        {
            if (_textStore.Exists(x => x.Name == name) || _groupStore.Exists(x => x.Name == name))
            {
                throw new ArgumentException($"Cannot create text because another item in the database already has the name {name}.");
            }
            ITextModel model = _modelFactory.GetTextModel(name, input, length);

            if (!string.IsNullOrWhiteSpace(author))
            {
                model.SetAuthor(author);
            }
            _textStore.Add(model);
        }
コード例 #3
0
        public void TestExists()
        {
            //string name = _uniqueNames.Pop();
            string name;

            _uniqueNames.TryPop(out name);
            StreamReader text   = new StreamReader("../../SampleTextFiles/WordSpanningMultipleLines.txt");
            ITextModel   model  = _modelFactory.GetTextModel(name, text, UniversalConstants.CountSize);
            bool         exists = _textStore.Exists(x => x.Name == name);

            Assert.IsFalse(exists);
            _textStore.Add(model);
            exists = _textStore.Exists(x => x.Name == name);
            Assert.IsTrue(exists);
            _textStore.Delete(model);
            exists = _textStore.Exists(x => x.Name == name);
            Assert.IsFalse(exists);
        }