Beispiel #1
0
        private void AddTagsToContainers(string tags, IEnumerable <ITagContainer> tagContainers)
        {
            if (!string.IsNullOrEmpty(tags))
            {
                string[] tagNames = tags.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                if (tagNames.Length > 0)
                {
                    foreach (string t in tagNames)
                    {
                        string tagName = t.NullSafe().StripHtml();

                        if (!string.IsNullOrEmpty(tagName))
                        {
                            ITag tag = _tagRepository.FindByName(tagName);

                            if (tag == null)
                            {
                                tag = _factory.CreateTag(tagName);
                                _tagRepository.Add(tag);
                            }

                            foreach (ITagContainer container in tagContainers)
                            {
                                container.AddTag(tag);
                            }
                        }
                    }
                }
            }
        }
        public void FindByTag_Should_Return_Paged_Result()
        {
            var story1 = CreateStory();
            var story2 = CreateStory();
            var story3 = CreateStory();

            Stories.AddRange(new[] { story1 as Story, story2 as Story, story3 as Story });

            var tag = _factory.CreateTag("dummy");

            Stories.ForEach(s => s.AddTag(tag));

            var pagedResult = _storyRepository.FindByTag(tag.Id, 0, 10);

            Assert.Equal(3, pagedResult.Result.Count);
            Assert.Equal(3, pagedResult.Total);
        }
Beispiel #3
0
        public void Add_Should_Use_Database()
        {
            database.Expect(d => d.Insert(It.IsAny <Tag>())).Verifiable();

            _tagRepository.Add(_factory.CreateTag("Dummy"));
        }
Beispiel #4
0
 public void Add_Should_Use_Database()
 {
     _tagRepository.Add(_factory.CreateTag("Dummy"));
     database.Verify(d => d.InsertOnSubmit(It.IsAny <Tag>()), Times.AtMostOnce());
 }