diff options
author | Mikhail Melnikov <mikhail_melnikov@epam.com> | 2017-11-30 15:02:24 +0300 |
---|---|---|
committer | Joel Martinez <joelmartinez@gmail.com> | 2017-11-30 18:51:54 +0300 |
commit | f8cdfc060fc8df64af4fb7f131ea8c0627d48258 (patch) | |
tree | 36bc4370f3a136a2aacff2c7fe9988ea911795a6 /mdoc/mdoc.Test/VBFormatterTests.cs | |
parent | b070267b5cf3986cdd79f52244a15412d0cbf70a (diff) |
mdoc: Support for F# signatures
Added F# signatures and usage formatter
Added unit and integration tests
Closes #108
Diffstat (limited to 'mdoc/mdoc.Test/VBFormatterTests.cs')
-rw-r--r-- | mdoc/mdoc.Test/VBFormatterTests.cs | 41 |
1 files changed, 6 insertions, 35 deletions
diff --git a/mdoc/mdoc.Test/VBFormatterTests.cs b/mdoc/mdoc.Test/VBFormatterTests.cs index 7e2bf83a..de853856 100644 --- a/mdoc/mdoc.Test/VBFormatterTests.cs +++ b/mdoc/mdoc.Test/VBFormatterTests.cs @@ -1,15 +1,15 @@ -using System; -using System.Linq; using mdoc.Test.SampleClasses; -using Mono.Cecil; using Mono.Documentation.Updater; using NUnit.Framework; namespace mdoc.Test { [TestFixture()] - public class VBFormatterTests + public class VBFormatterTests : BasicFormatterTests<VBMemberFormatter> { + private VBMemberFormatter vbMemberFormatter = new VBMemberFormatter(); + protected override VBMemberFormatter formatter => vbMemberFormatter; + [Test] public void VB_op_Addition() => TestBinaryOp("Addition", "+"); @@ -118,7 +118,7 @@ namespace mdoc.Test [Test] public void Params() { - var member = GetMethod<TestClass>(m => m.Name == "DoSomethingWithParams"); + var member = GetMethod(typeof(TestClass), m => m.Name == "DoSomethingWithParams"); var formatter = new VBMemberFormatter(); var sig = formatter.GetDeclaration(member); Assert.AreEqual("Public Sub DoSomethingWithParams (ParamArray values As Integer())", sig); @@ -156,40 +156,11 @@ namespace mdoc.Test void TestOp(string name, string expectedSig, int argCount, string returnType = "TestClass") { - var member = GetMethod<TestClass>(m => m.Name == $"op_{name}" && m.Parameters.Count == argCount && m.ReturnType.Name == RealTypeName(returnType)); - var formatter = new VBMemberFormatter(); + var member = GetMethod(typeof(TestClass), m => m.Name == $"op_{name}" && m.Parameters.Count == argCount && m.ReturnType.Name == RealTypeName(returnType)); var sig = formatter.GetDeclaration(member); Assert.AreEqual(expectedSig, sig); } - MethodDefinition GetMethod<T>(Func<MethodDefinition, bool> query) - { - var type = typeof(T); - var moduleName = type.Module.FullyQualifiedName; - return GetMethod(GetType(moduleName, type.FullName), query); - } - - MethodDefinition GetMethod(TypeDefinition testclass, Func<MethodDefinition, bool> query) - { - var methods = testclass.Methods; - var member = methods.FirstOrDefault(query).Resolve(); - if (member == null) - throw new Exception("Did not find the member in the test class"); - return member; - } - - TypeDefinition GetType(string filepath, string classname) - { - var module = ModuleDefinition.ReadModule(filepath); - var types = module.GetTypes(); - var testclass = types - .SingleOrDefault(t => t.FullName == classname); - if (testclass == null) - { - throw new Exception($"Test was unable to find type {classname}"); - } - return testclass.Resolve(); - } #endregion } }
\ No newline at end of file |