public void TestCropImage() { Bitmap sourceImage = new Bitmap(quizImgDir + "\\1.png"); Rectangle rec = new Rectangle(400, 250, 1200, 150); QuizSolver.CropImage(sourceImage, rec); }
public void TestGetQuizPattern() { // All water Bitmap sourceImage = new Bitmap(quizImgDir + "\\1.png"); string pattern = QuizSolver.GetQuizPattern(sourceImage, 1920, 1080); Assert.AreEqual(QuizSolver.ALL_WATER, pattern); }
public void TestCropQuiz() { string path = quizImgDir + "\\1.png"; //string path = @"C:\TestWin32\720-1.png"; Bitmap source = new Bitmap(path); for (int i = 1; i <= 8; i++) { QuizSolver.GetAnswer(source, i); } }
private string TryGetQuizPattern() { string pattern = string.Empty; for (int i = 0; i < 3; i++) { pattern = QuizSolver.GetQuizPattern(Emulator.PrintWindow(), Emulator.Width, Emulator.Height); if (!string.IsNullOrEmpty(pattern)) { break; } } return(pattern); }
public void TestMatchImage() { NoxEmulator emulator = new NoxEmulator(); IntPtr parent = AbstractEmulator.FindWindow("Qt5QWindowIcon", "Nox"); Bitmap source = emulator.PrintWindow(parent); Bitmap crop = BitmapUtils.CropImage(source, new Rectangle(800, 550, 400, 200)); string test1 = @"C:\Users\Administrator\Desktop\1\dungeonEnergy.png"; string test2 = @"E:\SWRunner\Resources\general\gift_box.png"; Assert.AreEqual(1, QuizSolver.FindMatchImage(crop, new Bitmap(test2))); }
public void CreateGrayImages() { string testScreenPath = quizImgDir + "\\10.png"; Bitmap testScreen = new Bitmap(testScreenPath); string quizPattern = QuizSolver.ANGELMON; //Assert.AreEqual(QuizSolver.BOSS, quizPattern); string actual = ""; for (int i = 1; i <= 8; i++) { (Point point, Bitmap img)answer = QuizSolver.GetAnswer(testScreen, i); if (QuizSolver.IsCorrectAnswer(answer, quizPattern, 1280, 720)) { actual += i; //emulator.Click(answer.point); } } }
public void CheckRefill() { if (NeedRefill()) { Debug.WriteLine("Perform refill"); Emulator.Click(RunnerConfig.OpenShopPoint); Helper.Sleep(2000, 3000); Emulator.Click(RunnerConfig.BuyEnergyWithCrystalPoint); Helper.Sleep(1000, 2000); string pattern = TryGetQuizPattern(); if (!string.IsNullOrEmpty(pattern)) { while (!string.IsNullOrEmpty(pattern)) { Debug.Write("Try to solve: " + pattern); QuizSolver.SolveQuiz(Emulator); Thread.Sleep(3000); Emulator.PressEsc(); Thread.Sleep(1000); pattern = TryGetQuizPattern(); } } Emulator.Click(RunnerConfig.ConfirmBuyPoint); Helper.Sleep(8000, 10000); Emulator.Click(RunnerConfig.BuyOKPoint); Helper.Sleep(1500, 2000); Emulator.Click(RunnerConfig.CloseShopPoint); Helper.Sleep(1500, 2000); Emulator.Click(RunnerConfig.ReplayPoint); } Debug.WriteLine("No need to refill"); }
public void TestCorrectAnswerAngelmon() { string testScreenPath = quizImgDir + "\\2.png"; Bitmap testScreen = new Bitmap(testScreenPath); string quizPattern = QuizSolver.GetQuizPattern(testScreen, 1920, 1080); Assert.AreEqual(QuizSolver.ANGELMON, quizPattern); string actual = ""; for (int i = 1; i <= 8; i++) { (Point point, Bitmap img)answer = QuizSolver.GetAnswer(testScreen, i); if (QuizSolver.IsCorrectAnswer(answer, quizPattern, 1920, 1080)) { actual += i; //emulator.Click(answer.point); } } string expected = "136"; Assert.AreEqual(expected, actual); }
public void TestCorrectAnswerEllia() { string testScreenPath = quizImgDir + "\\9.png"; Bitmap testScreen = new Bitmap(testScreenPath); string quizPattern = QuizSolver.GetQuizPattern(testScreen, 1280, 720); Assert.AreEqual(QuizSolver.ELLIA, quizPattern); string actual = ""; for (int i = 1; i <= 8; i++) { (Point point, Bitmap img)answer = QuizSolver.GetAnswer(testScreen, i); if (QuizSolver.IsCorrectAnswer(answer, quizPattern, 1280, 720)) { actual += i; //emulator.Click(answer.point); } } string expected = "35"; Assert.AreEqual(expected, actual); }
public void TestQuiz() { NoxEmulator emulator = new NoxEmulator(); QuizSolver.SolveQuiz(emulator); }