Пример #1
0
		private void CheckTestAgainstControl(ImageBuffer testImage, string testTypeString)
		{
			// there is an assumtion that we got to save valid images at least once.
			string controlFileTga = testTypeString + " Control.tga";
			string imageFolder = "ControlImages";
			string testFailPathAndFileName = Path.Combine(imageFolder, testTypeString + " Test Fail.tga");
			ImageBuffer controlImage = new ImageBuffer();
			if (!Directory.Exists(imageFolder))
			{
				Directory.CreateDirectory(imageFolder);
			}
			string controlPathAndFileName = Path.Combine(imageFolder, controlFileTga);
			if (File.Exists(controlPathAndFileName))
			{
				ImageTgaIO.LoadImageData(controlImage, controlPathAndFileName);

				bool testIsSameAsControl = controlImage.Equals(testImage);
				if (!testIsSameAsControl)
				{
					// this image will be in the current output folder inside of imageFolder
					ImageTgaIO.Save(testImage, testFailPathAndFileName);
				}
				else if (File.Exists(testFailPathAndFileName))
				{
					// we don't want to have these confounding our results.
					File.Delete(testFailPathAndFileName);
				}

				Assert.IsTrue(testIsSameAsControl);
				// If you want to create new control images select SetNextStatement to inside the else condition to creat them.
			}
			else
			{
				ImageTgaIO.Save(testImage, controlPathAndFileName);
			}
		}