public bool InvasionDetected() { var currentradarImage = Radar.CurrentImage(); Image knownInvader; int numberOfInvadersDetected = 0; while ((knownInvader = Repository.Next()) != null) { if (Palantir.Match(currentradarImage, knownInvader)) { numberOfInvadersDetected++; } } return(numberOfInvadersDetected > 0); }
public void TestInvasionByFakeInvaderExtractedFromRadarImage() { var radar = new StaticRadar(); var palantir = new Palantir(); var invader = new Image(new List <string> { "----ooo----o-oooo---", "-o-----o------------", "------oooo----------", "---o-o--------------", "--o--------o--o---oo", "-----------------o--", "-o---o--o-oo--o--o-o", "--oo-----o----o-----" }); var match = palantir.Match(radar.CurrentImage(), invader); Assert.IsTrue(match); }
public void TestInvasionByInvader1() { var radar = new StaticRadar(); var palantir = new Palantir(); var invader1 = new Image(new List <string> { "--o-----o--", "---o---o---", "--ooooooo--", "-oo-ooo-oo-", "ooooooooooo", "o-ooooooo-o", "o-o-----o-o", "---oo-oo---" }); var match = palantir.Match(radar.CurrentImage(), invader1); Assert.IsFalse(match); }