<commit_before>﻿//*********************************************************//
//    Copyright (c) Microsoft. All rights reserved.
//    
//    Apache 2.0 License
//    
//    You may obtain a copy of the License at
//    http://www.apache.org/licenses/LICENSE-2.0
//    
//    Unless required by applicable law or agreed to in writing, software 
//    distributed under the License is distributed on an "AS IS" BASIS, 
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
//    implied. See the License for the specific language governing 
//    permissions and limitations under the License.
//
//*********************************************************//

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.NodejsTools.Npm;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NpmTests {
    [TestClass]
    [DeploymentItem(@"TestData\NpmPackageJsonData\", "NpmPackageJsonData")]
    public class ProblematicPackageJsonTests : AbstractPackageJsonTests {

        [TestMethod, Priority(0)]
        public void FreshPackageJsonParseFromResource() {
            var pkg = LoadFromResource("NpmTests.TestData.fresh_package.json");
            Assert.IsNotNull(pkg, "Fresh package should not be null.");
        }

        private void TestParseFromFile(string filename) {
            string file = string.Format(@"NpmPackageJsonData\{0}", filename);
            var pkg = LoadFromFile(file);
            Assert.IsNotNull(
                pkg,
                string.Format("Package from file '{0}' should not be null.", file));
        }

        [TestMethod, Priority(0)]
        public void FreshPackageParseFromFile() {
            TestParseFromFile("fresh_package.json");
        }

        private void TestFreshPackage(string suffix) {
            TestParseFromFile(string.Format("fresh_package_{0}.json", suffix));
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseDoubleColon() {
            TestFreshPackage("doublecolon");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseDoubleComma() {
            TestFreshPackage("doublecomma");
        }

        [TestMethod, Priority(0), TestCategory("Ignore")]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseDuplicateProperty() {
            TestFreshPackage("duplicateproperty");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseLeadingBrace() {
            TestFreshPackage("leadingbrace");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseLeadingLetter() {
            TestFreshPackage("leadingletter");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseLeadingSquareBrace() {
            TestFreshPackage("leadingsquarebrace");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseMissingColon() {
            TestFreshPackage("missingcolon");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseMissingComma() {
            TestFreshPackage("missingcomma");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseMissingLeadingBrace() {
            TestFreshPackage("missingleadingbrace");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseMissingLeadingListBrace() {
            TestFreshPackage("missingleadinglistbrace");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseMissingLeadingPropNameQuote() {
            TestFreshPackage("missingleadingpropnamequote");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseMissingOnePropNameQuote() {
            TestFreshPackage("missingonepropnamequote");
        }

        [TestMethod, Priority(0)]
        public void ParseMissingPropNameQuotes() {
            TestFreshPackage("missingpropnamequotes");
        }

        [TestMethod, Priority(0), TestCategory("Ignore")]
        public void ParseMissingTrailingBrace() {
            TestFreshPackage("missingtrailingbrace");
        }

        [TestMethod, Priority(0), TestCategory("Ignore")]
        public void ParseMissingTrailingListBrace() {
            TestFreshPackage("missingtrailinglistbrace");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseUnescapedQuote() {
            TestFreshPackage("unescapedquote");
        }
<commit_msg>Fix two problematic json tests<commit_after>﻿//*********************************************************//
//    Copyright (c) Microsoft. All rights reserved.
//    
//    Apache 2.0 License
//    
//    You may obtain a copy of the License at
//    http://www.apache.org/licenses/LICENSE-2.0
//    
//    Unless required by applicable law or agreed to in writing, software 
//    distributed under the License is distributed on an "AS IS" BASIS, 
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
//    implied. See the License for the specific language governing 
//    permissions and limitations under the License.
//
//*********************************************************//

using System;
using System.IO;
using System.Text;
using Microsoft.NodejsTools.Npm;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NpmTests {
    [TestClass]
    [DeploymentItem(@"TestData\NpmPackageJsonData\", "NpmPackageJsonData")]
    public class ProblematicPackageJsonTests : AbstractPackageJsonTests {
        [TestMethod, Priority(0)]
        public void FreshPackageJsonParseFromResource() {
            var pkg = LoadFromResource("NpmTests.TestData.fresh_package.json");
            Assert.IsNotNull(pkg, "Fresh package should not be null.");
        }

        private void TestParseFromFile(string filename) {
            string file = string.Format(@"NpmPackageJsonData\{0}", filename);
            var pkg = LoadFromFile(file);
            Assert.IsNotNull(
                pkg,
                string.Format("Package from file '{0}' should not be null.", file));
        }

        [TestMethod, Priority(0)]
        public void FreshPackageParseFromFile() {
            TestParseFromFile("fresh_package.json");
        }

        private void TestFreshPackage(string suffix) {
            TestParseFromFile(string.Format("fresh_package_{0}.json", suffix));
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseDoubleColon() {
            TestFreshPackage("doublecolon");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseDoubleComma() {
            TestFreshPackage("doublecomma");
        }

        [TestMethod, Priority(0), TestCategory("Ignore")]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseDuplicateProperty() {
            TestFreshPackage("duplicateproperty");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseLeadingBrace() {
            TestFreshPackage("leadingbrace");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseLeadingLetter() {
            TestFreshPackage("leadingletter");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseLeadingSquareBrace() {
            TestFreshPackage("leadingsquarebrace");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseMissingColon() {
            TestFreshPackage("missingcolon");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseMissingComma() {
            TestFreshPackage("missingcomma");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseMissingLeadingBrace() {
            TestFreshPackage("missingleadingbrace");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseMissingLeadingListBrace() {
            TestFreshPackage("missingleadinglistbrace");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseMissingLeadingPropNameQuote() {
            TestFreshPackage("missingleadingpropnamequote");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseMissingOnePropNameQuote() {
            TestFreshPackage("missingonepropnamequote");
        }

        [TestMethod, Priority(0)]
        public void ParseMissingPropNameQuotes() {
            TestFreshPackage("missingpropnamequotes");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseMissingTrailingBrace() {
            TestFreshPackage("missingtrailingbrace");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseMissingTrailingListBrace() {
            TestFreshPackage("missingtrailinglistbrace");
        }

        [TestMethod, Priority(0)]
        [ExpectedException(typeof(PackageJsonException))]
        public void ParseUnescapedQuote() {
            TestFreshPackage("unescapedquote");
        }

{'fraction_non_alphanumeric': 0.1211347796210857, 'fraction_numerical': 0.004908216354176892, 'mean_word_length': 2.788769059129788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5898054', 'n_tokens_mistral': 2611, 'n_tokens_neox': 2458, 'n_words': 504}