コード例 #1
0
        public void SimpleTag()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity()
                {
                    Name                 = "SamplePackage",
                    FullPath             = "c:\\tmp\\path",
                    FastPackageReference = "some-string",
                    IsPatch              = false,
                    Source               = "test-source",
                    SearchKey            = "search-key",
                    Status               = "test-status",
                    TagId                = "some-tag-id",
                    Version              = "1.0",
                    VersionScheme        = "multipart-numeric",
                    FromTrustedSource    = true,
                    IsSupplemental       = false,
                    IsCorpus             = false,
                    Summary              = "Summary Text",
                    AppliesToMedia       = "Windows",
                    PackageFilename      = "c:\\tmp\\path\\filename.txt",
                    TagVersion           = "1",
                };

                // add some arbitrary metadata
                var meta = swid.AddMetadataValue(swid.FastPackageReference, "sample", "value");
                Assert.NotNull(meta);

                var xml = XDocument.Parse(swid.SwidTagText);

                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                Assert.Equal("SamplePackage", xml.XPathToAttribute("/swid:SoftwareIdentity/@name").Value);

                var v = xml.XPathToAttribute("/swid:SoftwareIdentity/@tagId").Value;

                Assert.Equal("some-tag-id", xml.XPathToAttribute("/swid:SoftwareIdentity/@tagId").Value);
                Assert.Equal("1.0", xml.XPathToAttribute("/swid:SoftwareIdentity/@version").Value);
                Assert.Equal("multipart-numeric", xml.XPathToAttribute("/swid:SoftwareIdentity/@versionScheme").Value);
                Assert.Equal("1", xml.XPathToAttribute("/swid:SoftwareIdentity/@tagVersion").Value);
                Assert.Equal("Windows", xml.XPathToAttribute("/swid:SoftwareIdentity/@media").Value);

                Assert.True(xml.XPathToAttribute("/swid:SoftwareIdentity/@patch").Value.IsFalse());
                Assert.True(xml.XPathToAttribute("/swid:SoftwareIdentity/@supplemental").Value.IsFalse());
                Assert.True(xml.XPathToAttribute("/swid:SoftwareIdentity/@corpus").Value.IsFalse());

                Assert.Equal("Summary Text", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Meta/@summary").Value);

                Assert.Equal("value", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Meta/@sample").Value);
            }
        }
コード例 #2
0
        public void WhatHappensWithDuplicateMetadata()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity();

                // add some data
                var meta = swid.AddMetadataValue(swid.FastPackageReference, "sample", "value");
                Assert.NotNull(meta);

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                // assertions
            }
        }
コード例 #3
0
ファイル: SwidTagTests.cs プロジェクト: notgerry/oneget
        public void WhatHappensWithDuplicateMetadata()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity();

                // add some data
                var meta = swid.AddMetadataValue(swid.FastPackageReference, "sample", "value");
                Assert.NotNull(meta);

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                // assertions
            }
        }
コード例 #4
0
ファイル: SwidTagTests.cs プロジェクト: notgerry/oneget
        public void SimpleTag()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity() {
                    Name = "SamplePackage",
                    FullPath = "c:\\tmp\\path",
                    FastPackageReference = "some-string",
                    IsPatch = false,
                    Source = "test-source",
                    SearchKey = "search-key",
                    Status = "test-status",
                    TagId = "some-tag-id",
                    Version = "1.0",
                    VersionScheme = "multipart-numeric",
                    FromTrustedSource = true,
                    IsSupplemental = false,
                    IsCorpus = false,
                    Summary = "Summary Text",
                    AppliesToMedia = "Windows",
                    PackageFilename = "c:\\tmp\\path\\filename.txt",
                    TagVersion = "1",
                };

                // add some arbitrary metadata
                var meta = swid.AddMetadataValue(swid.FastPackageReference, "sample", "value");
                Assert.NotNull(meta);

                var xml = XDocument.Parse(swid.SwidTagText);

                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                Assert.Equal("SamplePackage", xml.XPathToAttribute("/swid:SoftwareIdentity/@name").Value);

                var v = xml.XPathToAttribute("/swid:SoftwareIdentity/@tagId").Value;

                Assert.Equal("some-tag-id", xml.XPathToAttribute("/swid:SoftwareIdentity/@tagId").Value);
                Assert.Equal("1.0", xml.XPathToAttribute("/swid:SoftwareIdentity/@version").Value);
                Assert.Equal("multipart-numeric", xml.XPathToAttribute("/swid:SoftwareIdentity/@versionScheme").Value);
                Assert.Equal("1", xml.XPathToAttribute("/swid:SoftwareIdentity/@tagVersion").Value);
                Assert.Equal("Windows", xml.XPathToAttribute("/swid:SoftwareIdentity/@media").Value);

                Assert.True(xml.XPathToAttribute("/swid:SoftwareIdentity/@patch").Value.IsFalse());
                Assert.True(xml.XPathToAttribute("/swid:SoftwareIdentity/@supplemental").Value.IsFalse());
                Assert.True(xml.XPathToAttribute("/swid:SoftwareIdentity/@corpus").Value.IsFalse());

                Assert.Equal("Summary Text", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Meta/@summary").Value);

                Assert.Equal("value", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Meta/@sample").Value);
            }
        }