예제 #1
0
        public void ODRTagsAreCreatedAsExpected()
        {
            var testFiles = new TestFileCache(Path.Combine(GetTestOutputPath(), "ODRTags1Files"));

            string catalogPath = Path.Combine(GetTestOutputPath(), "ODRTags1.xcassets");
            var    catalog     = new AssetCatalog(catalogPath, "test.test");
            var    dataset     = catalog.OpenDataSet("data1");

            dataset.AddVariant(new DeviceRequirement(), testFiles.CreateFile("data1.dat", "data1"), null);
            dataset.AddOnDemandResourceTag("tag1");
            dataset.AddOnDemandResourceTag("tag2");

            catalog.Write();

            string datasetPath = Path.Combine(catalogPath, "data1.dataset");

            Assert.IsTrue(Directory.Exists(catalogPath));
            Assert.IsTrue(Directory.Exists(datasetPath));
            AssertFileExistsAndHasContents(Path.Combine(datasetPath, "Contents.json"),
                                           File.ReadAllText(Path.Combine(GetTestSourcePath(), "ODRTags1.data1.dataset.Contents.json")));
            AssertFileExistsAndHasContents(Path.Combine(datasetPath, "data1.dat"), "data1");

            if (!DebugEnabled())
            {
                testFiles.CleanUp();
                Directory.Delete(catalogPath, true);
            }
        }
예제 #2
0
        public void DataSetCreationWorks()
        {
            var testFiles = new TestFileCache(Path.Combine(GetTestOutputPath(), "Dataset1Files"));

            string catalogPath = Path.Combine(GetTestOutputPath(), "Dataset1.xcassets");
            var    catalog     = new AssetCatalog(catalogPath, "test.test");
            var    dataset     = catalog.OpenDataSet("data1");

            dataset.AddVariant(new DeviceRequirement().AddDevice(DeviceTypeRequirement.iPad),
                               testFiles.CreateFile("data1.dat", "data1"), null);

            dataset.AddVariant(new DeviceRequirement().AddMemory(MemoryRequirement.Mem1GB),
                               testFiles.CreateFile("data2.dat", "data2"), "testtype1");

            dataset.AddVariant(new DeviceRequirement().AddMemory(MemoryRequirement.Mem2GB).AddGraphics(GraphicsRequirement.Metal1v2),
                               testFiles.CreateFile("data3", "data3"), "testtype2");

            catalog.Write();

            string datasetPath = Path.Combine(catalogPath, "data1.dataset");

            Assert.IsTrue(Directory.Exists(catalogPath));
            Assert.IsTrue(Directory.Exists(datasetPath));
            AssertFileExistsAndHasContents(Path.Combine(datasetPath, "Contents.json"),
                                           File.ReadAllText(Path.Combine(GetTestSourcePath(), "Dataset1.Contents.json")));
            AssertFileExistsAndHasContents(Path.Combine(datasetPath, "data1.dat"), "data1");
            AssertFileExistsAndHasContents(Path.Combine(datasetPath, "data2.dat"), "data2");
            AssertFileExistsAndHasContents(Path.Combine(datasetPath, "data3"), "data3");

            if (!DebugEnabled())
            {
                testFiles.CleanUp();
                Directory.Delete(catalogPath, true);
            }
        }
예제 #3
0
        public void FoldersAreCreatedAsExpected()
        {
            var testFiles = new TestFileCache(Path.Combine(GetTestOutputPath(), "Folder1Files"));

            string catalogPath = Path.Combine(GetTestOutputPath(), "Folder1.xcassets");
            var    catalog     = new AssetCatalog(catalogPath, "test.test");
            var    dataset     = catalog.OpenDataSet("test/test/test2/data1");

            dataset.AddVariant(new DeviceRequirement().AddDevice(DeviceTypeRequirement.iPad),
                               testFiles.CreateFile("data1.dat", "data1"), null);

            var folder = catalog.OpenFolder("test/test2");

            folder.providesNamespace = true;
            dataset = catalog.OpenDataSet("test/test2/data2");
            dataset.AddVariant(new DeviceRequirement().AddDevice(DeviceTypeRequirement.iPad),
                               testFiles.CreateFile("data2.dat", "data2"), null);

            catalog.Write();

            Assert.IsTrue(Directory.Exists(catalogPath));
            Assert.IsFalse(File.Exists(Path.Combine(catalogPath, "Contents.json")));
            Assert.IsTrue(Directory.Exists(Path.Combine(catalogPath, "test")));
            Assert.IsFalse(File.Exists(Path.Combine(catalogPath, "test/Contents.json")));
            Assert.IsTrue(Directory.Exists(Path.Combine(catalogPath, "test/test")));
            Assert.IsFalse(File.Exists(Path.Combine(catalogPath, "test/test/Contents.json")));
            Assert.IsTrue(Directory.Exists(Path.Combine(catalogPath, "test/test/test2")));
            Assert.IsFalse(File.Exists(Path.Combine(catalogPath, "test/test/test2/Contents.json")));
            Assert.IsTrue(Directory.Exists(Path.Combine(catalogPath, "test/test/test2/data1.dataset")));
            Assert.IsTrue(Directory.Exists(Path.Combine(catalogPath, "test/test2")));
            AssertFileExistsAndHasContents(Path.Combine(catalogPath, "test/test2/Contents.json"),
                                           File.ReadAllText(Path.Combine(GetTestSourcePath(), "Folder1.test2.Contents.json")));
            Assert.IsTrue(Directory.Exists(Path.Combine(catalogPath, "test/test2/data2.dataset")));
            AssertFileExistsAndHasContents(Path.Combine(catalogPath, "test/test/test2/data1.dataset/Contents.json"),
                                           File.ReadAllText(Path.Combine(GetTestSourcePath(), "Folder1.data1.dataset.Contents.json")));
            AssertFileExistsAndHasContents(Path.Combine(catalogPath, "test/test2/data2.dataset/Contents.json"),
                                           File.ReadAllText(Path.Combine(GetTestSourcePath(), "Folder1.data2.dataset.Contents.json")));

            if (!DebugEnabled())
            {
                testFiles.CleanUp();
                Directory.Delete(catalogPath, true);
            }
        }