예제 #1
0
        public void LookingForTagAmongTagsWithDifferentPopularity_GetSortedResultList()
        {
            //Arrange
            var tagRepository = new InMemoryTagRepository();

            tagRepository.Add("Tag1");
            tagRepository.Add("Tag2");
            tagRepository.Add("Tag3");
            var tagFacade = new TagFacade(tagRepository);

            tagFacade.UseTag("Tag1");

            tagFacade.UseTag("Tag2");
            tagFacade.UseTag("Tag2");
            tagFacade.UseTag("Tag2");

            tagFacade.UseTag("Tag3");
            tagFacade.UseTag("Tag3");

            //Act
            var expectedTags = new List <string> {
                "Tag2", "Tag3", "Tag1"
            };
            var actualTags = tagFacade.FindTag("Tag").ToList();

            //Assert
            Assert.AreEqual(expectedTags[0], actualTags[0]);
            Assert.AreEqual(expectedTags[1], actualTags[1]);
            Assert.AreEqual(expectedTags[2], actualTags[2]);
            Assert.AreEqual(expectedTags.Count, actualTags.Count);
        }
예제 #2
0
        public void TryToFindNotExistingTags_GetEmptyList()
        {
            //Arrange
            var tagRepository = new InMemoryTagRepository();

            tagRepository.Add("Tag1");
            tagRepository.Add("Tag2");
            tagRepository.Add("Teg3");
            var tagFacade = new TagFacade(tagRepository);

            //Act
            var actualTags = tagFacade.FindTag("Teg1").ToList();

            //Assert
            Assert.AreEqual(0, actualTags.Count);
        }
예제 #3
0
        public void TryToFindExistingTags_GetListOfFoundTags()
        {
            //Arrange
            var tagRepository = new InMemoryTagRepository();

            tagRepository.Add("Tag1");
            tagRepository.Add("Tag2");
            tagRepository.Add("Teg3");
            var tagFacade = new TagFacade(tagRepository);

            //Act
            var expectedTags = new List <string> {
                "Tag1", "Tag2"
            };
            var actualTags = tagFacade.FindTag("Tag").ToList();

            //Assert
            Assert.AreEqual(expectedTags[0], actualTags[0]);
            Assert.AreEqual(expectedTags[1], actualTags[1]);
            Assert.AreEqual(expectedTags.Count, actualTags.Count);
        }
예제 #4
0
        public void UseExistingTag_GetUpdatedPopularity()
        {
            //Arrange
            var tagRepository = new InMemoryTagRepository();

            tagRepository.Add("Tag1");
            tagRepository.Add("Tag2");
            var tagFacade = new TagFacade(tagRepository);

            //Act
            tagFacade.UseTag("Tag2");

            //Assert
            var expectedTags = new List <string> {
                "Tag2", "Tag1"
            };
            var actualTags = tagFacade.FindTag("Tag").ToList();

            Assert.AreEqual(expectedTags[0], actualTags[0]);
            Assert.AreEqual(expectedTags[1], actualTags[1]);
            Assert.AreEqual(expectedTags.Count, actualTags.Count);
        }
예제 #5
0
        public void CanAddTag()
        {
            var repo = new InMemoryTagRepository();
            Tag tag  = new Tag();

            tag.TagName = "Test Test";

            repo.Add(tag);

            var list   = repo.GetAll();
            var newTag = repo.Get(5);

            Assert.AreEqual(list.Count, 5);
            Assert.AreEqual(newTag.TagName, "Test Test");
        }