예제 #1
0
        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));
        }
예제 #2
0
        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();
        }
예제 #3
0
        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);
        }