Example #1
0
        public void MakeUriAbsoluteVisitor_VisitRun_DoesNotSetAbsoluteUriIfNotApplicable()
        {
            Dictionary <string, Uri> uriMapping = new Dictionary <string, Uri>()
            {
                { "%TEST3%", new Uri(@"C:\srcroot\") },
                { "%TEST4%", new Uri(@"D:\bld\out\") },
            };

            Run run = GenerateRunForTest(uriMapping);

            AbsoluteUrisVisitor visitor = new AbsoluteUrisVisitor();

            var newRun = visitor.VisitRun(run);

            var oldRun = GenerateRunForTest(uriMapping);

            // Validate.

            newRun.Files.Keys.ShouldBeEquivalentTo(oldRun.Files.Keys);
            foreach (var key in newRun.Files.Keys)
            {
                oldRun.Files[key].Uri.ShouldBeEquivalentTo(newRun.Files[key].Uri);
                oldRun.Files[key].UriBaseId.ShouldBeEquivalentTo(newRun.Files[key].UriBaseId);
                oldRun.Files[key].ParentKey.ShouldBeEquivalentTo(newRun.Files[key].ParentKey);
            }
        }
Example #2
0
        public void MakeUriAbsoluteVisitor_VisitRun_SetsAbsoluteUriForAllApplicableFiles()
        {
            Run run = GenerateRunForTest(new Dictionary <string, Uri>()
            {
                { "%TEST1%", new Uri(@"C:\srcroot\") },
                { "%TEST2%", new Uri(@"D:\bld\out\") }
            });

            AbsoluteUrisVisitor visitor = new AbsoluteUrisVisitor();

            var newRun = visitor.VisitRun(run);

            // Validate.
            newRun.Files.ContainsKey(@"file://*****:*****@"file://D:/bld/out/src/file2.dll");
            newRun.Files.ContainsKey(@"file://*****:*****@"file://C:/srcroot/src/archive.zip#file3.cs");

            foreach (var key in newRun.Files.Keys)
            {
                newRun.Files[key].Uri.ShouldBeEquivalentTo(new Uri(key));
                newRun.Files[key].UriBaseId.Should().BeNull();
                if (!string.IsNullOrEmpty(newRun.Files[key].ParentKey))
                {
                    newRun.Files.Should().ContainKey(newRun.Files[key].ParentKey);
                }
            }
        }
Example #3
0
        public void MakeUriAbsoluteVisitor_VisitRun_ThrowsIfPropertiesAreWrong()
        {
            Run run = GenerateRunForTest(null);

            run.Properties = new Dictionary <string, SerializedPropertyInfo>();
            run.Properties[RebaseUriVisitor.BaseUriDictionaryName] = new SerializedPropertyInfo("\"this is a string\"", true);

            AbsoluteUrisVisitor visitor = new AbsoluteUrisVisitor();

            Assert.Throws <InvalidOperationException>(() => visitor.VisitRun(run));
        }
Example #4
0
        public void MakeUriAbsoluteVisitor_VisitRun_DoesNotChangeIfPropertiesAbsent()
        {
            Run run = GenerateRunForTest(null);

            AbsoluteUrisVisitor visitor = new AbsoluteUrisVisitor();

            var newRun = visitor.VisitRun(run);

            // Validate.
            var oldRun = GenerateRunForTest(null);

            newRun.Files.Keys.ShouldBeEquivalentTo(oldRun.Files.Keys);
            foreach (var key in newRun.Files.Keys)
            {
                oldRun.Files[key].Uri.ShouldBeEquivalentTo(newRun.Files[key].Uri);
                oldRun.Files[key].UriBaseId.ShouldBeEquivalentTo(newRun.Files[key].UriBaseId);
                oldRun.Files[key].ParentKey.ShouldBeEquivalentTo(newRun.Files[key].ParentKey);
            }
        }