public void Deserialize_ModifiedRecipe_FullDetails(string itemName, string ingredient, string linkedItems) { string serialized = "ModifiedRecipe:" + "\r\n" + "(" + "\r\n" + $" ItemID:{itemName};" + "\r\n" + " AmountCrafted:4;" + "\r\n" + " Ingredients:" + "\r\n" + " (" + "\r\n" + $" ItemID:{ingredient};" + "\r\n" + " Required:2;" + "\r\n" + " )," + "\r\n" + " (" + "\r\n" + " ItemID:Copper;" + "\r\n" + " Required:3;" + "\r\n" + " );" + "\r\n" + $" LinkedItemIDs:{linkedItems};" + "\r\n" + ");" + "\r\n"; var recipe = new ModifiedRecipe(); recipe.FromString(serialized); Assert.AreEqual(TechType.Aerogel, recipe.ItemID); Assert.AreEqual(4, recipe.AmountCrafted); Assert.AreEqual(2, recipe.IngredientsCount); Assert.AreEqual(TechType.Titanium, recipe.GetIngredient(0).ItemID); Assert.AreEqual(2, recipe.GetIngredient(0).Required); Assert.AreEqual(TechType.Copper, recipe.GetIngredient(1).ItemID); Assert.AreEqual(3, recipe.GetIngredient(1).Required); Assert.AreEqual(2, recipe.LinkedItemsCount); Assert.AreEqual(TechType.Silver, recipe.GetLinkedItem(0)); Assert.AreEqual(TechType.Gold, recipe.GetLinkedItem(1)); }
public void CreateFromClases_ThenTest_SampleModifiedRecipes() { var curedReginaldRecipe = new ModifiedRecipe() { ItemID = TechType.CuredReginald.ToString(), AmountCrafted = 1, }; curedReginaldRecipe.AddUnlock(TechType.NutrientBlock.ToString()); curedReginaldRecipe.AddIngredient(TechType.Reginald.ToString(), 1); curedReginaldRecipe.AddIngredient(TechType.Salt.ToString(), 1); var origRecipeList = new ModifiedRecipeList { curedReginaldRecipe }; string serialized = origRecipeList.PrettyPrint(); string samples2File = SampleFileDirectory + "ModifiedRecipes_Samples2.txt"; File.WriteAllText(samples2File, serialized); var readingRecipeList = new ModifiedRecipeList(); string reserialized = File.ReadAllText(samples2File); bool success = readingRecipeList.FromString(reserialized); Assert.IsTrue(success); Assert.AreEqual(origRecipeList.Count, readingRecipeList.Count); // nutrientBlockRecipe ModifiedRecipe curedReginald = origRecipeList[0]; Assert.AreEqual(curedReginald.ItemID, curedReginaldRecipe.ItemID); Assert.AreEqual(curedReginald.AmountCrafted, curedReginaldRecipe.AmountCrafted); Assert.AreEqual(curedReginald.IngredientsCount, curedReginaldRecipe.IngredientsCount); Assert.AreEqual(curedReginald.GetIngredient(0).ItemID, curedReginaldRecipe.GetIngredient(0).ItemID); Assert.AreEqual(curedReginald.GetIngredient(1).ItemID, curedReginaldRecipe.GetIngredient(1).ItemID); Assert.AreEqual(curedReginald.GetIngredient(0).Required, curedReginaldRecipe.GetIngredient(0).Required); Assert.AreEqual(curedReginald.GetIngredient(1).Required, curedReginaldRecipe.GetIngredient(1).Required); Assert.AreEqual(curedReginald.ForceUnlockAtStart, curedReginaldRecipe.ForceUnlockAtStart); Assert.AreEqual(curedReginald.UnlocksCount, curedReginaldRecipe.UnlocksCount); Assert.AreEqual(curedReginald.GetUnlock(0), curedReginaldRecipe.GetUnlock(0)); }
public void Deserialize_ModifiedRecipesList_Unlocks() { const string serialized = "ModifiedRecipes:" + "\r\n" + "(" + "\r\n" + " ItemID:Aerogel;" + "\r\n" + " AmountCrafted:1;" + "\r\n" + " Ingredients:" + "\r\n" + " (" + "\r\n" + " ItemID:Titanium;" + "\r\n" + " Required:2;" + "\r\n" + " )," + "\r\n" + " (" + "\r\n" + " ItemID:Copper;" + "\r\n" + " Required:3;" + "\r\n" + " );" + "\r\n" + " LinkedItemIDs:Silver,Gold;" + "\r\n" + " ForceUnlockAtStart:NO;" + "\r\n" + " Unlocks:ComputerChip,Cyclops;" + "\r\n" + ");" + "\r\n"; var recipeList = new ModifiedRecipeList(); recipeList.FromString(serialized); ModifiedRecipe recipe = recipeList[0]; Assert.AreEqual(TechType.Aerogel, recipe.ItemID); Assert.AreEqual(1, recipe.AmountCrafted); Assert.AreEqual(2, recipe.IngredientsCount); Assert.AreEqual(TechType.Titanium, recipe.GetIngredient(0).ItemID); Assert.AreEqual(2, recipe.GetIngredient(0).Required); Assert.AreEqual(TechType.Copper, recipe.GetIngredient(1).ItemID); Assert.AreEqual(3, recipe.GetIngredient(1).Required); Assert.AreEqual(2, recipe.LinkedItemsCount); Assert.AreEqual(TechType.Silver, recipe.GetLinkedItem(0)); Assert.AreEqual(TechType.Gold, recipe.GetLinkedItem(1)); Assert.AreEqual(false, recipe.ForceUnlockAtStart); Assert.AreEqual(2, recipe.UnlocksCount); Assert.AreEqual(TechType.ComputerChip, recipe.GetUnlock(0)); Assert.AreEqual(TechType.Cyclops, recipe.GetUnlock(1)); }