Exemple #1
0
 public void BeforeEachTest()
 {
     using (var stream = TempFile.OpenResource(GetType(), "PackageJsonParserTest.TypesAngular.package.json"))
     {
         _sut = PackageJsonParser.FromStream(stream);
     }
 }
Exemple #2
0
        public void GetAuthors(string json, string expected)
        {
            _sut = new PackageJsonParser(Encoding.UTF8.GetBytes(json).JsonDeserialize <JObject>());

            var actual = _sut.GetAuthors();

            actual.ShouldBe(expected);
        }
Exemple #3
0
        public void GetLicense(string json, string expectedType, string expectedValue)
        {
            _sut = new PackageJsonParser(Encoding.UTF8.GetBytes(json).JsonDeserialize <JObject>());

            var actual = _sut.GetLicense();

            actual.Type.ShouldBe(expectedType);
            actual.Value.ShouldBe(expectedValue);
        }
Exemple #4
0
        public void GetRepository(string json, string expectedType, string expectedUrl)
        {
            _sut = new PackageJsonParser(Encoding.UTF8.GetBytes(json).JsonDeserialize <JObject>());

            var actual = _sut.GetRepository();

            if (expectedUrl == null)
            {
                actual.ShouldBeNull();
            }
            else
            {
                actual.ShouldNotBeNull();
                actual.Type.ShouldBe(expectedType);
                actual.Url.ShouldBe(expectedUrl);
            }
        }
Exemple #5
0
        public PackageJson ParsePackageJson(Stream content)
        {
            content.AssertNotNull(nameof(content));

            var parser = new PackageJsonParser(content.JsonDeserialize <JObject>());

            return(new PackageJson
            {
                Name = parser.GetName(),
                Version = parser.GetVersion(),
                HomePage = parser.GetHomePage(),
                Authors = parser.GetAuthors(),
                Description = parser.GetDescription(),
                License = parser.GetLicense(),
                Repository = parser.GetRepository(),
                PackageHRef = new Uri(new Uri("https://" + KnownHosts.Npm), "package/{0}/v/{1}".FormatWith(parser.GetName(), parser.GetVersion())).ToString()
            });
        }