public static void MyClassInitialize(TestContext testContext) { NoiseGenerator noiGen = new NoiseGenerator(); original = noiGen.getMemento(); testBitmap = new Bitmap(testPixel, testPixel); for (int height = 0; height < testBitmap.Height; height++) { for (int width = 0; width < testBitmap.Width; width++) { testBitmap.SetPixel(width, height, Color.White); width++; testBitmap.SetPixel(width, height, Color.Black); width++; testBitmap.SetPixel(width, height, Color.Red); width++; testBitmap.SetPixel(width, height, Color.Green); width++; testBitmap.SetPixel(width, height, Color.Blue); } } testNoise = new Memento("test", 5.1F); }
public void getMementoTest() { NoiseGenerator target = new NoiseGenerator(); Memento expected = original; Memento actual; actual = target.getMemento(); float expectedMean = (float)expected.state; float actualMean = (float)actual.state; Assert.AreEqual(expectedMean, actualMean); }
public void setMementoTest() { NoiseGenerator target = new NoiseGenerator(); Memento memento = testNoise; target.setMemento(memento); float actualMean = (float)target.getMemento().state; float expectedMean = (float)memento.state; Assert.AreEqual(expectedMean, actualMean, "Memento was not set right. "); }
public void processTest() { NoiseGenerator target = new NoiseGenerator(); Bitmap frame = testBitmap; float expectedMean = (float)target.getMemento().state; Bitmap actual; actual = target.process(frame); float actualMean = 0; for (int height = 0; height < actual.Height; height++) { for (int width = 0; width < actual.Width; width++) { if (!frame.GetPixel(width, height).Equals(actual.GetPixel(width, height))) { actualMean++; } } } Assert.AreEqual(expectedMean, actualMean, "Process does not work with mean. "); }