Beispiel #1
0
        public void TestAssemblyPaths(ITaskItem[] assemblyPaths)
        {
            var task = new MockTask()
            {
                AssemblyPaths = assemblyPaths
            };

            using (var driver = task.CreateDriver()) {
                var context = driver.Context;

                var expectedReferences = assemblyPaths.Select(p => p.ItemSpec)
                                         .GroupBy(p => Path.GetFileNameWithoutExtension(p))
                                         .Select(g => g.First());
                var actualReferences = driver.GetReferenceAssemblies();
                Assert.Equal(expectedReferences.OrderBy(a => a), actualReferences.OrderBy(a => a));

                foreach (var item in assemblyPaths)
                {
                    var assemblyPath = item.ItemSpec;
                    var trimMode     = item.GetMetadata("TrimMode");
                    if (String.IsNullOrEmpty(trimMode))
                    {
                        continue;
                    }

                    AssemblyAction expectedAction = (AssemblyAction)Enum.Parse(typeof(AssemblyAction), trimMode, ignoreCase: true);

                    var            ad           = new Mono.Cecil.AssemblyNameDefinition(Path.GetFileNameWithoutExtension(assemblyPath), new Version());
                    AssemblyAction actualAction = context.CalculateAssemblyAction(ad);

                    Assert.Equal(expectedAction, actualAction);
                }
            }
        }
Beispiel #2
0
        public void TestReferenceAssemblyPaths(string[] referenceAssemblyPaths)
        {
            var task = new MockTask()
            {
                ReferenceAssemblyPaths = referenceAssemblyPaths.Select(p => new TaskItem(p)).ToArray()
            };

            using (var driver = task.CreateDriver()) {
                var expectedReferences = referenceAssemblyPaths;
                var actualReferences   = driver.GetReferenceAssemblies();
                Assert.Equal(expectedReferences.OrderBy(a => a), actualReferences.OrderBy(a => a));
                foreach (var reference in expectedReferences)
                {
                    var            ad           = new Mono.Cecil.AssemblyNameDefinition(Path.GetFileNameWithoutExtension(reference), new Version());
                    AssemblyAction actualAction = driver.Context.CalculateAssemblyAction(ad);
                    Assert.Equal(AssemblyAction.Skip, actualAction);
                }
            }
        }