示例#1
0
        /// <summary>
        /// Test case 6
        /// </summary>
        private static TestCaseData StraightLineChartWithCustomDataPoints()
        {
            var testData = GetTestDataSet1();

            var chart = new LineChart(testData.series, testData.labels)
            {
                Height    = 500,
                Width     = 800,
                LineType  = LineType.Straight,
                ChartArea = { SeriesStyles         = new[]
                              {
                                  new LineSeriesStyle()
                                  {
                                      ElementStyle = { StrokeColor = "#3454D1" }, MarkerStyle = { StrokeWidth = 0 }, LabelStyle = { Size = 9, StrokeColor = "black" }, DataPointLabelPosition = Position.Centre
                                  },
                                  new LineSeriesStyle()
                                  {
                                      ElementStyle = { StrokeColor = "#34D1BF" }, MarkerStyle = { StrokeWidth = 0 }, LabelStyle = { Size = 9, StrokeColor = "black" }, DataPointLabelPosition = Position.Centre
                                  },
                              } }
            };

            var testCase = new TestCaseData(chart);

            testCase.SetName("TestCase 6 - Test custom series style.");
            testCase.SetDescription("Test case 6 : Straight line chart with custom data points, only dataPoint labels are drawn in centre position");
            testCase.ExpectedResult = GetExpectedResults("TestCase-6.xml");
            return(testCase);
        }
示例#2
0
        /// <summary>
        /// Test case 20
        /// </summary>
        private static TestCaseData DocumentationSample1()
        {
            var testData = DocumentationSampleDataSet1();

            var chart = new LineChart(testData.series, testData.labels)
            {
                Height    = 500,
                Width     = 800,
                LineType  = LineType.Straight,
                ChartArea =
                {
                    SeriesStyles         = new[]
                    {
                        new LineSeriesStyle()
                        {
                            ElementStyle = { StrokeColor    = "#4674C5", StrokeWidth    = 3, StrokeOpacity          = 1 },
                            MarkerStyle  = { StrokeWidth    =       0 },
                            LabelStyle   = { Size           =         9, StrokeColor    = "#3D3D3D" },DataPointLabelPosition = Position.Centre
                        },
                    },
                    YGridLineStyle       = { MajorLineStyle = { StrokeWidth = 0.7 },MinorLineStyle = { StrokeWidth = 0.1 } }
                },
                DrawDebug = false
            };

            var testCase = new TestCaseData(chart);

            testCase.SetName("TestCase 20 - Documentation sample 1.");
            testCase.SetDescription("Test case 20 : Straight line chart with custom data points, only dataPoint labels are drawn in centre position");
            testCase.ExpectedResult = GetExpectedResults("TestCase-20.xml");
            return(testCase);
        }
示例#3
0
        /// <summary>
        /// Test case 22
        /// </summary>
        private static TestCaseData DocumentationSample3()
        {
            var testData = DocumentationSampleDataSet1();

            var chart = new LineChart(testData.series, testData.labels)
            {
                Height       = 300,
                Width        = 1500,
                LineType     = LineType.Curved,
                PaddingRight = 15,
                XAxis        = { StartOnMajor = true },
                ChartArea    =
                {
                    SeriesStyles                   = new[]
                    {
                        new LineSeriesStyle()
                        {
                            ElementStyle           = { StrokeColor = "none", StrokeWidth =       1, Fill = "#4674C5", FillOpacity = 0.4 },
                            MarkerStyle            = { StrokeWidth =      2, StrokeColor = "white", Fill = "#4674C5", Radius      =   3 },
                            LabelStyle             = { Size        =      0, StrokeColor = "#3D3D3D" },
                            DataPointLabelPosition = Position.Centre
                        }
                    }
                },
                DrawDebug = false
            };

            var testCase = new TestCaseData(chart);

            testCase.SetName("TestCase 22 - Documentation sample 3.");
            testCase.SetDescription("Test case 22 : Curved line with a fill, where the min value is 0");
            testCase.ExpectedResult = GetExpectedResults("TestCase-22.xml");
            return(testCase);
        }
示例#4
0
        /// <summary>
        /// Test case 4
        /// </summary>
        private static TestCaseData CurvedLineChartWithDataPoints()
        {
            //TODO : DataPoints are not drawn at the correct position

            var testData = GetTestDataSet2();

            var chart = new LineChart(testData.series, testData.labels)
            {
                Height   = 500,
                Width    = 800,
                LineType = LineType.Curved,
            };

            var testCase = new TestCaseData(chart);

            testCase.SetName("TestCase 4 - Test data markers");
            testCase.SetDescription("Test case 4 : line chart with 1 series and the following all elements draw :\r\n" +
                                    "- curved lines\r\n" +
                                    "- DataPoints drawn\r\n" +
                                    "- X axis with labels, and major ticks\r\n" +
                                    "- Y axis with labels, and major ticks\r\n" +
                                    "- Legend with label and circle icon\r\n");
            testCase.ExpectedResult = GetExpectedResults("TestCase-4.xml");
            return(testCase);
        }
示例#5
0
        /// <summary>
        /// Test case 8
        /// </summary>
        private static TestCaseData BasicLineChartWithDashedAndDottedGridlines()
        {
            var testData = GetTestDataSet2();

            var chart = new LineChart(testData.series, testData.labels)
            {
                Height       = 500,
                Width        = 800,
                DrawDebug    = false,
                PaddingRight = 15,
                ChartArea    =
                {
                    YGridLineStyle     =
                    {
                        MajorLineStyle = { StrokeWidth = 0.7, StrokeStyle = LineStyle.Dashed },
                        MinorLineStyle = { StrokeWidth = 0.5, StrokeStyle = LineStyle.Dotted }
                    }
                }
            };

            var testCase = new TestCaseData(chart);

            testCase.SetName("TestCase 8 - Test path stroke style");
            testCase.SetDescription("Test case 8 : Basic line chart with dashed major and dotted minor gridlines");
            testCase.ExpectedResult = GetExpectedResults("TestCase-8.xml");
            return(testCase);
        }
示例#6
0
        public IEnumerable GetObservations()
        {
            var t = GetType();

            var categoryName = "Uncategorized";
            var description  = string.Empty;

#if NET_STANDARD
            var categoryAttributes = t.GetTypeInfo().CustomAttributes.Where(ca => ca.AttributeType == typeof(CategoryAttribute));
            var subjectAttributes  = t.GetTypeInfo().CustomAttributes.Where(ca => ca.AttributeType == typeof(SubjectAttribute));
#else
            var categoryAttributes = t.GetCustomAttributes(typeof(CategoryAttribute), true);
            var subjectAttributes  = t.GetCustomAttributes(typeof(SubjectAttribute), true);
#endif

#if NET_STANDARD
            if (categoryAttributes.Any())
            {
                categoryName = categoryAttributes.First().ConstructorArguments[0].Value.ToString();
#else
            if (categoryAttributes.Length > 0)
            {
                var categoryAttribute = (CategoryAttribute)categoryAttributes[0];
                categoryName = categoryAttribute.Name;
#endif
            }

#if NET_STANDARD
            if (subjectAttributes.Any())
            {
                description = subjectAttributes.First().ConstructorArguments[0].Value.ToString();
#else
            if (subjectAttributes.Length > 0)
            {
                var subjectAttribute = (SubjectAttribute)subjectAttributes[0];
                description = subjectAttribute.Subject;
#endif
            }

            var fieldInfos   = t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
            var itFieldInfos = new List <FieldInfo>();

            foreach (var info in fieldInfos)
            {
                if (info.FieldType.Name.Equals("It"))
                {
                    itFieldInfos.Add(info);
                }
            }

            foreach (var it in itFieldInfos)
            {
                var data = new TestCaseData(it.GetValue(this));
                data.SetDescription(description);
                data.SetName(it.Name.Replace("_", " "));
                data.SetCategory(categoryName);
                yield return(data);
            }
        }
示例#7
0
        public static TestCaseData CreateTestCaseData(object data, string testName, string testDescription)
        {
            TestCaseData testData = new TestCaseData(data);

            testData.SetName(testName);
            testData.SetDescription(testDescription);
            return(testData);
        }
示例#8
0
        private static TestCaseData MakeTestCase(TestScenario scenario)
        {
            var testCaseData = new TestCaseData(scenario);

            testCaseData.SetDescription(scenario.Description);
            testCaseData.SetName(scenario.Name ?? "unnamed test");
            return(testCaseData);
        }
示例#9
0
        /// <summary>
        /// Test case 11
        /// </summary>
        private static TestCaseData LineChartDataWithNullLabels()
        {
            var testCase = new TestCaseData(GetTestDataSet1().series, null);

            testCase.SetName("TestCase 11 - Line chart with NULL values and valid series");
            testCase.SetDescription("Test case 11 : Argument exception expected");
            return(testCase);
        }
示例#10
0
        /// <summary>
        /// Test case 2
        /// </summary>
        private static TestCaseData BasicLineChart()
        {
            var testData = GetTestDataSet2();

            var chart = new LineChart(testData.series, testData.labels)
            {
                Height    = 500,
                Width     = 800,
                ChartArea =
                {
                    SeriesStyles                   = new[]
                    {
                        new LineSeriesStyle()
                        {
                            LabelStyle             =
                            {
                                Fill = "black",
                                Size = 3
                            },
                            DataPointLabelPosition = Position.Bottom,
                            ElementStyle           =
                            {
                                Fill        = "none",
                                StrokeColor = "green"
                            },
                            MarkerStyle            = new MarkerStyle()
                            {
                                StrokeColor = "black",
                                Radius      = 3
                            }
                        },
                    }
                },
                XAxis =
                {
                    LabelStyle     = { Size        = 16, Fill        = "black" },
                    MajorTickStyle = { StrokeWidth =  1, Length      =5, StrokeColor = "green" },
                    BaseLineStyle  = { StrokeWidth =  1, StrokeColor = "green" }
                },
                YAxis =
                {
                    LabelStyle     = { Size        = 16, Fill        = "black" },
                    MajorTickStyle = { StrokeWidth =  1, Length      =5, StrokeColor = "green" },
                    BaseLineStyle  = { StrokeWidth =  1, StrokeColor = "green" }
                },
            };

            var testCase = new TestCaseData(chart);

            testCase.SetName("TestCase 2 - Test default straight line chart");
            testCase.SetDescription("Test case 2 : line chart with 1 series and the following all elements draw :\r\n" +
                                    "- Straight lines\r\n" +
                                    "- X axis with labels, and major ticks\r\n" +
                                    "- Y axis with labels, and major ticks\r\n" +
                                    "- Legend with label and circle icon\r\n");
            testCase.ExpectedResult = GetExpectedResults("TestCase-2.xml");
            return(testCase);
        }
示例#11
0
        private static TestCaseData CreateTestCaseData <TTestData>(TTestData data, string testName, string testCategory, string testDescription)
        {
            var tcData = new TestCaseData(data);

            tcData.SetCategory(testCategory);
            tcData.SetDescription(testDescription);
            tcData.SetName(testName);
            return(tcData);
        }
示例#12
0
        /// <summary>
        /// Test case 12
        /// </summary>
        private static TestCaseData LineChartWithDashSeries()
        {
            var testData = GetTestDataSet2();

            var chart = new LineChart(testData.series, testData.labels)
            {
                Height    = 500,
                Width     = 800,
                ChartArea =
                {
                    ChartAreaStyle = { StrokeWidth = 0.5 },
                    SeriesStyles   = new[]
                    {
                        new LineSeriesStyle()
                        {
                            LabelStyle             =
                            {
                                Fill = "black",
                                Size = 3
                            },
                            DataPointLabelPosition = Position.Bottom,
                            ElementStyle           =
                            {
                                Fill        = "none",
                                StrokeColor = "green",
                                StrokeStyle = LineStyle.Dashed
                            },
                            MarkerStyle            = new MarkerStyle()
                            {
                                StrokeColor = "black",
                                Radius      = 3
                            }
                        },
                    }
                },
                XAxis =
                {
                    LabelStyle     = { Size        = 16, Fill        = "black" },
                    MajorTickStyle = { StrokeWidth =  1, Length      =5, StrokeColor = "green" },
                    BaseLineStyle  = { StrokeWidth =  1, StrokeColor = "green" }
                },
                YAxis =
                {
                    LabelStyle     = { Size        = 16, Fill        = "black" },
                    MajorTickStyle = { StrokeWidth =  1, Length      =5, StrokeColor = "green" },
                    BaseLineStyle  = { StrokeWidth =  1, StrokeColor = "green" }
                },
            };

            var testCase = new TestCaseData(chart);

            testCase.SetName("TestCase 12 - Test dashed line type");
            testCase.SetDescription("Test case 12 : line chart with 1 series dashed line");
            testCase.ExpectedResult = GetExpectedResults("TestCase-12.xml");
            return(testCase);
        }
示例#13
0
        /// <summary>
        /// Test case 10
        /// </summary>
        private static TestCaseData LineChartDataWithNullSeries()
        {
            var testData = GetTestDataSet1();

            var testCase = new TestCaseData(null, testData.labels);

            testCase.SetName("TestCase 10 - Line chart with NULL series and valid labels");
            testCase.SetDescription("Test case 10 : Argument exception expected");
            return(testCase);
        }
示例#14
0
        /// <summary>
        /// Debug: 1 Axis Labels not centered
        /// </summary>
        private static TestCaseData DebugXAxisLabels()
        {
            var series = JsonConvert.DeserializeObject <ChartSeries[]>("[ { 'seriesName': 'Skynet', 'dataValues': [ null, null, null, null, null, null, null, null, 82.0, 55.0, 128.0, 3.0, 139.0, 90.0 ], 'dataPoints': [], 'style': null, 'color': null } ]");
            var labels = JsonConvert.DeserializeObject <string[]>("[ 'Mar 2019', 'Apr 2019', 'May 2019', 'Jun 2019', 'Jul 2019', 'Aug 2019', 'Sep 2019', 'Oct 2019', 'Nov 2019', 'Dec 2019', 'Jan 2020', 'Feb 2020', 'Mar 2020', 'Apr 2020' ]");

            var testCase = new TestCaseData(series, labels);

            testCase.SetName("Debug 1 - Axis Labels not centered");
            testCase.SetDescription("Debug 1 - Axis Labels not centered");
            return(testCase);
        }
示例#15
0
        /// <summary>
        /// Debug: Partial series joining
        /// </summary>
        private static TestCaseData DebugPartialSeriesJoining()
        {
            var series = JsonConvert.DeserializeObject <ChartSeries[]>("[ { 'seriesName': '2019-2020', 'dataValues': [ null, null, null, 82.0, 55.0, 128.0, 3.0, 139.0, 90.0, null, null, null ], 'dataPoints': [], 'style': null, 'color': null }, { 'seriesName': 'Forecast usage', 'dataValues': [ null, null, null, null, null, null, null, null, 90.0, 77.33, 102.11, 89.81 ], 'dataPoints': [], 'style': null, 'color': null } ]");
            var labels = JsonConvert.DeserializeObject <string[]>("[ 'Aug 2019', 'Sep 2019', 'Oct 2019', 'Nov 2019', 'Dec 2019', 'Jan 2020', 'Feb 2020', 'Mar 2020', 'Apr 2020', 'May 2020', 'Jun 2020', 'Jul 2020' ]");

            var testCase = new TestCaseData(series, labels);

            testCase.SetName("Debug 2 - 2 partial series");
            testCase.SetDescription("Debug 2 - 2 partial series needs to appear like a single line, but the first series adds 0 instead of nulls at the end");
            return(testCase);
        }
示例#16
0
        /// <summary>
        /// Debug: Argument exception
        /// </summary>
        private static TestCaseData DebugTest3()
        {
            var series = JsonConvert.DeserializeObject <ChartSeries[]>("[{\"SeriesName\":\"2019-2020\",\"DataValues\":[null,null,null,null,1.0,0.0,0.0,0.0,2.0,null,null,null],\"DataPoints\":[],\"Style\":null,\"Color\":null},{\"SeriesName\":\"Forecast usage\",\"DataValues\":[null,null,null,null,null,null,null,null,2.0,0.67,0.89,1.19],\"DataPoints\":[],\"Style\":null,\"Color\":null},{\"SeriesName\":\"Trend\",\"DataValues\":[0.12,0.14,0.16,0.19,0.21,0.24,0.26,0.29,0.31,0.34,0.36,0.38],\"DataPoints\":[],\"Style\":{\"IsDefaultStyle\":false,\"LabelStyle\":{\"Font\":\"Arial\",\"Draw\":false,\"StrokeWidth\":0,\"WidthPixels\":0.0,\"HeightPixels\":0.0,\"Size\":0,\"Fill\":\"grey\",\"FillOpacity\":1.0,\"StrokeOpacity\":1.0,\"StrokeColor\":\"none\",\"HasFill\":true,\"Overflow\":0},\"DrawLabel\":false,\"DataPointLabelPosition\":0,\"MarkerStyle\":{\"Radius\":0.0,\"Fill\":\"none\",\"FillOpacity\":1.0,\"StrokeOpacity\":1.0,\"StrokeColor\":\"grey\",\"StrokeWidth\":0.0,\"Draw\":false,\"HasFill\":false,\"Overflow\":0},\"ElementStyle\":{\"Fill\":\"none\",\"FillOpacity\":1.0,\"StrokeOpacity\":0.4,\"StrokeColor\":\"#F37748\",\"StrokeWidth\":4.0,\"Draw\":true,\"HasFill\":false,\"Overflow\":0}},\"Color\":null}]");
            var labels = JsonConvert.DeserializeObject <string[]>("[\"Sep 2019\",\"Oct 2019\",\"Nov 2019\",\"Dec 2019\",\"Jan 2020\",\"Feb 2020\",\"Mar 2020\",\"Apr 2020\",\"May 2020\",\"Jun 2020\",\"Jul 2020\",\"Aug 2020\"]");

            var testCase = new TestCaseData(series, labels);

            testCase.SetName("Debug 3 - Exception during YAxis export");
            testCase.SetDescription("Exception when exporting YAxis data");
            return(testCase);
        }
示例#17
0
        /// <summary>
        /// Debug: Incorrect dataPoints
        /// </summary>
        private static TestCaseData DebugTest4()
        {
            var series = JsonConvert.DeserializeObject <ChartSeries[]>("[ { \"seriesName\": \"Usage\", \"dataValues\": [ 1332.0, 1536.0, 1631.0, 1900.0, 2367.0, 2285.0, 4245.0, 5499.0, 4595.0, null, null, null, null, null ], \"dataPoints\": [], \"style\": null, \"color\": null } ]");
            var labels = JsonConvert.DeserializeObject <string[]>("[ \"Apr 2019\", \"May 2019\", \"Jun 2019\", \"Jul 2019\", \"Aug 2019\", \"Sep 2019\", \"Oct 2019\", \"Nov 2019\", \"Dec 2019\", \"Jan 2020\", \"Feb 2020\", \"Mar 2020\", \"Apr 2020\", \"May 2020\" ]");

            var testCase = new TestCaseData(series, labels);

            testCase.SetName("Debug 4 - DataPoints looks wrong");
            testCase.SetDescription("Testing dataPoints");
            return(testCase);
        }
示例#18
0
        /// <summary>
        /// Provide tests from the tests.json file.
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <TestCaseData> ProvideTests()
        {
            var str  = File.ReadAllText($"{RootDirectory}/tests.json");
            var json = JObject.Parse(str);

            foreach (var o in json)
            {
                var data = new TestCaseData(o.Key, o.Value);
                data.SetDescription(o.Key);
                yield return(data);
            }
        }
示例#19
0
        /// <summary>
        /// Test case 9
        /// </summary>
        private static TestCaseData ChartWithPartialSeries()
        {
            var testData = GetTestDataSet4();

            var chart    = new LineChart(testData.series, testData.labels);
            var testCase = new TestCaseData(chart);

            testCase.SetName("TestCase 9 - Test partial series");
            testCase.SetDescription("Test case 9 : Test chart with partial series");
            testCase.ExpectedResult = GetExpectedResults("TestCase-9.xml");
            return(testCase);
        }
示例#20
0
            TestCaseData GenPayData
                (int fullYears, double expectedPay, Exception exception = null)
            {
                TestCaseData data = GenData(fullYears);

                data.SetDescription(string.Format(descriptionPatternPay, fullYears, expectedPay));
                if (exception != null)
                {
                    data.Throws(exception.GetType());
                }
                else
                {
                    data.Returns(expectedPay);
                }
                return(data);
            }
        public IEnumerable GetObservations()
        {
            Type currentType = GetType();

            string categoryName = "Uncategorized";
            string description  = string.Empty;

            IEnumerable <CategoryAttribute> categoryAttributes =
                currentType.GetTypeInfo().GetCustomAttributes(typeof(CategoryAttribute), true)
                .OfType <CategoryAttribute>()
                .ToArray();

            IEnumerable <SubjectAttribute> subjectAttributes =
                currentType.GetTypeInfo().GetCustomAttributes(typeof(SubjectAttribute), true).OfType <SubjectAttribute>()
                .ToArray();

            if (categoryAttributes.Any())
            {
                CategoryAttribute categoryAttribute = categoryAttributes.First();
                categoryName = categoryAttribute.Name;
            }

            if (subjectAttributes.Any())
            {
                //SubjectAttribute subjectAttribute = subjectAttributes.First();
                //description = subjectAttribute.Subject;
            }

            FieldInfo[] fieldInfos = currentType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic |
                                                           BindingFlags.FlattenHierarchy);

            FieldInfo[] itFieldInfos = fieldInfos.Where(field => field.FieldType == typeof(Then)).ToArray();

            foreach (FieldInfo thenFieldInfo in itFieldInfos)
            {
                var data = new TestCaseData(thenFieldInfo.GetValue(this));

                string caseDescription = (string.IsNullOrWhiteSpace(description) ? thenFieldInfo.Name : description)
                                         .NormalizeTestName().EnsureStartsWithPrefix();
                data.SetDescription(caseDescription);
                data.SetName(thenFieldInfo.Name.NormalizeTestName().EnsureStartsWithPrefix() + " [" +
                             thenFieldInfo.Name + "]");
                data.SetCategory(categoryName);

                yield return(data);
            }
        }
示例#22
0
        /// <summary>
        /// Test case 1
        /// </summary>
        private static TestCaseData LineChartWithAllElements()
        {
            var testData = GetTestDataSet1();

            var chart = new LineChart(testData.series, testData.labels, drawDefaultDataPointLabels: true, drawDefaultDataMarkers: true)
            {
                Height          = 500,
                Width           = 800,
                BackgroundColor = "#CCCCCC",
                LineType        = LineType.Straight,
                Legend          = { LegendIcon = LegendIcon.Circle, LabelStyle = { } },
                XAxis           =
                {
                    MinorTickStyle = { StrokeWidth = 0.25, Length = 3 },
                    MajorTickStyle = { StrokeWidth =  0.5, Length = 5 }
                },
                YAxis =
                {
                    MinorTickStyle = { StrokeWidth = 0.25, Length = 3 },
                    MajorTickStyle = { StrokeWidth =  0.5, Length = 5 }
                },
                ChartArea =
                {
                    ChartAreaStyle = { StrokeWidth    = 0.5 },
                    XGridLineStyle = { MajorLineStyle = { StrokeWidth = 0.5}, MinorLineStyle                 = { StrokeWidth = 0.25 } },
                    YGridLineStyle = { MajorLineStyle = { StrokeWidth = 0.5}, MinorLineStyle                 = { StrokeWidth = 0.25 } },
                },
                Title     = { Text = "Test Case 1", },
                DrawDebug = false
            };

            var testCase = new TestCaseData(chart);

            testCase.SetName("TestCase 1 - Test most chart features");
            testCase.SetDescription("Test case 1 : line chart with 3 series and the following all elements draw :\r\n" +
                                    "- Straight lines\r\n" +
                                    "- DataPoints drawn\r\n" +
                                    "- DataPointLabels drawn\r\n" +
                                    "- Major and minor X grid lines\r\n" +
                                    "- Major and minor Y grid lines\r\n" +
                                    "- X axis with labels, minor and major ticks\r\n" +
                                    "- Y axis with labels, minor and major ticks\r\n" +
                                    "- Legend with label and circle icon\r\n");
            testCase.ExpectedResult = GetExpectedResults("TestCase-1.xml");
            return(testCase);
        }
示例#23
0
        /// <summary>
        /// Test case 21
        /// </summary>
        private static TestCaseData DocumentationSample2()
        {
            var testData = DocumentationSampleDataSet2();

            var chart = new LineChart(testData.series, testData.labels)
            {
                Height       = 300,
                Width        = 1500,
                LineType     = LineType.Curved,
                PaddingRight = 15,
                XAxis        = { StartOnMajor = true },
                ChartArea    =
                {
                    SeriesStyles                   = new[]
                    {
                        new LineSeriesStyle()
                        {
                            ElementStyle           = { StrokeColor = "none", StrokeWidth = 1, Fill = "#4674C5", FillOpacity = 0.4 },
                            MarkerStyle            = { StrokeWidth =    0 },
                            LabelStyle             = { Size        =      0, StrokeColor = "#3D3D3D" },
                            DataPointLabelPosition = Position.Centre
                        },
                        new LineSeriesStyle()
                        {
                            ElementStyle           = { StrokeColor = "none", StrokeWidth = 1, Fill = "#267F00", FillOpacity = 0.4 },
                            MarkerStyle            = { StrokeWidth =    0 },
                            LabelStyle             = { Size        =      0, StrokeColor = "#3D3D3D" },
                            DataPointLabelPosition = Position.Centre
                        },
                    },
                    YGridLineStyle                 =
                    {
                        MajorLineStyle = { StrokeWidth =    0.7, StrokeStyle = LineStyle.Dashed },
                        MinorLineStyle = { StrokeWidth = 0 }
                    }
                },
                DrawDebug = false
            };

            var testCase = new TestCaseData(chart);

            testCase.SetName("TestCase 21 - Documentation sample 2.");
            testCase.SetDescription("Test case 21 : Curved line chart with custom data points, only dataPoint labels are drawn in centre position");
            testCase.ExpectedResult = GetExpectedResults("TestCase-21.xml");
            return(testCase);
        }
示例#24
0
        public static IEnumerable <TestCaseData> ExtractMethodTestFactoryMethod()
        {
            string[] files = Directory.GetFiles(@"..\..\Ralph.Core.Tests\ExtractMethodTests\TestCases", "*.cs");
            foreach (var file in files)
            {
                string codefile = Path.GetFullPath(file);
                string codeText = File.ReadAllText(codefile);


                var testCaseData = new TestCaseData(codeText);
                testCaseData.SetName(Path.GetFileNameWithoutExtension(codefile));
                testCaseData.SetDescription(ParseDesc(codeText));


                yield return(testCaseData);
            }
        }
示例#25
0
        /// <summary>
        /// Debug : Weird series
        /// </summary>
        private static TestCaseData DebugTest5()
        {
            var series = new[]
            {
                new ChartSeries("Usage", new double?[] { null, null, null, null, null, null, null, null, 1.0, 0, 0, 0, 2, 386 }),
            };

            var labels = new[]
            {
                "Apr 2019", "May 2019", "Jun 2019", "Jul 2019", "Aug 2019", "Sep 2019", "Oct 2019", "Nov 2019", "Dec 2019", "Jan 2020", "Feb 2020", "Mar 2020", "Apr 2020", "May 2020"
            };

            var testCase = new TestCaseData(series, labels);

            testCase.SetName("Debug 5 - Test dataSet");
            testCase.SetDescription("Testing dataPoints");
            return(testCase);
        }
        public IEnumerable GetObservations()
        {
            var t = GetType();

            var categoryName = "Uncategorized";
            var description  = string.Empty;

            var categoryAttributes = t.GetTypeInfo().GetCustomAttributes(typeof(CategoryAttribute), true);
            var subjectAttributes  = t.GetTypeInfo().GetCustomAttributes(typeof(SubjectAttribute), true);

            if (categoryAttributes.Any())
            {
                var categoryAttribute = (CategoryAttribute)categoryAttributes.First();
                categoryName = categoryAttribute.Name;
            }

            if (subjectAttributes.Any())
            {
                var subjectAttribute = (SubjectAttribute)subjectAttributes.First();
                description = subjectAttribute.Subject;
            }

            var fieldInfos = t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic |
                                         BindingFlags.FlattenHierarchy);
            var itFieldInfos = new List <FieldInfo>();

            foreach (var info in fieldInfos)
            {
                if (info.FieldType.Name.Equals("It"))
                {
                    itFieldInfos.Add(info);
                }
            }

            foreach (var it in itFieldInfos)
            {
                var data = new TestCaseData(it.GetValue(this));
                data.SetDescription(description);
                data.SetName(it.Name.Replace("_", " "));
                data.SetCategory(categoryName);
                yield return(data);
            }
        }
示例#27
0
            private static TestCaseData GetManagerWithSubordinnatesData(int fullYears, double expectedResult, int[] gruntYears = null, int[] managersYears = null, int[] salesYears = null)
            {
                var manager       = new Organization.Manager("Manager", "Manageroff", DateTime.Now.AddYears(-fullYears), Organization.BASEPAYRATE);
                int gruntsCount   = 0;
                int managersCount = 0;
                int salesCount    = 0;

                if (gruntYears != null)
                {
                    gruntsCount = gruntYears.Length;
                    foreach (var fullYear in gruntYears)
                    {
                        GetGrunt(fullYear).SetManager(manager);
                    }
                }

                if (managersYears != null)
                {
                    managersCount = managersYears.Length;
                    foreach (var fullYear in managersYears)
                    {
                        GetManager(fullYear).SetManager(manager);
                    }
                }

                if (salesYears != null)
                {
                    salesCount = salesYears.Length;

                    foreach (var fullYear in salesYears)
                    {
                        GetSales(fullYear).SetManager(manager);
                    }
                }
                var data = new TestCaseData(manager);

                data.SetCategory(categoryName);
                data.SetDescription(string.Format(descriptionPattern, fullYears, gruntsCount, managersCount, salesCount));
                data.SetName(string.Format(namePattern, fullYears, gruntsCount + managersCount + salesCount));
                data.Returns(expectedResult);

                return(data);
            }
示例#28
0
        private IEnumerable <TestCaseData> BuildTestCases(IEnumerable <TestXml> tests)
        {
            var testCases = new List <TestCaseData>(tests.Count());

            foreach (var test in tests)
            {
                TestCaseData testCaseDataNUnit = new TestCaseData(test);
                testCaseDataNUnit.SetName(test.GetName());
                testCaseDataNUnit.SetDescription(test.Description);
                foreach (var category in test.Categories)
                {
                    testCaseDataNUnit.SetCategory(CategoryHelper.Format(category));
                }
                foreach (var property in test.Traits)
                {
                    testCaseDataNUnit.SetProperty(property.Name, property.Value);
                }

                //Assign auto-categories
                if (EnableAutoCategories)
                {
                    foreach (var system in test.Systems)
                    {
                        foreach (var category in system.GetAutoCategories())
                        {
                            testCaseDataNUnit.SetCategory(CategoryHelper.Format(category));
                        }
                    }
                }
                //Assign auto-categories
                if (EnableGroupAsCategory)
                {
                    foreach (var groupName in test.GroupNames)
                    {
                        testCaseDataNUnit.SetCategory(CategoryHelper.Format(groupName));
                    }
                }

                testCases.Add(testCaseDataNUnit);
            }
            return(testCases);
        }
        public IEnumerable <TestCaseData> TestCases()
        {
            var namespaceLength = typeof(Harness).Namespace.Length + 1;
            var assembly        = Assembly.GetExecutingAssembly();
            var resourceNames   = assembly.GetManifestResourceNames().Where(name => name.EndsWith(Extension));

            foreach (var resourceName in resourceNames)
            {
                var stream = assembly.GetManifestResourceStream(resourceName);
                var reader = new StreamReader(stream);
                var config = TestCaseConfig.Read(reader);
                config.FileName = resourceName;
                config.TestName = resourceName.Substring(namespaceLength, resourceName.Length - namespaceLength - Extension.Length);
                var testCaseData = new TestCaseData(config, reader).SetName(config.TestName);
                if (!string.IsNullOrWhiteSpace(config.Description))
                {
                    testCaseData.SetDescription(config.Description);
                }
                yield return(testCaseData);
            }
        }
示例#30
0
        /// <summary>
        /// Test case 5
        /// </summary>
        private static TestCaseData CurvedLineChartWithMultipleSeries()
        {
            var testData = GetTestDataSet3();

            var chart = new LineChart(testData.series, testData.labels)
            {
                Height   = 500,
                Width    = 800,
                LineType = LineType.Curved,
            };

            var testCase = new TestCaseData(chart);

            testCase.SetName("TestCase 5 - Test multiple series");
            testCase.SetDescription("Test case 5 : Curved line chart with 3 series with long names to force legend overflow :\r\n" +
                                    "- curved lines\r\n" +
                                    "- X axis with labels, and major ticks\r\n" +
                                    "- Y axis with labels, and major ticks\r\n" +
                                    "- Legend with label and circle icon\r\n");
            testCase.ExpectedResult = GetExpectedResults("TestCase-5.xml");
            return(testCase);
        }