Last active
December 15, 2015 04:59
-
-
Save johnkors/5205893 to your computer and use it in GitHub Desktop.
InterfaceImplementations_Always_ShouldBeInjected
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
[Test] | |
public void InterfaceImplementations_Always_ShouldBeInjected() | |
{ | |
var interfaces = _source.OfType<InterfaceDeclarationSyntax>().Select( | |
x => x.Identifier.ToString() | |
); | |
var classes = _source.OfType<ClassDeclarationSyntax>(); | |
var implementsInterface = classes.Where( | |
c => ( | |
c.BaseList != null && | |
c.BaseList.Types.Select(t => t.ToString()).Any( | |
t => interfaces.Any(i => i.Contains(t)) | |
) | |
) | |
).Select(i => i.Identifier.ToString()).ToList(); | |
var notInjected = _source.OfType<ObjectCreationExpressionSyntax>() | |
.Where( | |
o => implementsInterface.Contains(o.Type.ToString()) | |
); | |
Assert.That(notInjected.Count(), Is.EqualTo(0)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment