예제 #1
0
 public void CanFailWithNullDescriptionAndNullTagType()
 {
     TagRepository repo = new TagRepository();
     Assert.Throws(typeof(SQLiteException), () =>
         repo.Add(new Tag())
     );
 }
예제 #2
0
 public void CanAddTag()
 {
     TagRepository repo = new TagRepository();
     repo.Add(new Tag
     {
         Description = "tag"
     });
 }
예제 #3
0
        public void CanGetTag()
        {
            TagRepository repo = new TagRepository();
            Tag tag = new Tag
            {
                Description = "tag"
            };
            repo.Add(tag);

            Assert.AreEqual(tag, repo.GetById(tag.Id));
        }
예제 #4
0
        public void CanGetAllTags()
        {
            TagRepository repo = new TagRepository();
            Tag tag1 = new Tag { Description = "tag1" };
            Tag tag2 = new Tag { Description = "tag2" };
            repo.Add(tag1);
            repo.Add(tag2);

            Tag[] tags = repo.GetAll().ToArray();

            Assert.True(tags.Contains(tag1));
            Assert.True(tags.Contains(tag2));
        }
예제 #5
0
        public void CanDeleteTag()
        {
            TagRepository repo = new TagRepository();
            Tag tag = new Tag
            {
                Description = "tag"
            };
            repo.Add(tag);

            repo.Delete(tag.Id);

            Assert.Null(repo.GetById(tag.Id));
        }
예제 #6
0
        public void CanAddFileWithTags()
        {
            TagRepository tagRepository = new TagRepository();
            Tag tag1 = new Tag { Description = Guid.NewGuid().ToString() };
            tagRepository.Add(tag1);
            Tag tag2 = new Tag { Description = Guid.NewGuid().ToString() };
            tagRepository.Add(tag2);

            FileRepository fileRepository = new FileRepository();
            File file = new File
            {
                FilePath = Guid.NewGuid().ToString(),
                Tags = new [] { tag1, tag2 }.ToList()
            };
            fileRepository.Add(file);

            Assert.AreEqual(file, fileRepository.GetByFilename(file.FilePath));
        }
예제 #7
0
        public void CanGetFilesByTag()
        {
            TagRepository tagRepository = new TagRepository();
            Tag tag = new Tag
            {
                Description = "CanGetFilesByTag tag"
            };
            tagRepository.Add(tag);

            FileRepository fileRepository = new FileRepository();
            File fileWithTag = new File
            {
                FilePath = Guid.NewGuid().ToString(),
                Tags = new []{ tag }.ToList()
            };

            File fileWithoutTag = new File
            {
                FilePath = Guid.NewGuid().ToString(),
                Tags = new Tag[0].ToList()
            };

            fileRepository.Add(fileWithTag);
            fileRepository.Add(fileWithoutTag);

            IEnumerable<File> files = fileRepository.GetByTag(tag.Id);
            Assert.Contains(fileWithTag, files.ToArray());
        }
예제 #8
0
        public void CanUpdateTag()
        {
            TagTypeRepository repoTagtypes = new TagTypeRepository();
            TagType tagTypeOriginal = new TagType
            {
                Description = "tag type original"
            };
            TagType tagTypeUpdated = new TagType
            {
                Description = "tag type updated"
            };
            repoTagtypes.Add(tagTypeOriginal);
            repoTagtypes.Add(tagTypeUpdated);

            TagRepository repoTags = new TagRepository();
            Tag tag = new Tag
            {
                Description = "tag",
                TagType = tagTypeOriginal
            };
            repoTags.Add(tag);

            tag.Description = "tag updated";
            tag.TagType = tagTypeUpdated;
            repoTags.Update(tag);

            Assert.AreEqual(tag, repoTags.GetById(tag.Id));
        }