Skip to content

Instantly share code, notes, and snippets.

@johnkors
Last active December 15, 2015 04:59
Show Gist options
  • Save johnkors/5205893 to your computer and use it in GitHub Desktop.
Save johnkors/5205893 to your computer and use it in GitHub Desktop.
InterfaceImplementations_Always_ShouldBeInjected
[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