|
1 | 1 | using BrainAI.Pathfinding;
|
2 |
| -using Microsoft.VisualBasic; |
3 | 2 | using NUnit.Framework;
|
4 | 3 | using System.Collections.Generic;
|
5 | 4 | using System.Linq;
|
@@ -199,5 +198,84 @@ public void ContinueSearch_MultiGoals_PathFound()
|
199 | 198 | new Point(2, 3)
|
200 | 199 | }, pathfinder.ResultPath);
|
201 | 200 | }
|
| 201 | + |
| 202 | + [Test] |
| 203 | + public void Search_TwiceWithSuccess_PathCleared() |
| 204 | + { |
| 205 | + /* |
| 206 | + ____ |
| 207 | + _01_ |
| 208 | + _#2_ |
| 209 | + __3_ |
| 210 | + */ |
| 211 | + graph.Walls.Add(new Point(1, 2)); |
| 212 | + pathfinder.Search(new Point(1, 1), new Point(2, 3)); |
| 213 | + CollectionAssert.AreEqual(new List<Point> { |
| 214 | + new Point(1, 1), |
| 215 | + new Point(2, 1), |
| 216 | + new Point(2, 2), |
| 217 | + new Point(2, 3) |
| 218 | + }, pathfinder.ResultPath); |
| 219 | + pathfinder.Search(new Point(1, 1), new Point(2, 3)); |
| 220 | + CollectionAssert.AreEqual(new List<Point> { |
| 221 | + new Point(1, 1), |
| 222 | + new Point(2, 1), |
| 223 | + new Point(2, 2), |
| 224 | + new Point(2, 3) |
| 225 | + }, pathfinder.ResultPath); |
| 226 | + } |
| 227 | + |
| 228 | + [Test] |
| 229 | + public void Search_TwiceWithFail_PathCleared() |
| 230 | + { |
| 231 | + /* |
| 232 | + ###_ |
| 233 | + #012 |
| 234 | + ###_ |
| 235 | + ____ |
| 236 | + */ |
| 237 | + graph.Walls.Add(new Point(0, 2)); |
| 238 | + graph.Walls.Add(new Point(0, 1)); |
| 239 | + graph.Walls.Add(new Point(0, 0)); |
| 240 | + graph.Walls.Add(new Point(1, 0)); |
| 241 | + graph.Walls.Add(new Point(2, 0)); |
| 242 | + graph.Walls.Add(new Point(2, 1)); |
| 243 | + graph.Walls.Add(new Point(2, 2)); |
| 244 | + pathfinder.Search(new Point(1, 1), new Point(1, 3)); |
| 245 | + CollectionAssert.AreEqual(new List<Point> { |
| 246 | + new Point(1, 1), |
| 247 | + new Point(1, 2), |
| 248 | + new Point(1, 3) |
| 249 | + }, pathfinder.ResultPath); |
| 250 | + |
| 251 | + |
| 252 | + /* |
| 253 | + ###_ |
| 254 | + #012 |
| 255 | + ###_ |
| 256 | + ____ |
| 257 | + */ |
| 258 | + graph.Walls.Add(new Point(1, 2)); |
| 259 | + pathfinder.Search(new Point(1, 1), new Point(1, 3)); |
| 260 | + CollectionAssert.IsEmpty(pathfinder.ResultPath); |
| 261 | + } |
| 262 | + |
| 263 | + [Test] |
| 264 | + public void MoveFromBlock() |
| 265 | + { |
| 266 | + /* |
| 267 | + ____ |
| 268 | + _01_ |
| 269 | + _#2_ |
| 270 | + __3_ |
| 271 | + */ |
| 272 | + graph.Walls.Add(new Point(1, 2)); |
| 273 | + pathfinder.Search(new Point(1, 2), new Point(2, 3)); |
| 274 | + CollectionAssert.AreEqual(new List<Point> { |
| 275 | + new Point(1, 2), |
| 276 | + new Point(2, 2), |
| 277 | + new Point(2, 3) |
| 278 | + }, pathfinder.ResultPath); |
| 279 | + } |
202 | 280 | }
|
203 | 281 | }
|
0 commit comments