Example #1
0
        public void TestBuildManifestFileInfoParsing()
        {
            BuildManifestFileInfo info1 = new BuildManifestFileInfo("/path/a", new ContentHash(HashType.Vso0), new[] { new ContentHash(HashType.SHA1), new ContentHash(HashType.SHA256) });
            BuildManifestFileInfo info2 = new BuildManifestFileInfo("/path/x", new ContentHash(HashType.Vso0), new[] { new ContentHash(HashType.SHA1) });

            string str1 = info1.ToString();
            string str2 = info2.ToString();

            XAssert.IsTrue(BuildManifestFileInfo.TryParse(str1, out BuildManifestFileInfo parsedInfo1));
            XAssert.IsTrue(BuildManifestFileInfo.TryParse(str2, out BuildManifestFileInfo parsedInfo2));

            XAssert.AreEqual(info1, parsedInfo1);
            XAssert.AreEqual(info2, parsedInfo2);

            XAssert.IsFalse(BuildManifestFileInfo.TryParse("123|VSO:123|SHA1:123", out _));
            XAssert.IsFalse(BuildManifestFileInfo.TryParse("123|VSO:123|SHA1:123|", out _));
            XAssert.IsFalse(BuildManifestFileInfo.TryParse("123|VSO:123", out _));
            XAssert.IsFalse(BuildManifestFileInfo.TryParse("123", out _));
            XAssert.IsFalse(BuildManifestFileInfo.TryParse("|123", out _));
        }
Example #2
0
        public void TestBuildManifestFileInfoParsing()
        {
            BuildManifestFileInfo info1 = new BuildManifestFileInfo("/path/a", "VSOa", "SHAa");
            BuildManifestFileInfo info2 = new BuildManifestFileInfo("/path/x", "VSOx", "SHAx");

            string str1 = info1.ToString();
            string str2 = info2.ToString();

            XAssert.IsTrue(BuildManifestFileInfo.TryParse(str1, out BuildManifestFileInfo parsedInfo1));
            XAssert.IsTrue(BuildManifestFileInfo.TryParse(str2, out BuildManifestFileInfo parsedInfo2));

            XAssert.AreEqual(info1, parsedInfo1);
            XAssert.AreEqual(info2, parsedInfo2);

            XAssert.IsFalse(BuildManifestFileInfo.TryParse("123|123|123|", out _));
            XAssert.IsFalse(BuildManifestFileInfo.TryParse("123|123", out _));
            XAssert.IsFalse(BuildManifestFileInfo.TryParse("123", out _));

            XAssert.IsTrue(ThrowsException(() => BuildManifestFileInfo.TryParse("|123|123", out _)));
            XAssert.IsTrue(ThrowsException(() => BuildManifestFileInfo.TryParse("123||123", out _)));
            XAssert.IsTrue(ThrowsException(() => BuildManifestFileInfo.TryParse("123|123|", out _)));
        }