public void IsBorder_CorrectBorder() { // добавил ProgramImage, Calculater ProgramImage image = new ProgramImage(); Bitmap map = new Bitmap(800, 600); for (int I = 0; I < 800; I++) { for (int J = 0; J < 600; J++) { map.SetPixel(I, J, Color.Black); } } image.AddNewImage(map); Calculater item = new Calculater(image); bool correctanswer = true; int h = 3; int w = 3; int x = 1; int y = 1; //ProgramImage item = new ProgramImage(); int[,] matrix = new int[w, h]; for (int I = 0; I < w; I++) { for (int J = 0; J < h; J++) { matrix[1, 1] = 1; } } Assert.AreEqual(item.IsBorder(matrix, x, y, h, w), correctanswer); }
public void ContrastCorrect() { // changes for over 255 ProgramImage item = new ProgramImage(); int err = 0; Bitmap map = new Bitmap(1, 1); map.SetPixel(0, 0, Color.FromArgb(0, 0, 0)); item.AddNewImage(map); err = item.Contrast(0, 10); Assert.AreEqual(err, 0); }
public void IsBorder_InvalidStartPoint() { // добавил ProgramImage, Calculater ProgramImage image = new ProgramImage(); Bitmap map = new Bitmap(800, 600); for (int I = 0; I < 800; I++) { for (int J = 0; J < 600; J++) { map.SetPixel(I, J, Color.Black); } } image.AddNewImage(map); Calculater item = new Calculater(image); bool correctanswer = false; int h = 3; int w = 3; int x1 = -1; int y1 = 0; int x2 = -1; int y2 = -1; int x3 = 0; int y3 = -1; int x4 = -1; int y4 = -1; int x5 = w + 1; int y5 = 0; int x6 = w + 1; int y6 = h + 1; int x7 = 0; int y7 = h + 1; int x8 = w + 1; int y8 = h + 1; //ProgramImage item = new ProgramImage(); int[,] matrix = new int[w, h]; for (int I = 0; I < w; I++) { for (int J = 0; J < h; J++) { matrix[1, 1] = 1; } } Assert.AreEqual(item.IsBorder(matrix, x1, y1, h, w), correctanswer); Assert.AreEqual(item.IsBorder(matrix, x2, y2, h, w), correctanswer); Assert.AreEqual(item.IsBorder(matrix, x3, y3, h, w), correctanswer); Assert.AreEqual(item.IsBorder(matrix, x4, y4, h, w), correctanswer); Assert.AreEqual(item.IsBorder(matrix, x5, y5, h, w), correctanswer); Assert.AreEqual(item.IsBorder(matrix, x6, y6, h, w), correctanswer); Assert.AreEqual(item.IsBorder(matrix, x7, y7, h, w), correctanswer); Assert.AreEqual(item.IsBorder(matrix, x8, y8, h, w), correctanswer); }
public void PerimetrNoMatrix() { // добавил ProgramImage, Calculater ProgramImage image = new ProgramImage(); Bitmap map = new Bitmap(800, 600); for (int I = 0; I < 800; I++) { for (int J = 0; J < 600; J++) { map.SetPixel(I, J, Color.Black); } } image.AddNewImage(map); Calculater item = new Calculater(image); int count = 0; count = item.Perimetr(null, 2, 800, 600); Assert.AreEqual(count, -1); }
public void SquareCalculate_InvalidHeightToCalculate_Above() { // добавил ProgramImage, Calculater ProgramImage image = new ProgramImage(); Bitmap map = new Bitmap(800, 600); for (int I = 0; I < 800; I++) { for (int J = 0; J < 600; J++) { map.SetPixel(I, J, Color.Black); } } image.AddNewImage(map); Calculater item = new Calculater(image); int correctanswer = -2; int x = 2; int y = 5; int h = 10; int w = 10; int invalid_h = 12; int num = 1; int[,] matrix = new int[w, h]; for (int I = 0; I < w; I++) { for (int J = 0; J < h; J++) { if (I == 5 && J == 5) { matrix[I, J] = 1; } else { matrix[I, J] = 0; } } } //ProgramImage item = new ProgramImage(); Assert.AreEqual(item.SquareCalculate(x, y, num, matrix, invalid_h, w), correctanswer); }
public void PerimetrNegativeNum() { // добавил ProgramImage, Calculater ProgramImage image = new ProgramImage(); Bitmap map = new Bitmap(800, 600); for (int I = 0; I < 800; I++) { for (int J = 0; J < 600; J++) { map.SetPixel(I, J, Color.Black); } } image.AddNewImage(map); Calculater item = new Calculater(image); int count = 0; int[,] matr = new int[1, 1]; matr[0, 0] = 2; count = item.Perimetr(matr, -1, 2000, 2000); Assert.AreEqual(count, -1); }
public void SquareCalculate_CorrectCalculate() { // добавил создание ProgramImage и добавил картинку ProgramImage image = new ProgramImage(); Bitmap map = new Bitmap(800, 600); for (int I = 0; I < 800; I++) { for (int J = 0; J < 600; J++) { map.SetPixel(I, J, Color.Black); } } image.AddNewImage(map); int correctanswer = 99; Calculater item = new Calculater(image); int x = 2; int y = 2; int num = 1; int h = 10; int w = 10; int[,] matrix = new int[w, h]; for (int I = 0; I < w; I++) { for (int J = 0; J < h; J++) { if (I == 5 && J == 5) { matrix[I, J] = 1; } else { matrix[I, J] = 0; } } } Assert.AreEqual(item.SquareCalculate(x, y, num, matrix, h, w), correctanswer); }
public void IsBorder_NullMatrix() { // добавил ProgramImage, Calculater ProgramImage image = new ProgramImage(); Bitmap map = new Bitmap(800, 600); for (int I = 0; I < 800; I++) { for (int J = 0; J < 600; J++) { map.SetPixel(I, J, Color.Black); } } image.AddNewImage(map); Calculater item = new Calculater(image); bool correctanswer = false; int h = 3; int w = 3; int x = 1; int y = 1; //ProgramImage item = new ProgramImage(); Assert.AreEqual(item.IsBorder(null, x, y, h, w), correctanswer); }
public void SquareCalculate_InvalidStartPointToCalculate_Less() { // добавил ProgramImage, Calculater ProgramImage image = new ProgramImage(); Bitmap map = new Bitmap(800, 600); for (int I = 0; I < 800; I++) { for (int J = 0; J < 600; J++) { map.SetPixel(I, J, Color.Black); } } image.AddNewImage(map); Calculater item = new Calculater(image); int correctanswer = 0; int x1 = -1; int y1 = 0; int x2 = -1; int y2 = -1; int x3 = 0; int y3 = -1; int x4 = -1; int y4 = -1; int x5 = 11; int y5 = 0; int x6 = 11; int y6 = 11; int x7 = 0; int y7 = 11; int x8 = 11; int y8 = 11; int h = 10; int w = 10; int num = 1; int[,] matrix = new int[w, h]; for (int I = 0; I < w; I++) { for (int J = 0; J < h; J++) { if (I == 5 && J == 5) { matrix[I, J] = 1; } else { matrix[I, J] = 0; } } } //ProgramImage item = new ProgramImage(); Assert.AreEqual(item.SquareCalculate(x1, y1, num, matrix, h, w), correctanswer); Assert.AreEqual(item.SquareCalculate(x2, y2, num, matrix, h, w), correctanswer); Assert.AreEqual(item.SquareCalculate(x3, y3, num, matrix, h, w), correctanswer); Assert.AreEqual(item.SquareCalculate(x4, y4, num, matrix, h, w), correctanswer); Assert.AreEqual(item.SquareCalculate(x5, y5, num, matrix, h, w), correctanswer); Assert.AreEqual(item.SquareCalculate(x6, y6, num, matrix, h, w), correctanswer); Assert.AreEqual(item.SquareCalculate(x7, y7, num, matrix, h, w), correctanswer); Assert.AreEqual(item.SquareCalculate(x8, y8, num, matrix, h, w), correctanswer); }