Created
January 15, 2014 14:38
-
-
Save rarous/8437413 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FormReaders | |
{ | |
const string SlovakConnectors = "MultiConnector.Connectors.Svk.*.dll"; | |
public static IEnumerable<object[]> Connectors | |
{ | |
get | |
{ | |
var currentDir = Path.GetFullPath("."); | |
return from file in Directory.EnumerateFiles(currentDir, SlovakConnectors) | |
orderby file | |
let asm = Assembly.LoadFile(file) | |
from type in asm.GetTypes() | |
where typeof(IConnector).IsAssignableFrom(type) | |
&& !type.IsAbstract | |
select new object[] { type, file }; | |
} | |
} | |
[Theory] | |
[PropertyData("Connectors")] | |
public void ConnectorShouldHaveCorrespondingFormReader(Type connector, string file) | |
{ | |
var uiAsm = Assembly.Load(file.Replace(".dll", ".UI.dll")); | |
var readers = from type in uiAsm.GetTypes() | |
where typeof(IFormReader).IsAssignableFrom(type) | |
&& !type.IsAbstract | |
select type; | |
Assert.True(readers.Any(x => | |
x.Name.Replace("FormReader", "") == connector.Name.Replace("Connector", "")), | |
String.Format("Connector {0} does not have form reader defined.", connector.Name)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment