Example #1
0
        public void RepositoryReadWriterTests_DeeplySpecifiedId_WillBeResolvedFromId()
        {
            //Arrange
            const string searchPattern = "*.dll";

            var repo = StubIORepositoryReadWriter.CreateRepositoryReadWriter(searchPattern);
            var dir  = new DirectoryInfo(repo.RootFolder);

            var actualFile = dir.GetFiles(searchPattern, SearchOption.AllDirectories)
                             .Where(x => x.FullName.Replace(repo.RootFolder, string.Empty).Contains(@"\"))
                             .Last();

            //Act
            var file =
                repo.GetEntity <File>(repo.GenerateId(actualFile.FullName));

            //Assert
            Assert.IsNotNull(file);
            Assert.AreEqual(actualFile.Name, file.Name);
        }
        public void RepositoryReadWriterTests_DeleteNonContainerFile()
        {
            //Arrange
            const string searchPattern = "*.dll";

            var repo = StubIORepositoryReadWriter.CreateRepositoryReadWriter(searchPattern);
            var dir  = new DirectoryInfo(repo.RootFolder);

            var contents = "Test File Content";
            var file     = CreateFile(contents);

            repo.AddOrUpdate(file);

            Assert.IsTrue(System.IO.File.Exists(file.Location));

            //Act
            repo.Delete <File>(file.Id);

            //Assert
            Assert.IsFalse(System.IO.File.Exists(file.Location));
        }
        public void RepositoryReadWriterTests_CreateEntityWithRelations_CreatesRelationFiles()
        {
            //Arrange
            const string searchPattern = "*.dll,*.xml";

            var repo = StubIORepositoryReadWriter.CreateRepositoryReadWriter(searchPattern);
            var dir  = new DirectoryInfo(repo.RootFolder);

            var sourceFile      = CreateFile("Source File");
            var destinationFile = CreateFile("Destination File");

            destinationFile.Relations.Add(new Relation(new RelationType("TestRelation"), sourceFile, destinationFile, new[] {
                new RelationMetaDatum("size", "100")
            }));

            repo.AddOrUpdate(sourceFile);
            repo.AddOrUpdate(destinationFile);

            var sourceMd5Hash      = sourceFile.Id.ToString().ToMd5();
            var destinationMd5Hash = destinationFile.Id.ToString().ToMd5();
            var relationPath       = Path.Combine(repo.RootFolder, "Relations\\" + sourceMd5Hash + "-" + destinationMd5Hash + ".xml");

            Assert.IsTrue(System.IO.File.Exists(relationPath));
        }