Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Issue with structure map dependency resolver test
kburnell
#1 Posted : Wednesday, April 25, 2012 2:49:12 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/25/2012(UTC)
Posts: 2

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>();
}
}

Remco
#2 Posted : Wednesday, April 25, 2012 4:57:29 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi, thanks for posting!

It looks to me like this test is making assumptions about the location of assemblies within its application domain. I suggest having a read of the test issue troubleshooting guide, as it has a section that covers this - https://www.ncrunch.net/documentation/troubleshooting_test-and-runtime-related-issues

I hope this helps.


Cheers,

Remco
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.023 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download