Created
April 25, 2012 19:29
-
-
Save MartinRL/2492561 to your computer and use it in GitHub Desktop.
StructureMapObjectFactoryResetDefaultsBug
This file contains 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
using System; | |
using FluentAssertions; | |
using StructureMap; | |
using Xunit; | |
namespace StructureMapObjectFactoryResetDefaultsBug | |
{ | |
public class Reproducer | |
{ | |
[Fact] | |
public void Given_ObjectFactory_Inject_When_ObjectFactory_ResetDefaults_Then_configured_instance_is_returned() | |
{ | |
ObjectFactory.Initialize(i => i.For<IFoo>().Use<FooProd>()); | |
ObjectFactory.Inject<IFoo>(new FooStub()); | |
ObjectFactory.GetInstance<IFoo>().Should().BeOfType<FooStub>(); | |
ObjectFactory.ResetDefaults(); | |
ObjectFactory.GetInstance<IFoo>().Should().BeOfType<FooProd>(); // fails | |
} | |
} | |
public interface IFoo {} | |
public class FooProd : IFoo {} | |
public class FooStub : IFoo {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment