Ejemplo n.º 1
0
    public void ValidProps()
    {
        var moduleDefinition = ModuleDefinition.CreateModule("Foo", ModuleKind.Dll);

        var resolver    = new MockAssemblyResolver();
        var innerWeaver = new InnerWeaver
        {
            Logger                = new Mock <ILogger>().Object,
            AssemblyFilePath      = "AssemblyFilePath",
            ProjectDirectoryPath  = "ProjectDirectoryPath",
            SolutionDirectoryPath = "SolutionDirectoryPath",
            ReferenceDictionary   = new Dictionary <string, string>
            {
                { "Ref1;Ref2", "Path1" }
            },
            ReferenceCopyLocalPaths = new List <string>
            {
                "CopyRef1",
                "CopyRef2"
            },
            References       = "Ref1;Ref2",
            ModuleDefinition = moduleDefinition,
            DefineConstants  = new List <string>
            {
                "Debug",
                "Release"
            },
            assemblyResolver = resolver
        };

        var weaverEntry = new WeaverEntry
        {
            Element      = "<foo/>",
            AssemblyPath = @"c:\FakePath\Assembly.dll"
        };
        var moduleWeaver = new ValidModuleWeaver();

        innerWeaver.SetProperties(weaverEntry, moduleWeaver, typeof(ValidModuleWeaver).BuildDelegateHolder());

        Assert.IsNotNull(moduleWeaver.LogDebug);
        Assert.IsNotNull(moduleWeaver.LogInfo);
        Assert.IsNotNull(moduleWeaver.LogWarning);
        Assert.IsNotNull(moduleWeaver.LogWarningPoint);
        Assert.IsNotNull(moduleWeaver.LogError);
        Assert.IsNotNull(moduleWeaver.LogErrorPoint);
        Assert.IsNotNull(moduleWeaver.LogMessage);
        Assert.AreEqual("Ref1;Ref2", moduleWeaver.References);
        Assert.AreEqual("CopyRef1", moduleWeaver.ReferenceCopyLocalPaths[0]);
        Assert.AreEqual("CopyRef2", moduleWeaver.ReferenceCopyLocalPaths[1]);
        Assert.AreEqual("Debug", moduleWeaver.DefineConstants[0]);
        Assert.AreEqual("Release", moduleWeaver.DefineConstants[1]);

        // Assert.IsNotEmpty(moduleWeaver.References);
        Assert.AreEqual(moduleDefinition, moduleWeaver.ModuleDefinition);
        Assert.AreEqual(resolver, moduleWeaver.AssemblyResolver);
        Assert.AreEqual(@"c:\FakePath", moduleWeaver.AddinDirectoryPath);
        Assert.AreEqual("AssemblyFilePath", moduleWeaver.AssemblyFilePath);
        Assert.AreEqual("ProjectDirectoryPath", moduleWeaver.ProjectDirectoryPath);
        Assert.AreEqual("SolutionDirectoryPath", moduleWeaver.SolutionDirectoryPath);
    }
Ejemplo n.º 2
0
    public void ValidProps()
    {
        var moduleWeaver = new ValidModuleWeaver();
        var moduleDefinition = ModuleDefinition.CreateModule("Foo", ModuleKind.Dll);
        var assemblyResolver = new Mock<IAssemblyResolver>().Object;
        var innerWeaver = new InnerWeaver
            {
                AssemblyPath = "AssemblyPath"
            };

        var moduleWeaverRunner = new WeaverInitialiser
            {
                ModuleDefinition = moduleDefinition,
                Logger = new Mock<ILogger>().Object,
                AssemblyResolver = assemblyResolver,
                InnerWeaver = innerWeaver
            };
        var weaverEntry = new WeaverEntry {Element = "<foo/>"};
        moduleWeaverRunner.SetProperties(weaverEntry, moduleWeaver);

        Assert.IsNotNull(moduleWeaver.LogInfo);
        Assert.IsNotNull(moduleWeaver.LogWarning);
        Assert.IsNotNull(moduleWeaver.LogWarningPoint);
        Assert.IsNotNull(moduleWeaver.LogError);
        Assert.IsNotNull(moduleWeaver.LogErrorPoint);
        Assert.AreEqual(moduleDefinition, moduleWeaver.ModuleDefinition);
        Assert.AreEqual(assemblyResolver, moduleWeaver.AssemblyResolver);
        Assert.AreEqual("AssemblyPath", moduleWeaver.AssemblyPath);
    }
Ejemplo n.º 3
0
    public void ValidProps()
    {
        var moduleDefinition = ModuleDefinition.CreateModule("Foo", ModuleKind.Dll);

        var innerWeaver = new InnerWeaver
            {
                AssemblyFilePath = "AssemblyFilePath",
                SolutionDirectoryPath = "SolutionDirectoryPath",
                ReferenceDictionary = new Dictionary<string, string> { { "Ref1;Ref2","Path1" } },
                ModuleDefinition = moduleDefinition,

            };

        var weaverEntry = new WeaverEntry
                              {
                                  Element = "<foo/>",
                                  AssemblyPath = @"c:\FakePath\Assembly.dll"
                              };
        var moduleWeaver = new ValidModuleWeaver();
        innerWeaver.SetProperties(weaverEntry, moduleWeaver);

        Assert.IsNotNull(moduleWeaver.LogInfo);
        Assert.IsNotNull(moduleWeaver.LogWarning);
        Assert.IsNotNull(moduleWeaver.LogWarningPoint);
        Assert.IsNotNull(moduleWeaver.LogError);
        Assert.IsNotNull(moduleWeaver.LogErrorPoint);
           // Assert.IsNotEmpty(moduleWeaver.References);
        Assert.AreEqual(moduleDefinition, moduleWeaver.ModuleDefinition);
        Assert.AreEqual(innerWeaver, moduleWeaver.AssemblyResolver);
        Assert.AreEqual(@"c:\FakePath",moduleWeaver.AddinDirectoryPath);
        Assert.AreEqual("AssemblyFilePath", moduleWeaver.AssemblyFilePath);
        Assert.AreEqual("SolutionDirectoryPath", moduleWeaver.SolutionDirectoryPath);
    }
Ejemplo n.º 4
0
    public void ValidProps()
    {
        var moduleWeaver     = new ValidModuleWeaver();
        var moduleDefinition = ModuleDefinition.CreateModule("Foo", ModuleKind.Dll);
        var assemblyResolver = new Mock <IAssemblyResolver>().Object;
        var innerWeaver      = new InnerWeaver
        {
            AssemblyPath = "AssemblyPath"
        };

        var moduleWeaverRunner = new WeaverInitialiser
        {
            ModuleDefinition = moduleDefinition,
            Logger           = new Mock <ILogger>().Object,
            AssemblyResolver = assemblyResolver,
            InnerWeaver      = innerWeaver
        };
        var weaverEntry = new WeaverEntry {
            Element = "<foo/>"
        };

        moduleWeaverRunner.SetProperties(weaverEntry, moduleWeaver);

        Assert.IsNotNull(moduleWeaver.LogInfo);
        Assert.IsNotNull(moduleWeaver.LogWarning);
        Assert.IsNotNull(moduleWeaver.LogWarningPoint);
        Assert.IsNotNull(moduleWeaver.LogError);
        Assert.IsNotNull(moduleWeaver.LogErrorPoint);
        Assert.AreEqual(moduleDefinition, moduleWeaver.ModuleDefinition);
        Assert.AreEqual(assemblyResolver, moduleWeaver.AssemblyResolver);
        Assert.AreEqual("AssemblyPath", moduleWeaver.AssemblyPath);
    }
Ejemplo n.º 5
0
    public void Execute()
    {
        var moduleWeaver       = new ValidModuleWeaver();
        var moduleWeaverRunner = new ModuleWeaverRunner {
            Logger = new Mock <ILogger>().Object
        };

        moduleWeaverRunner.Execute(moduleWeaver);
    }
Ejemplo n.º 6
0
	public void ValidProps()
	{
		var moduleDefinition = ModuleDefinition.CreateModule("Foo", ModuleKind.Dll);

		var innerWeaver = new InnerWeaver
			{
				Logger = new Mock<ILogger>().Object,
				AssemblyFilePath = "AssemblyFilePath",
				ProjectDirectoryPath = "ProjectDirectoryPath",
				SolutionDirectoryPath = "SolutionDirectoryPath",
				ReferenceDictionary = new Dictionary<string, string> {{"Ref1;Ref2", "Path1"}},
				ReferenceCopyLocalPaths = new List<string> {"CopyRef1","CopyRef2"},
				References ="Ref1;Ref2",
				ModuleDefinition = moduleDefinition,
                DefineConstants = new List<string>{"Debug", "Release"}
			};

		var weaverEntry = new WeaverEntry
			{
				Element = "<foo/>",
				AssemblyPath = @"c:\FakePath\Assembly.dll"
			};
		var moduleWeaver = new ValidModuleWeaver();
        innerWeaver.SetProperties(weaverEntry, moduleWeaver, (typeof(ValidModuleWeaver)).BuildDelegateHolder());

        Assert.IsNotNull(moduleWeaver.LogDebug);
		Assert.IsNotNull(moduleWeaver.LogInfo);
		Assert.IsNotNull(moduleWeaver.LogWarning);
		Assert.IsNotNull(moduleWeaver.LogWarningPoint);
		Assert.IsNotNull(moduleWeaver.LogError);
		Assert.IsNotNull(moduleWeaver.LogErrorPoint);
		Assert.IsNotNull(moduleWeaver.LogMessage);
		Assert.AreEqual("Ref1;Ref2", moduleWeaver.References);
		Assert.AreEqual("CopyRef1", moduleWeaver.ReferenceCopyLocalPaths[0]);
        Assert.AreEqual("CopyRef2", moduleWeaver.ReferenceCopyLocalPaths[1]);
		Assert.AreEqual("Debug", moduleWeaver.DefineConstants[0]);
		Assert.AreEqual("Release", moduleWeaver.DefineConstants[1]);

		// Assert.IsNotEmpty(moduleWeaver.References); 
		Assert.AreEqual(moduleDefinition, moduleWeaver.ModuleDefinition);
		Assert.AreEqual(innerWeaver, moduleWeaver.AssemblyResolver);
		Assert.AreEqual(@"c:\FakePath", moduleWeaver.AddinDirectoryPath);
		Assert.AreEqual("AssemblyFilePath", moduleWeaver.AssemblyFilePath);
        Assert.AreEqual("ProjectDirectoryPath", moduleWeaver.ProjectDirectoryPath);
		Assert.AreEqual("SolutionDirectoryPath", moduleWeaver.SolutionDirectoryPath);
	}
Ejemplo n.º 7
0
    public void ValidProps()
    {
        var moduleDefinition = ModuleDefinition.CreateModule("Foo", ModuleKind.Dll);

        var resolver    = new MockAssemblyResolver();
        var innerWeaver = BuildInnerWeaver(moduleDefinition, resolver);

        innerWeaver.SplitUpReferences();

        var weaverEntry = new WeaverEntry
        {
            Element      = "<foo/>",
            AssemblyPath = @"c:\FakePath\Assembly.dll"
        };
        var moduleWeaver = new ValidModuleWeaver();

        innerWeaver.SetProperties(weaverEntry, moduleWeaver, typeof(ValidModuleWeaver).BuildDelegateHolder());

        ValidateProps(moduleWeaver, moduleDefinition);
        Assert.Equal(resolver, moduleWeaver.AssemblyResolver);
    }
Ejemplo n.º 8
0
 public void Execute()
 {
     var moduleWeaver = new ValidModuleWeaver();
     var moduleWeaverRunner = new InnerWeaver { Logger = new Mock<ILogger>().Object };
     moduleWeaverRunner.RunWeaver(moduleWeaver);
 }