PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/FodyIsolated.Tests/WeaverInitialiserTests.cs

https://github.com/PKRoma/Fody
C# | 85 lines | 73 code | 10 blank | 2 comment | 0 complexity | aac85357e8f1fc64ffb55f7b1b4d200b MD5 | raw file
Possible License(s): MIT
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Xml.Linq;
  5. using Mono.Cecil;
  6. using Mono.Cecil.Cil;
  7. using Moq;
  8. using NUnit.Framework;
  9. [TestFixture]
  10. public class WeaverInitialiserTests
  11. {
  12. [Test]
  13. public void ValidProps()
  14. {
  15. var moduleDefinition = ModuleDefinition.CreateModule("Foo", ModuleKind.Dll);
  16. var innerWeaver = new InnerWeaver
  17. {
  18. Logger = new Mock<ILogger>().Object,
  19. AssemblyFilePath = "AssemblyFilePath",
  20. ProjectDirectoryPath = "ProjectDirectoryPath",
  21. SolutionDirectoryPath = "SolutionDirectoryPath",
  22. ReferenceDictionary = new Dictionary<string, string> {{"Ref1;Ref2", "Path1"}},
  23. ReferenceCopyLocalPaths = new List<string> {"Ref1"},
  24. ModuleDefinition = moduleDefinition,
  25. DefineConstants = new List<string>{"Debug", "Release"}
  26. };
  27. var weaverEntry = new WeaverEntry
  28. {
  29. Element = "<foo/>",
  30. AssemblyPath = @"c:\FakePath\Assembly.dll"
  31. };
  32. var moduleWeaver = new ValidModuleWeaver();
  33. innerWeaver.SetProperties(weaverEntry, moduleWeaver, (typeof(ValidModuleWeaver)).BuildDelegateHolder());
  34. Assert.IsNotNull(moduleWeaver.LogInfo);
  35. Assert.IsNotNull(moduleWeaver.LogDebug);
  36. Assert.IsNotNull(moduleWeaver.LogWarning);
  37. Assert.IsNotNull(moduleWeaver.LogWarningPoint);
  38. Assert.IsNotNull(moduleWeaver.LogError);
  39. Assert.IsNotNull(moduleWeaver.LogErrorPoint);
  40. Assert.AreEqual("Ref1", moduleWeaver.ReferenceCopyLocalPaths.First());
  41. Assert.AreEqual("Debug", moduleWeaver.DefineConstants[0]);
  42. Assert.AreEqual("Release", moduleWeaver.DefineConstants[1]);
  43. // Assert.IsNotEmpty(moduleWeaver.References);
  44. Assert.AreEqual(moduleDefinition, moduleWeaver.ModuleDefinition);
  45. Assert.AreEqual(innerWeaver, moduleWeaver.AssemblyResolver);
  46. Assert.AreEqual(@"c:\FakePath", moduleWeaver.AddinDirectoryPath);
  47. Assert.AreEqual("AssemblyFilePath", moduleWeaver.AssemblyFilePath);
  48. Assert.AreEqual("ProjectDirectoryPath", moduleWeaver.ProjectDirectoryPath);
  49. Assert.AreEqual("SolutionDirectoryPath", moduleWeaver.SolutionDirectoryPath);
  50. }
  51. }
  52. public class ValidModuleWeaver
  53. {
  54. public XElement Config { get; set; }
  55. // public List<string> References { get; set; }
  56. public string AssemblyFilePath { get; set; }
  57. public string ProjectDirectoryPath { get; set; }
  58. public string AddinDirectoryPath { get; set; }
  59. public Action<string> LogInfo { get; set; }
  60. public Action<string> LogDebug { get; set; }
  61. public Action<string> LogWarning { get; set; }
  62. public Action<string, SequencePoint> LogWarningPoint { get; set; }
  63. public Action<string> LogError { get; set; }
  64. public Action<string, SequencePoint> LogErrorPoint { get; set; }
  65. public IAssemblyResolver AssemblyResolver { get; set; }
  66. public ModuleDefinition ModuleDefinition { get; set; }
  67. public string SolutionDirectoryPath { get; set; }
  68. public List<string> DefineConstants { get; set; }
  69. public List<string> ReferenceCopyLocalPaths { get; set; }
  70. public bool ExecuteCalled;
  71. public void Execute()
  72. {
  73. ExecuteCalled = true;
  74. }
  75. }