|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Reflection; |
| 5 | +using System.Text; |
| 6 | +using System.Threading.Tasks; |
| 7 | +using Xunit.Sdk; |
| 8 | + |
| 9 | +namespace Tests.Common { |
| 10 | + public class FormatterData : DataAttribute { |
| 11 | + private readonly string _fromatter; |
| 12 | + |
| 13 | + public FormatterData(string Formatter) { |
| 14 | + _fromatter = Formatter; |
| 15 | + } |
| 16 | + |
| 17 | + public override IEnumerable<object[]> GetData(MethodInfo testMethod) { |
| 18 | + // resolve path from current dll + formatter name |
| 19 | + |
| 20 | + // parse file |
| 21 | + // for each line in File.ReadAllLines(path) |
| 22 | + // if line.StartsWith("---") - new test |
| 23 | + // (test name embedded in ---- lines) |
| 24 | + // add to TheoryData<string, string, string> |
| 25 | + // expression name |
| 26 | + // formatter name |
| 27 | + // result |
| 28 | + |
| 29 | + // return TheoryData |
| 30 | + |
| 31 | + throw new NotImplementedException(); |
| 32 | + } |
| 33 | + } |
| 34 | +} |
| 35 | +/* |
| 36 | +test objects |
| 37 | + namespace: ExpressionToString.Tests.Objects |
| 38 | + ExpressionToString.Tests.Common |
| 39 | + CSCompiler |
| 40 | + FactoryMethods |
| 41 | + ExpressionToString.Tests.Common.VB |
| 42 | + VBCompiler |
| 43 | + spread across partial static classes/modules, based on category |
| 44 | + decorate with category custom attribute |
| 45 | +
|
| 46 | +base abstract class |
| 47 | + overridable RunTest |
| 48 | + parameters - object to test, object name |
| 49 | + protected PreRunTest |
| 50 | + parameters - caller member name |
| 51 | + resolve object from type of 'this' and member name |
| 52 | + calls RunTest with object, object name |
| 53 | +
|
| 54 | +three abstract classes, by source |
| 55 | + decorate class with source trait |
| 56 | + each one spread across multiple files, using partial |
| 57 | + each test method |
| 58 | + decorate with category trait |
| 59 | + corresponds to expression object |
| 60 | + calls PreRunTest |
| 61 | +
|
| 62 | +formatter tests |
| 63 | + static dictionary<string formatter, string objectName), string> with results |
| 64 | + for each registered formatter, load from files |
| 65 | + inherits three abstract classes |
| 66 | + RunTest calls static RunToStringTest, passing in object name and object |
| 67 | +
|
| 68 | + get results + pathspans from ToString("Factory methods") |
| 69 | +
|
| 70 | + for each formatter |
| 71 | + get expected using the formatter and the object name as a multipart key, against the static dictionary |
| 72 | + get actual using ToString(formatter) on the object |
| 73 | + if formatter == factory methods, use above |
| 74 | + Assert.Equals |
| 75 | +
|
| 76 | + do pathspans checks against factory methods pathspans |
| 77 | +
|
| 78 | +visualizer data tests |
| 79 | + inherits three abstract classes |
| 80 | + RunTest calls static VisualizerDataTest, passing in object |
| 81 | + static method creaates new VisualizerData from object |
| 82 | +
|
| 83 | +validation of test methods vs expressions - each expression object must have a corresponding test method |
| 84 | +
|
| 85 | +*/ |
0 commit comments