test.rs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. use crate::grid::group_test::script::GridGroupTest;
  2. use crate::grid::group_test::script::GroupScript::*;
  3. #[tokio::test]
  4. async fn board_init_test() {
  5. let mut test = GridGroupTest::new().await;
  6. let scripts = vec![
  7. AssertGroupCount(3),
  8. AssertGroup {
  9. group_index: 0,
  10. row_count: 2,
  11. },
  12. AssertGroup {
  13. group_index: 1,
  14. row_count: 2,
  15. },
  16. AssertGroup {
  17. group_index: 2,
  18. row_count: 1,
  19. },
  20. ];
  21. test.run_scripts(scripts).await;
  22. }
  23. #[tokio::test]
  24. async fn board_move_row_test() {
  25. let mut test = GridGroupTest::new().await;
  26. let group = test.group_at_index(0).await;
  27. let scripts = vec![
  28. MoveRow {
  29. from_group_index: 0,
  30. from_row_index: 0,
  31. to_group_index: 0,
  32. to_row_index: 1,
  33. },
  34. AssertGroup {
  35. group_index: 0,
  36. row_count: 2,
  37. },
  38. AssertGroupRow {
  39. group_index: 0,
  40. row_index: 1,
  41. row: group.rows.get(0).unwrap().clone(),
  42. },
  43. ];
  44. test.run_scripts(scripts).await;
  45. }
  46. #[tokio::test]
  47. async fn board_move_row_to_other_group_test() {
  48. let mut test = GridGroupTest::new().await;
  49. let group = test.group_at_index(0).await;
  50. let scripts = vec![
  51. MoveRow {
  52. from_group_index: 0,
  53. from_row_index: 0,
  54. to_group_index: 1,
  55. to_row_index: 1,
  56. },
  57. AssertGroup {
  58. group_index: 0,
  59. row_count: 1,
  60. },
  61. AssertGroup {
  62. group_index: 1,
  63. row_count: 3,
  64. },
  65. AssertGroupRow {
  66. group_index: 1,
  67. row_index: 1,
  68. row: group.rows.get(0).unwrap().clone(),
  69. },
  70. ];
  71. test.run_scripts(scripts).await;
  72. }
  73. #[tokio::test]
  74. async fn board_move_row_to_other_group_and_reorder_test() {
  75. let mut test = GridGroupTest::new().await;
  76. let group = test.group_at_index(0).await;
  77. let scripts = vec![
  78. MoveRow {
  79. from_group_index: 0,
  80. from_row_index: 0,
  81. to_group_index: 1,
  82. to_row_index: 1,
  83. },
  84. MoveRow {
  85. from_group_index: 1,
  86. from_row_index: 1,
  87. to_group_index: 1,
  88. to_row_index: 2,
  89. },
  90. AssertGroupRow {
  91. group_index: 1,
  92. row_index: 2,
  93. row: group.rows.get(0).unwrap().clone(),
  94. },
  95. ];
  96. test.run_scripts(scripts).await;
  97. }