public void GetInstance_Generic_ShouldGetInstanceFromLamarContainer() { //---------------Set up test pack------------------- var container = Substitute.For <IContainer>(); var iocContainer = new LamarThuriaIocContainer(container); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- iocContainer.GetInstance <IFakeObject>(); //---------------Test Result ----------------------- container.Received(1).TryGetInstance <IFakeObject>(); }
public void GetInstance_Generic_GivenObjectNotFound_ShouldNotThrowExceptionAndReturnNull() { //---------------Set up test pack------------------- var container = new Container(new ServiceRegistry()); var iocContainer = new LamarThuriaIocContainer(container); object returnedObject = null; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- Assert.DoesNotThrow(() => returnedObject = iocContainer.GetInstance <IFakeObject>()); //---------------Test Result ----------------------- returnedObject.Should().BeNull(); }
public void GetInstance_Generic_GivenObjectExists_ShouldNotThrowExceptionAndReturnInstanceOfObject() { //---------------Set up test pack------------------- var fakeObject = new FakeObject(); var container = new Container(registry => { registry.For <IFakeObject>().Use(fakeObject); }); var iocContainer = new LamarThuriaIocContainer(container); object returnedObject = null; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- Assert.DoesNotThrow(() => returnedObject = iocContainer.GetInstance <IFakeObject>()); //---------------Test Result ----------------------- returnedObject.Should().NotBeNull(); returnedObject.Should().BeAssignableTo <IFakeObject>(); returnedObject.Should().Be(fakeObject); }