From 25006ab464c81cae640cac10bb1049fec5a7def8 Mon Sep 17 00:00:00 2001 From: "SND\\floAr_cp" Date: Fri, 31 Aug 2012 09:03:27 +0000 Subject: [PATCH] Added function to DataFactory.cs to create extreme value test sets --- ANX.Framework.TestCenter/DataFactory.cs | 45 ++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/ANX.Framework.TestCenter/DataFactory.cs b/ANX.Framework.TestCenter/DataFactory.cs index 4d618b4d..edc4b352 100644 --- a/ANX.Framework.TestCenter/DataFactory.cs +++ b/ANX.Framework.TestCenter/DataFactory.cs @@ -15,8 +15,51 @@ namespace ANX.Framework.TestCenter class DataFactory { static Random r=new Random(); + /// + /// Create a test-dataset with a permutation of extreme value + /// + /// max. extreme + /// min. extreme + /// how many elements are used in test + /// test bundle with numberOfElements*numberOfElements test sets + public static object[] createPermutation(object maxValue, object minValue, int numberOfElements) + { + object[] valuePair = { maxValue, minValue }; + int testCaseCount = (int)Math.Pow(numberOfElements, 2); + object[,] matrix = new object[numberOfElements, testCaseCount]; + for (int x = 0; x < numberOfElements; ++x) + { + int counter = 0; + int value = 0; + for (int y = 0; y < testCaseCount; ++y) + { - static object[] generateTestData(int numOfTests, int numOfElements,int min,int max) + matrix[x, y] = valuePair[value]; + counter++; + if (counter > x) + { + counter = 0; + if (value == 0) + value = 1; + else + value = 0; + } + } + } + object[] result = new object[testCaseCount]; + for (int y = 0; y < testCaseCount; ++y) + { + object[] line = new object[numberOfElements]; + for (int x = 0; x < numberOfElements; ++x) + { + line[x] = matrix[x, y]; + } + result[y] = line; + } + return result; + + } + static object[] generateTestData(int numOfTests, int numOfElements, int min, int max) { object[] result = new object[numOfTests];