예제 #1
0
        public void WriteRepoDistribution()
        {
            const string DataIndexName = "Test dataindex";
            var          gstId         = Guid.NewGuid().ToString();
            var          catId1        = Guid.NewGuid().ToString();
            var          catId2        = Guid.NewGuid().ToString();
            var          gstNode       = NodeFactory.Gamesystem(id: gstId);
            var          original      =
                new RepoDistribution(
                    DatafileInfo.Create(
                        DataIndexFilename,
                        NodeFactory.DataIndex(DataIndexName)),
                    (new IDatafileInfo <CatalogueBaseNode>[]
            {
                DatafileInfo.Create("gamesystem.gst", gstNode),
                DatafileInfo.Create("cat1.cat", NodeFactory.Catalogue(gstNode, id: catId1)),
                DatafileInfo.Create("cat2.cat", NodeFactory.Catalogue(gstNode, id: catId2)),
            })
                    .ToImmutableArray());

            using var memory = new MemoryStream();
            original.WriteTo(memory);
            memory.Position = 0;
            var read = memory.ReadRepoDistribution();

            Assert.Equal(DataIndexName, read.Index.GetData().Name);
            Assert.True(
                read.Datafiles
                .Select(x => x.GetData().Id)
                .ToHashSet()
                .SetEquals(new[] { gstId, catId1, catId2 }));
        }
예제 #2
0
        private void PublishIndex(IWorkspace workspace, Options options)
        {
            var dataIndex = CreateIndex(workspace, options);
            var datafile  = DatafileInfo.Create(options.Filename + XmlFileExtensions.DataIndex, dataIndex);

            TryCatchLogError(
                datafile.Filepath,
                () => Path.Combine(options.Output.FullName, datafile.Filepath),
                datafile.WriteXmlFile);
        }