-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeaverInitialiserTests.cs
91 lines (81 loc) · 3.29 KB
/
WeaverInitialiserTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using Microsoft.Build.Framework;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Moq;
using NUnit.Framework;
[TestFixture]
public class WeaverInitialiserTests
{
[Test]
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);
}
}
public class ValidModuleWeaver
{
public XElement Config { get; set; }
// public List<string> References { get; set; }
public string AssemblyFilePath { get; set; }
public string ProjectDirectoryPath { get; set; }
public string AddinDirectoryPath { get; set; }
public Action<string> LogDebug { get; set; }
public Action<string> LogInfo { get; set; }
public Action<string> LogWarning { get; set; }
public Action<string, SequencePoint> LogWarningPoint { get; set; }
public Action<string> LogError { get; set; }
public Action<string, SequencePoint> LogErrorPoint { get; set; }
public Action<string, MessageImportance> LogMessage { get; set; }
public IAssemblyResolver AssemblyResolver { get; set; }
public ModuleDefinition ModuleDefinition { get; set; }
public string SolutionDirectoryPath { get; set; }
public List<string> DefineConstants { get; set; }
public string References { get; set; }
public List<string> ReferenceCopyLocalPaths { get; set; }
public bool ExecuteCalled;
public void Execute()
{
ExecuteCalled = true;
}
}