예제 #1
0
        static ITestResultMethod runMethodTest(
            ITestResultFactory resultFactory,
            IDrawingBackend drawingBackend,
            TestMethod testMethod,
            Action <IDrawingTarget> action)
        {
            var attribute = testMethod.Attribute;

            var width  = attribute.Width;
            var height = attribute.Height;

            using (var target = drawingBackend.CreateBitmapDrawingSurface(width, height))
            {
                ITestResultReport testReport;
                using (var drawingTarget = target.BeginDraw())
                {
                    action(drawingTarget);
                    testReport = resultFactory.Report(drawingTarget.Reports);
                }

                var bitmap = resultFactory.Bitmap(width, height, target.ExtractRawBitmap());

                return(resultFactory.Method(testMethod.Info.Name, bitmap, testReport));
            }
        }
예제 #2
0
        static ITestResultMethod[] runMethodTests(
            ITestResultFactory resultFactory,
            IDrawingBackend drawingBackend,
            object instance,
            IEnumerable <TestMethod> methods)
        {
            var results = new List <ITestResultMethod>();

            foreach (var method in methods)
            {
                var info = method.Info;

                try
                {
                    string whyNot;
                    if (!method.canTest(out whyNot))
                    {
                        if (!method.Ignorable)
                        {
                            throw new Exception(whyNot);
                        }
                        continue;
                    }

                    var methodResult = runMethodTest(resultFactory, drawingBackend, instance, method);
                    results.Add(methodResult);
                }
                catch (Exception e)
                {
                    results.Add(resultFactory.Method(info.Name, e));
                }
            }

            return(results.ToArray());
        }
예제 #3
0
        static ITestResultMethod[] runMethodTests(
            ITestResultFactory resultFactory,
            IDrawingBackend drawingBackend,
            object instance,
            IEnumerable<TestMethod> methods)
        {
            var results = new List<ITestResultMethod>();
            foreach (var method in methods)
            {
                var info = method.Info;

                try
                {
                    string whyNot;
                    if (!method.canTest(out whyNot))
                    {
                        if (!method.Ignorable)
                            throw new Exception(whyNot);
                        continue;
                    }

                    var methodResult = runMethodTest(resultFactory, drawingBackend, instance, method);
                    results.Add(methodResult);
                }
                catch (Exception e)
                {
                    results.Add(resultFactory.Method(info.Name, e));
                }
            }

            return results.ToArray();
        }
예제 #4
0
        static ITestResultMethod runMethodTest(
            ITestResultFactory resultFactory,
            IDrawingBackend drawingBackend,
            TestMethod testMethod,
            Action<IDrawingTarget> action)
        {
            var attribute = testMethod.Attribute;

            var width = attribute.Width;
            var height = attribute.Height;

            using (var target = drawingBackend.CreateBitmapDrawingSurface(width, height))
            {
                ITestResultReport testReport;
                using (var drawingTarget = target.BeginDraw())
                {
                    action(drawingTarget);
                    testReport = resultFactory.Report(drawingTarget.Reports);
                }

                var bitmap = resultFactory.Bitmap(width, height, target.ExtractRawBitmap());

                return resultFactory.Method(testMethod.Info.Name, bitmap, testReport);
            }
        }