public void GetAllInstances_ShouldGetInstancesFromLamarContainer() { //---------------Set up test pack------------------- var container = Substitute.For <IContainer>(); var iocContainer = new LamarThuriaIocContainer(container); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- iocContainer.GetAllInstances(typeof(IFakeObject)); //---------------Test Result ----------------------- container.Received(1).GetAllInstances(typeof(IFakeObject)); }
public void GetAllInstances_GivenObjectsNotFound_ShouldNotThrowExceptionAndReturnEmptyList() { //---------------Set up test pack------------------- var container = new Container(new ServiceRegistry()); var iocContainer = new LamarThuriaIocContainer(container); IEnumerable <object> returnedObjects = null; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- Assert.DoesNotThrow(() => returnedObjects = iocContainer.GetAllInstances(typeof(IFakeObject))); //---------------Test Result ----------------------- var enumerable = returnedObjects as object[] ?? returnedObjects.ToArray(); enumerable.Should().NotBeNull(); enumerable.Any().Should().BeFalse(); }
public void GetAllInstances_GivenObjectsExists_ShouldNotThrowExceptionAndReturnListOfObjects() { //---------------Set up test pack------------------- var fakeObject1 = new FakeObject(); var fakeObject2 = new FakeObject(); var container = new Container(registry => { registry.For <IFakeObject>().Use(fakeObject1); registry.For <IFakeObject>().Use(fakeObject2); }); var iocContainer = new LamarThuriaIocContainer(container); IEnumerable <object> returnedObjects = null; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- Assert.DoesNotThrow(() => returnedObjects = iocContainer.GetAllInstances(typeof(IFakeObject))); //---------------Test Result ----------------------- var enumerable = returnedObjects as object[] ?? returnedObjects.ToArray(); enumerable.Should().NotBeNull(); enumerable.Count().Should().Be(2); }