public void TruncatedExampleSelectStatementOnChildrenExpectFailure()
        {
            DocSet  docSet   = new DocSet();
            DocFile testFile = new DocFileForTesting(Resources.ExampleValidationSelectStatementFailure, "test.md", "test.md", docSet);

            var issues = new IssueLogger();

            testFile.Scan(string.Empty, issues);

            Assert.IsEmpty(issues.Issues.Where(x => x.IsError));

            docSet.ResourceCollection.RegisterJsonResource(testFile.Resources.First());

            var testMethod = testFile.Requests.First();

            var expectedResponse = HttpParser.ParseHttpResponse(testMethod.ExpectedResponse);
            var actualResponse   = HttpParser.ParseHttpResponse(testMethod.ActualResponse);

            testMethod.ValidateResponse(actualResponse, expectedResponse, null, issues);

            Assert.IsTrue(issues.Issues.Any(x => x.Code == ValidationErrorCode.RequiredPropertiesMissing), "Error with Code = RequiredPropertiesMissing");
            Assert.IsTrue(
                issues.Issues.Any(x => x.Code == ValidationErrorCode.SkippedSimilarErrors),
                "Error with Code = SkippedSimilarErrors");
        }
        public void TruncatedExampleWithRequiredPropertiesTest()
        {
            DocSet  docSet   = new DocSet();
            DocFile testFile = new DocFileForTesting(Resources.ExampleValidateResponse, "test.md", "test.md", docSet);

            var issues = new IssueLogger();

            testFile.Scan(string.Empty, issues);

            Assert.IsEmpty(issues.Issues.Where(x => x.IsError));

            docSet.ResourceCollection.RegisterJsonResource(testFile.Resources.First());

            var testMethod = testFile.Requests.First();

            var expectedResponse = HttpParser.ParseHttpResponse(testMethod.ExpectedResponse);
            var actualResponse   = HttpParser.ParseHttpResponse(testMethod.ActualResponse);

            testMethod.ValidateResponse(actualResponse, expectedResponse, null, issues);

            Assert.AreEqual(1, issues.Errors.Count());
            var error = issues.Errors.First();

            Assert.AreEqual(ValidationErrorCode.RequiredPropertiesMissing, error.Code);
        }
Exemple #3
0
        static DocFile GetDocFile()
        {
            DocSet  docSet   = new DocSet();
            DocFile testFile = new DocFileForTesting(Resources.ExampleResources, "resources.md", "resources.md", docSet);

            var issues = new IssueLogger();

            testFile.Scan(string.Empty, issues);

            Assert.IsFalse(issues.Issues.WereWarningsOrErrors(), "Detected warnings or errors when reading the example markdown file.");

            return(testFile);
        }
        public void TruncatedExampleSelectStatementOnChildren()
        {
            DocSet  docSet   = new DocSet();
            DocFile testFile = new DocFileForTesting(Resources.ExampleValidationSelectStatement, "test.md", "test.md", docSet);

            var issues = new IssueLogger();

            testFile.Scan(string.Empty, issues);

            Assert.IsEmpty(issues.Issues.Where(x => x.IsError));

            docSet.ResourceCollection.RegisterJsonResource(testFile.Resources.First());

            var testMethod = testFile.Requests.First();

            var expectedResponse = HttpParser.ParseHttpResponse(testMethod.ExpectedResponse);
            var actualResponse   = HttpParser.ParseHttpResponse(testMethod.ActualResponse);

            testMethod.ValidateResponse(actualResponse, expectedResponse, null, issues);

            Assert.AreEqual(0, issues.Errors.Count());
        }