public void LoottableSourcePartTest() { using MockDatapack datapack = new MockDatapack("pack"); FileMocks.MockLootTable table = new FileMocks.MockLootTable(datapack.Namespace("test"), "loot"); Assert.AreEqual("loot test:loot", new LootSources.LoottableSource(table).GetSourceString()); Assert.ThrowsException <ArgumentNullException>(() => new LootSources.LoottableSource(null !)); }
public void TestEmptyDatapack() { Assert.AreEqual(MockDatapack.GetPack(), MockDatapack.GetPack(), "Empty Datapack doesn't return the same datapack"); using BaseDatapack pack = new MockDatapack("pack"); Assert.AreEqual("\"file/pack\"", pack.IngameName, "Empty datapack doesn't return correct name"); ((MockDatapack)pack).FileDatapack = false; Assert.AreEqual("pack", pack.IngameName, "Empty datapack doesn't return correct name"); }
public void ScheduleClearTest() { using MockDatapack datapack = new MockDatapack("pack"); FileMocks.MockFunction function = new FileMocks.MockFunction(datapack.Namespace("space"), "function"); Assert.AreEqual("schedule clear space:function", new ScheduleClearCommand(function).GetCommandString()); Assert.ThrowsException <ArgumentNullException>(() => new ScheduleClearCommand(null !)); }
/// <summary> /// Converts a string of the format NAMESPACE:NAME into a namespace object and a string containing the name /// </summary> /// <param name="fileName">The string to convert</param> /// <returns>The things from the string</returns> protected static (BasePackNamespace @namespace, string name) GetNamespaceAndNameFromString(string fileName) { string[] parts = fileName.Split(':'); if (parts.Length != 2) { throw new InvalidCastException("String for creating mock file has to contain a single :"); } return(MockDatapack.GetPack().Namespace(parts[0]), parts[1]); }
public void FishItemSourcePartTest() { using MockDatapack datapack = new MockDatapack("pack"); FileMocks.MockLootTable table = new FileMocks.MockLootTable(datapack.Namespace("test"), "loot"); Assert.AreEqual("fish test:loot ~1 ~2 ~3 minecraft:dirt", new LootSources.FishItemSource(table, new Coords(1, 2, 3), ID.Item.dirt).GetSourceString()); Assert.ThrowsException <ArgumentNullException>(() => new LootSources.FishItemSource(null !, new Vector(1, 2, 3), ID.Item.dirt)); Assert.ThrowsException <ArgumentNullException>(() => new LootSources.FishItemSource(table, null !, ID.Item.dirt)); Assert.ThrowsException <ArgumentNullException>(() => new LootSources.FishItemSource(table, new Vector(1, 2, 3), null !)); }
public void FishHandSourcePartTest() { using MockDatapack datapack = new MockDatapack("pack"); FileMocks.MockLootTable table = new FileMocks.MockLootTable(datapack.Namespace("test"), "loot"); Assert.AreEqual("fish test:loot ~1 ~2 ~3 mainhand", new LootSources.FishHandSource(table, new Coords(1, 2, 3), true).GetSourceString()); Assert.AreEqual("fish test:loot ~1 ~2 ~3 offhand", new LootSources.FishHandSource(table, new Coords(1, 2, 3), false).GetSourceString()); Assert.ThrowsException <ArgumentNullException>(() => new LootSources.FishHandSource(null !, new Coords(1, 2, 3), true)); Assert.ThrowsException <ArgumentNullException>(() => new LootSources.FishHandSource(table, null !, true)); }
public void DatapackEnableAtCommandTest() { BaseDatapack otherPack = new MockDatapack("other"); Assert.AreEqual("datapack enable \"file/pack\" after \"file/other\"", new DatapackEnableAtCommand(GetPack(), true, otherPack).GetCommandString()); Assert.AreEqual("datapack enable \"file/pack\" before \"file/other\"", new DatapackEnableAtCommand(GetPack(), false, otherPack).GetCommandString()); Assert.ThrowsException <ArgumentNullException>(() => new DatapackEnableAtCommand(null !, false, otherPack)); Assert.ThrowsException <ArgumentNullException>(() => new DatapackEnableAtCommand(GetPack(), false, null !)); }
public void RecipeCommandTest() { using MockDatapack datapack = new MockDatapack("pack"); FileMocks.MockRecipe recipe = new FileMocks.MockRecipe(datapack.Namespace("space"), "recipe"); Assert.AreEqual("recipe give @a space:recipe", new RecipeCommand(recipe, ID.Selector.a, true).GetCommandString()); Assert.AreEqual("recipe take @a space:recipe", new RecipeCommand(recipe, ID.Selector.a, false).GetCommandString()); Assert.ThrowsException <ArgumentNullException>(() => new RecipeCommand(null !, ID.Selector.a, true)); Assert.ThrowsException <ArgumentNullException>(() => new RecipeCommand(recipe, null !, true)); }
public void ScheduleAddTest() { using MockDatapack datapack = new MockDatapack("pack"); FileMocks.MockFunction function = new FileMocks.MockFunction(datapack.Namespace("space"), "function"); Assert.AreEqual("schedule function space:function 100d", new ScheduleAddCommand(function, new NoneNegativeTime <int>(100, ID.TimeType.days)).GetCommandString()); Assert.AreEqual("schedule function space:function 100d append", new ScheduleAddCommand(function, new NoneNegativeTime <int>(100, ID.TimeType.days), true).GetCommandString()); Assert.ThrowsException <ArgumentNullException>(() => new ScheduleAddCommand(null !, new NoneNegativeTime <int>(100, ID.TimeType.days))); Assert.ThrowsException <ArgumentNullException>(() => new ScheduleAddCommand(function, null !)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => new ScheduleAddCommand(function, -10)); }
public void AdvancementSomeCommandTest() { using MockDatapack datapack = new MockDatapack("name"); MockNamespace packNamespace = datapack.Namespace("space"); Assert.AreEqual("advancement grant @a from space:adv", new AdvancementSomeCommand(ID.Selector.a, new FileMocks.MockAdvancement(packNamespace, "adv"), ID.RelativeAdvancement.from, true).GetCommandString()); Assert.AreEqual("advancement revoke @a from space:adv", new AdvancementSomeCommand(ID.Selector.a, new FileMocks.MockAdvancement(packNamespace, "adv"), ID.RelativeAdvancement.from, false).GetCommandString()); Assert.AreEqual("advancement grant @a through space:adv", new AdvancementSomeCommand(ID.Selector.a, new FileMocks.MockAdvancement(packNamespace, "adv"), ID.RelativeAdvancement.through, true).GetCommandString()); Assert.AreEqual("advancement revoke @a through space:adv", new AdvancementSomeCommand(ID.Selector.a, new FileMocks.MockAdvancement(packNamespace, "adv"), ID.RelativeAdvancement.through, false).GetCommandString()); Assert.AreEqual("advancement grant @a until space:adv", new AdvancementSomeCommand(ID.Selector.a, new FileMocks.MockAdvancement(packNamespace, "adv"), ID.RelativeAdvancement.until, true).GetCommandString()); Assert.AreEqual("advancement revoke @a until space:adv", new AdvancementSomeCommand(ID.Selector.a, new FileMocks.MockAdvancement(packNamespace, "adv"), ID.RelativeAdvancement.until, false).GetCommandString()); Assert.ThrowsException <ArgumentNullException>(() => new AdvancementSomeCommand(null !, new FileMocks.MockAdvancement(packNamespace, "adv"), ID.RelativeAdvancement.from, true)); Assert.ThrowsException <ArgumentNullException>(() => new AdvancementSomeCommand(ID.Selector.a, null !, ID.RelativeAdvancement.until, true)); }
public void AdvancementSingleCommandTest() { using MockDatapack datapack = new MockDatapack("name"); MockNamespace packNamespace = datapack.Namespace("space"); Assert.AreEqual("advancement grant @a only space:adv", new AdvancementSingleCommand(ID.Selector.a, new FileMocks.MockAdvancement(packNamespace, "adv"), null, true).GetCommandString()); Assert.AreEqual("advancement revoke @a only space:adv", new AdvancementSingleCommand(ID.Selector.a, new FileMocks.MockAdvancement(packNamespace, "adv"), null, false).GetCommandString()); Assert.AreEqual("advancement grant @a only space:adv test", new AdvancementSingleCommand(ID.Selector.a, new FileMocks.MockAdvancement(packNamespace, "adv"), new AdvancementObjects.BredAnimalsTrigger() { Name = "test" }, true).GetCommandString()); Assert.AreEqual("advancement revoke @a only space:adv test", new AdvancementSingleCommand(ID.Selector.a, new FileMocks.MockAdvancement(packNamespace, "adv"), new AdvancementObjects.BredAnimalsTrigger() { Name = "test" }, false).GetCommandString()); Assert.ThrowsException <ArgumentNullException>(() => new AdvancementSingleCommand(null !, new FileMocks.MockAdvancement(packNamespace, "adv"), null, true)); Assert.ThrowsException <ArgumentNullException>(() => new AdvancementSingleCommand(ID.Selector.a, null !, null, true)); }
public void TestEmptyPredicate() { Assert.AreEqual("name:predicate", new FileMocks.MockPredicate(MockDatapack.GetPack().Namespace("name"), "predicate").GetNamespacedName(), "EmptyPredicate doesn't reutrn correct string"); Assert.AreEqual("space:name", ((FileMocks.MockPredicate) "space:name").GetNamespacedName(), "Implicit string to predicate conversion converts incorrectly"); }
public void TestEmptyGroup() { Assert.AreEqual("#space:file", new FileMocks.MockGroup <IBlockType>(MockDatapack.GetPack().Namespace("space"), "file").GetNamespacedName(), "EmptyGroup doesn't return correct string"); }
public void TestEmptyLoottable() { Assert.AreEqual("name:loot", new FileMocks.MockLootTable(MockDatapack.GetPack().Namespace("name"), "loot").GetNamespacedName(), "EmptyLoottable doesn't reutrn correct string"); Assert.AreEqual("space:name", ((FileMocks.MockLootTable) "space:name").GetNamespacedName(), "Implicit string to loottable conversion converts incorrectly"); }
public void TestEmptyFunction() { Assert.AreEqual("name:func", new FileMocks.MockFunction(MockDatapack.GetPack().Namespace("name"), "func").GetNamespacedName(), "EmptyFunction doesn't reutrn correct string"); Assert.AreEqual("space:name", ((FileMocks.MockFunction) "space:name").GetNamespacedName(), "Implicit string to function conversion converts incorrectly"); }
public void TestEmptyAdvancement() { Assert.AreEqual("name:adv", new FileMocks.MockAdvancement(MockDatapack.GetPack().Namespace("name"), "adv").GetNamespacedName(), "EmptyAdvancement doesn't reutrn correct string"); Assert.AreEqual("space:name", ((FileMocks.MockAdvancement) "space:name").GetNamespacedName(), "Implicit string to advancement conversion converts incorrectly"); }