Example #1
0
    public void TestSaveLocationChanges()
    {
        // Check that, when the save location is changed, the two XML files a) can vary independently, and that b) the second file
        // is an extension of whatever data existed in the first file (i.e. that, in a sense, operations on the second file are precluded by
        // all of the operations that had occurred to establish the first file).

        CollectionWriter.EstablishNewDocument();

        // Create some data
        Dictionary <string, string[]>         descriptiveData = new Dictionary <string, string[]>();
        Dictionary <string, VerticeTransform> structuralData  = new Dictionary <string, VerticeTransform>();

        descriptiveData.Add("title", new string[] { "Test Title" });
        descriptiveData.Add("creator", new string[] { "Test Creator" });
        descriptiveData.Add("date", new string[] { "2016-10-20" });

        structuralData.Add("TEST-ARTEFACT-01", new VerticeTransform(Vector3.one, Quaternion.identity, Vector3.one));

        // Write data to the first file
        Paths.CollectionMetadata = Environment.CurrentDirectory + "/Assets/Scripts/Metadata/TestAssets/Collection_Writer_Test.xml";
        CollectionWriter.WriteCollectionWithIdentifer("TEST-COLLECTION-01", descriptiveData, structuralData);

        // Change location and save the new collection
        Paths.CollectionMetadata = Environment.CurrentDirectory + "/Assets/Scripts/Metadata/TestAssets/Collection_Writer_Test_02.xml";
        CollectionWriter.WriteCollectionWithIdentifer("TEST-COLLECTION-02", descriptiveData, structuralData);

        // Check that the first file has only one collection
        CollectionReader.LoadXmlFromFile(Environment.CurrentDirectory + "/Assets/Scripts/Metadata/TestAssets/Collection_Writer_Test.xml");
        string[] collectionIdentifiers_01 = CollectionReader.GetIdentifiersForCollections();
        Assert.That(collectionIdentifiers_01.Length == 1);

        // Now check that the second file has two
        CollectionReader.LoadXmlFromFile(Paths.CollectionMetadata);
        string[] collectionIdentifiers_02 = CollectionReader.GetIdentifiersForCollections();
        Assert.That(collectionIdentifiers_02.Length == 2);

        // Tidy up (the second file will be deleted in TearDown)
        File.Delete(Environment.CurrentDirectory + "/Assets/Scripts/Metadata/TestAssets/Collection_Writer_Test.xml");
    }
Example #2
0
 public void TestAddArtefactToNonexistantCollection()
 {
     CollectionWriter.EstablishNewDocument();
     CollectionWriter.AddArtefactToCollectionWithIdentifier("NON-EXISTANT COLLECTION", "", new VerticeTransform(0f, 0f, 0f, 0f));
 }