1
0

FurnaceRecipeTest.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Runtime.CompilerServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using MineCase.Algorithm;
  9. using MineCase.Block;
  10. using MineCase.Item;
  11. using Xunit;
  12. namespace MineCase.UnitTest
  13. {
  14. public class FurnaceRecipeTest
  15. {
  16. public readonly string RootDir;
  17. public FurnaceRecipeTest()
  18. {
  19. RootDir = SetRootDir();
  20. }
  21. private static string SetRootDir([CallerFilePath]string fileName = null) =>
  22. Path.Combine(Path.GetDirectoryName(fileName), @"../../data");
  23. [Fact]
  24. public Task TestFurnaceRecipeLoader()
  25. {
  26. // Wait for api update
  27. /*
  28. var loader = new FurnaceRecipeLoader();
  29. using (var sr = new StreamReader(File.OpenRead(Path.Combine(RootDir, "furnace.txt"))))
  30. {
  31. await loader.LoadRecipes(sr);
  32. }
  33. var recipes = loader.Recipes;
  34. Assert.Equal(2, recipes.Count);
  35. var fuels = loader.Fuels;
  36. Assert.Equal(4, fuels.Count);
  37. */
  38. return Task.CompletedTask;
  39. }
  40. [Fact]
  41. public Task TestFurnaceRecipeMatcher()
  42. {
  43. // Wait for api update
  44. /*
  45. var loader = new FurnaceRecipeLoader();
  46. using (var sr = new StreamReader(File.OpenRead(Path.Combine(RootDir, "furnace.txt"))))
  47. {
  48. await loader.LoadRecipes(sr);
  49. }
  50. var matcher = new FurnaceRecipeMatcher(loader.Recipes, loader.Fuels);
  51. var recipe = matcher.FindRecipe(
  52. new Slot { BlockId = (short)BlockStates.Wood().Id, ItemCount = 1 });
  53. var fuel = matcher.FindFuel(
  54. new Slot { BlockId = (short)BlockStates.Wood().Id, ItemCount = 1 });
  55. Assert.NotNull(recipe);
  56. Assert.Equal(ItemStates.Coal(CoalType.Charcoal), new ItemState { Id = (uint)recipe.Output.BlockId, MetaValue = (uint)recipe.Output.ItemDamage });
  57. Assert.Equal((short)BlockStates.Wood().Id, fuel.Slot.BlockId);
  58. */
  59. return Task.CompletedTask;
  60. }
  61. }
  62. }