Build/Test Issues

Issue with structure map dependency resolver test

Started by kburnell on 5,949 views

In my NCrunch window one of my tests is always marked as failing, even though it passes when ran. The specific test involves testing my StructureMap dependency resolver. The code from the class under test and the test class are provided below.

Class Under Test

public static class Resolver {

public static T GetConcreteInstanceOf<T>() {
return ObjectFactory.GetInstance<T>();
}
}

Test Class
[TestClass]
public class ResolverTest {

[TestMethod]
public void GetConcreteInstanceOf_ShouldReturn_LoggingService_WhenT_Is_ILoggingService() {
//Arrange
ObjectFactory.Initialize(registry => registry.Scan(x =>
{
x.AssembliesFromApplicationBaseDirectory();
x.WithDefaultConventions();
}));
//Act
ILoggingService result = Resolver.GetConcreteInstanceOf<ILoggingService>();
//Assert
result.ShouldBeType<LoggingService>();
}
}

Post a reply

Log in to reply.