protected virtual TestCaseData GenerateRandomTestCaseData(int matrixSize, Random randomizer, MaskPatternType pattern, PenaltyRules rules)
        {
        	ByteMatrix matrix;
            
			BitMatrix bitmatrix = GetOriginal(matrixSize, randomizer, out matrix);
			
			ApplyPattern(matrix, (int)pattern);
			
			int expect;
			
			switch(rules)
			{
				case PenaltyRules.Rule01:
					expect = MaskUtil.applyMaskPenaltyRule1(matrix);
					break;
				case PenaltyRules.Rule02:
					expect = MaskUtil.applyMaskPenaltyRule2(matrix);
					break;
				case PenaltyRules.Rule03:
					expect = MaskUtil.applyMaskPenaltyRule3(matrix);
					break;
				case PenaltyRules.Rule04:
					expect = MaskUtil.applyMaskPenaltyRule4(matrix);
					break;
				default:
					throw new InvalidOperationException(string.Format("Unsupport Rules {0}", rules.ToString()));
			}
			
			
            BitMatrix input = matrix.ToBitMatrix();
            
            return new TestCaseData(input, (int)rules, expect).SetName(string.Format(s_TestNameFormat, input.Width, rules.ToString(), expect));
        }
Exemplo n.º 2
0
        public static void GenerateFaultyRecord(BitMatrix matrix, PenaltyRules penaltyRule, int expected, int actual)
        {
            string path = Path.Combine(Path.GetTempPath(), s_TxtFileName);

            if (!File.Exists(path))
            {
                using (StreamWriter file = File.CreateText(path))
                {
                    file.WriteLine();
                }
            }

            using (var file = File.AppendText(path))
            {
                file.Write(penaltyRule.ToString());
                file.Write(string.Format(" Expected: {0}, Actual: {0}", expected.ToString(), actual.ToString()));
                matrix.ToGraphic(file);
                file.WriteLine("=====");
                file.Close();
            }
        }
Exemplo n.º 3
0
 public static void GenerateFaultyRecord(BitMatrix matrix, PenaltyRules penaltyRule, int expected, int actual)
 {
     string path = Path.Combine(Path.GetTempPath(), s_TxtFileName);
     
     if(!File.Exists(path))
     {
     	using (StreamWriter file = File.CreateText(path)) 
       	{
     		file.WriteLine();
     	}
     }
     
     using (var file = File.AppendText(path))
     {
     	file.Write(penaltyRule.ToString());
     	file.Write(string.Format(" Expected: {0}, Actual: {0}", expected.ToString(), actual.ToString()));
         matrix.ToGraphic(file);
         file.WriteLine("=====");
         file.Close();
         
     }
 }
        protected virtual TestCaseData GenerateRandomTestCaseData(int matrixSize, Random randomizer, MaskPatternType pattern, PenaltyRules rules)
        {
            ByteMatrix matrix;

            BitMatrix bitmatrix = GetOriginal(matrixSize, randomizer, out matrix);

            ApplyPattern(matrix, (int)pattern);

            int expect;

            switch (rules)
            {
            case PenaltyRules.Rule01:
                expect = MaskUtil.applyMaskPenaltyRule1(matrix);
                break;

            case PenaltyRules.Rule02:
                expect = MaskUtil.applyMaskPenaltyRule2(matrix);
                break;

            case PenaltyRules.Rule03:
                expect = MaskUtil.applyMaskPenaltyRule3(matrix);
                break;

            case PenaltyRules.Rule04:
                expect = MaskUtil.applyMaskPenaltyRule4(matrix);
                break;

            default:
                throw new InvalidOperationException(string.Format("Unsupport Rules {0}", rules.ToString()));
            }


            BitMatrix input = matrix.ToBitMatrix();

            return(new TestCaseData(input, (int)rules, expect).SetName(string.Format(s_TestNameFormat, input.Width, rules.ToString(), expect)));
        }