Example #1
0
        public string Write(XmlTestDocument testDocument, string outputPath, Type testClass, ICompatibleList<ResourceReference<XmlTestElement>> resourceRefs)
        {
            if (!outputDirectory.Exists) {
                outputDirectory.Create();
            }

            foreach (ResourceReference<XmlTestElement> resourceRef in resourceRefs)
            {
                WriteResourceToOutputDirectory(resourceRef, testClass, outputPath);
            }

            FileInfo outputFile = new FileInfo(outputDirectory.FullName + Path.DirectorySeparatorChar + outputPath);
            if (!outputFile.Directory.Exists)
            {
                Mkdirs(outputFile.Directory);
            }

            File.WriteAllText(outputFile.FullName, testDocument.asXml());

            return outputFile.FullName;
        }
        private static void LoadTestCases(ISession session, ref long id, string filename)
        {
            XmlTestDocument document = new XmlTestDocument();

            document.LoadFile(filename);
            foreach (XmlTestCollection testCase in document.Tests)
            {
                foreach (XmlTest test in testCase)
                {
                    NtsTestCase ntsTestCase = new NtsTestCase();
                    switch (test.TestType)
                    {
                    case XmlTestType.Intersection:
                    case XmlTestType.Union:
                    case XmlTestType.Difference:
                    case XmlTestType.SymmetricDifference:
                    case XmlTestType.Boundary:
                    case XmlTestType.Centroid:
                    case XmlTestType.ConvexHull:
                    case XmlTestType.Envelope:
                    case XmlTestType.InteriorPoint:
                        ntsTestCase.GeometryResult = (IGeometry)test.Result;
                        break;

                    case XmlTestType.Contains:
                    case XmlTestType.CoveredBy:
                    case XmlTestType.Covers:
                    case XmlTestType.Crosses:
                    case XmlTestType.Disjoint:
                    case XmlTestType.Equals:
                    case XmlTestType.Intersects:
                    case XmlTestType.IsEmpty:
                    case XmlTestType.IsSimple:
                    case XmlTestType.IsValid:
                    case XmlTestType.Touches:
                    case XmlTestType.Within:
                        ntsTestCase.BooleanResult = (bool)test.Result;
                        break;

                    case XmlTestType.Relate:
                        ntsTestCase.RelatePattern = (string)test.Argument2;
                        ntsTestCase.BooleanResult = (bool)test.Result;
                        break;

                    default:
                        continue;
                    }
                    ntsTestCase.Operation   = test.TestType.ToString();
                    ntsTestCase.Description = testCase.Name + ": " + test.Description;

                    if (test.IsDefaultTarget)
                    {
                        ntsTestCase.GeometryA = test.A;
                        ntsTestCase.GeometryB = test.B;
                    }
                    else
                    {
                        ntsTestCase.GeometryA = test.B;
                        ntsTestCase.GeometryB = test.A;
                    }

                    ntsTestCase.Id = ++id;

                    Prepare(ntsTestCase);

                    session.Save(ntsTestCase);
                }
            }
        }