public void TestGetRecipePass() { // Serialize schema GameObjectsHandler goh = GameObjectsHandler.WithFilepath(getFilepath(itemSchemaV1)); // Create valid list of available objects List <RecipeElement> availables = new List <RecipeElement>(); availables.Add(new RecipeElement(4, 1)); availables.Add(new RecipeElement(5, 1)); // Obtain valid output GameObjectEntry goe = goh.GetRecipe(availables, 7); // Asserts Assert.That(goe.name, Is.EqualTo("steel")); }
public void TestInitialiseGameObjectsHandler() { GameObjectsHandler goh = GameObjectsHandler.WithFilepath(getFilepath(itemSchemaV1)); //Assert fields are correct Assert.That(goh.GameObjs.items.Count, Is.EqualTo(16)); Assert.That(goh.GameObjs.items[0].item_id, Is.EqualTo(1)); Assert.That(goh.GameObjs.items[0].name, Is.EqualTo("wood")); Assert.That(goh.GameObjs.items[0].type, Is.EqualTo(1)); Assert.That(goh.GameObjs.items[15].item_id, Is.EqualTo(16)); Assert.That(goh.GameObjs.items[15].name, Is.EqualTo("dune buggy")); Assert.That(goh.GameObjs.items[15].type, Is.EqualTo(5)); Assert.That(goh.GameObjs.items[15].blueprint[0].item_id, Is.EqualTo(9)); Assert.That(goh.GameObjs.items[15].blueprint[0].quantity, Is.EqualTo(4)); Assert.That(goh.GameObjs.items[15].blueprint[1].item_id, Is.EqualTo(10)); Assert.That(goh.GameObjs.items[15].blueprint[1].quantity, Is.EqualTo(1)); }
public void TestGetSingleElementBlueprintFail() { // Serialize schema GameObjectsHandler goh = GameObjectsHandler.WithFilepath(getFilepath(itemSchemaV1)); // Create list of available objects, with too few values List <RecipeElement> availables = new List <RecipeElement>(); availables.Add(new RecipeElement(2, 6)); GameObjectEntry goe = goh.GetBlueprint(availables, 7); if (goe != null) { // Failure case // GetBlueprint returns non-null object where null expected Assert.Fail(); } }
public void TestGetSingleElementBlueprintPass() { // Serialize schema GameObjectsHandler goh = GameObjectsHandler.WithFilepath(getFilepath(itemSchemaV1)); // Create list of available objects List <RecipeElement> availables = new List <RecipeElement>(); availables.Add(new RecipeElement(2, 8)); try { GameObjectEntry goe = goh.GetBlueprint(availables, 7); //Assert values are correct Assert.That(goe.name, Is.EqualTo("furnace")); } catch (InvalidDataException e) { // Exception thrown, failure case Assert.Fail(); } }
public void TestGetRecipeFail() { // Serialize schema GameObjectsHandler goh = GameObjectsHandler.WithFilepath(getFilepath(itemSchemaV1)); // Create valid list of available objects List <RecipeElement> availables = new List <RecipeElement>(); availables.Add(new RecipeElement(5, 1)); // Obtain valid output GameObjectEntry goe = goh.GetRecipe(availables, 7); // Asserts if (goe != null) { // Failure case, no objects are valid. Hence goe should be null Assert.Fail(); } }