public void TestPredicate() { //setup using Datapack pack = new Datapack("datapacks", "pack", "a pack", 0, new NoneFileCreator()); PackNamespace space = pack.Namespace("space"); //test space.Predicate("MyPredicate", new Conditions.RandomCondition(0.5)); Assert.IsTrue(pack.FileCreator.GetDirectories().Any(d => d == "datapacks/pack/data/space/predicates/"), "Directory wasn't created"); Assert.IsTrue(pack.FileCreator.GetWriters().Any(w => w.path == "datapacks/pack/data/space/predicates/mypredicate.json"), "File wasn't created"); space.Predicate("folder/otherpredicate", new Conditions.RandomCondition(0.5), BaseFile.WriteSetting.OnDispose); Assert.IsFalse(pack.FileCreator.GetDirectories().Any(d => d == "datapacks/pack/data/space/predicates/folder/"), "Directory wasn't supposed to be created yet since its OnDispose"); Assert.IsFalse(pack.FileCreator.GetWriters().Any(w => w.path == "datapacks/pack/data/space/predicates/folder/otherpredicate.json"), "File wasn't supposed to be created yet since its OnDispose"); pack.Dispose(); Assert.IsTrue(pack.FileCreator.GetDirectories().Any(d => d == "datapacks/pack/data/space/predicates/folder/"), "Directory wasn't created for file with directory in name"); Assert.IsTrue(pack.FileCreator.GetWriters().Any(w => w.path == "datapacks/pack/data/space/predicates/folder/otherpredicate.json"), "File is supposed to have been created now since Dispose was ran"); }
public void TestRecipe() { //setup using Datapack pack = new Datapack("datapacks", "pack", "a pack", 0, new NoneFileCreator()); PackNamespace space = pack.Namespace("space"); //test space.Recipe("myrecipe"); Assert.IsTrue(pack.FileCreator.GetDirectories().Any(d => d == "datapacks/pack/data/space/recipes/"), "Directory wasn't created"); Assert.IsTrue(pack.FileCreator.GetWriters().Any(w => w.path == "datapacks/pack/data/space/recipes/myrecipe.json"), "File wasn't created"); space.Recipe("folder/otherrecipe", SmeltRecipe.SmeltType.smelting, ID.Item.dirt, ID.Item.coarse_dirt, 2, null, null, BaseFile.WriteSetting.OnDispose); Assert.IsFalse(pack.FileCreator.GetDirectories().Any(d => d == "datapacks/pack/data/space/recipes/folder/"), "Directory wasn't supposed to be created yet since its OnDispose"); Assert.IsFalse(pack.FileCreator.GetWriters().Any(w => w.path == "datapacks/pack/data/space/recipes/folder/otherrecipe.json"), "File wasn't supposed to be created yet since its OnDispose"); pack.Dispose(); Assert.IsTrue(pack.FileCreator.GetDirectories().Any(d => d == "datapacks/pack/data/space/recipes/folder/"), "Directory wasn't created for file with directory in name"); Assert.IsTrue(pack.FileCreator.GetWriters().Any(w => w.path == "datapacks/pack/data/space/recipes/folder/otherrecipe.json"), "File is supposed to have been created now since Dispose was ran"); }
public void TestLootTable() { //setup using Datapack pack = new Datapack("datapacks", "pack", "a pack", 0, new NoneFileCreator()); PackNamespace space = pack.Namespace("space"); //test space.Loottable("myTable", new LootPool[] { new LootPool(new EmptyEntry(), 1) }, null, BaseFile.WriteSetting.Auto); Assert.IsTrue(pack.FileCreator.GetDirectories().Any(d => d == "datapacks/pack/data/space/loot_tables/"), "Directory wasn't created"); Assert.IsTrue(pack.FileCreator.GetWriters().Any(w => w.path == "datapacks/pack/data/space/loot_tables/mytable.json"), "File wasn't created"); space.Loottable("folder/otherTable", new LootPool[] { new LootPool(new EmptyEntry(), 1) }, null, BaseFile.WriteSetting.OnDispose); Assert.IsFalse(pack.FileCreator.GetDirectories().Any(d => d == "datapacks/pack/data/space/loot_tables/folder/"), "Directory wasn't supposed to be created yet since its OnDispose"); Assert.IsFalse(pack.FileCreator.GetWriters().Any(w => w.path == "datapacks/pack/data/space/loot_tables/folder/othertable.json"), "File wasn't supposed to be created yet since its OnDispose"); pack.Dispose(); Assert.IsTrue(pack.FileCreator.GetWriters().Any(w => w.path == "datapacks/pack/data/space/loot_tables/folder/othertable.json"), "File is supposed to have been created now since Dispose was ran"); Assert.IsTrue(pack.FileCreator.GetDirectories().Any(d => d == "datapacks/pack/data/space/loot_tables/folder/"), "Directory wasn't created for file with directory in name"); }
public void TestAdvancement() { //setup using Datapack pack = new Datapack("datapacks", "pack", "a pack", 0, new NoneFileCreator()); PackNamespace space = pack.Namespace("space"); //test space.Advancement("myadvancement"); Assert.IsTrue(pack.FileCreator.GetDirectories().Any(d => d == "datapacks/pack/data/space/advancements/"), "Directory wasn't created"); Assert.IsTrue(pack.FileCreator.GetWriters().Any(w => w.path == "datapacks/pack/data/space/advancements/myadvancement.json"), "File wasn't created"); space.Advancement("folder/otherAdvancement", new BredAnimalsTrigger(), null !, BaseFile.WriteSetting.OnDispose); Assert.IsFalse(pack.FileCreator.GetDirectories().Any(d => d == "datapacks/pack/data/space/advancements/folder/"), "Directory wasn't supposed to be created yet since its OnDispose"); Assert.IsFalse(pack.FileCreator.GetWriters().Any(w => w.path == "datapacks/pack/data/space/advancements/folder/otheradvancement.json"), "File wasn't supposed to be created yet since its OnDispose"); pack.Dispose(); Assert.IsTrue(pack.FileCreator.GetDirectories().Any(d => d == "datapacks/pack/data/space/advancements/folder/"), "Directory wasn't created for file with directory in name"); Assert.IsTrue(pack.FileCreator.GetWriters().Any(w => w.path == "datapacks/pack/data/space/advancements/folder/otheradvancement.json"), "File is supposed to have been created now since Dispose was ran"); }