public void CanAddFile() { FileRepository repo = new FileRepository(); File file = new File { FilePath = Guid.NewGuid().ToString(), Tags = new List<Tag>() }; repo.Add(file); Assert.AreNotEqual(0, file.Id); }
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)); }
public void CanFailSamePath() { FileRepository repo = new FileRepository(); string filePath = Guid.NewGuid().ToString(); repo.Add(new File { FilePath = filePath, Tags = new List<Tag>() }); Assert.Throws(typeof(SQLiteException), () => repo.Add(new File { FilePath = filePath, Tags = new List<Tag>() }) ); }
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()); }
public void CanGetFile() { FileRepository repo = new FileRepository(); File file = new File { FilePath = Guid.NewGuid().ToString(), Tags = new List<Tag>() }; repo.Add(file); Assert.AreEqual(file, repo.GetByFilename(file.FilePath)); }
public void CanFailWithNullFilepath() { FileRepository repo = new FileRepository(); Assert.Throws(typeof(SQLiteException), () => repo.Add(new File { Tags = new List<Tag>() }) ); }