Exemple #1
0
        public void FulfillWithNull()
        {
            // Setup
            var dependency = new Dependency(typeof(Dependency1));

            // Execute
            dependency.Fulfill(a_service: null);
        }
Exemple #2
0
        public void ConstructDepencency()
        {
            // Execute
            var dependency = new Dependency(a_contract: typeof (Dependency1));

            // Assert
            Assert.AreSame(typeof(Dependency1), dependency.Contract);
        }
Exemple #3
0
        public void CheckIfFulfilledWhenNot()
        {
            // Setup
            var dependency = new Dependency(typeof (Dependency2));

            // Assert
            Assert.IsFalse(dependency.IsFulfilled);
        }
Exemple #4
0
        public void FulfillWithService()
        {
            // Setup
            var container = new Container();
            var service = new Service(container, typeof(Dependency1), typeof(DependencyBase), null);
            var dependency = new Dependency(typeof (Dependency1));

            // Execute
            dependency.Fulfill(a_service: service);

            // Assert
            Assert.IsTrue(dependency.IsFulfilled);
        }
Exemple #5
0
        public void FulfillWithContainer()
        {
            // Setup
            var container = new Container();
            container.Register<DependencyBase, Dependency2>();
            var dependency = new Dependency(typeof(DependencyBase));

            // Execute
            dependency.Fulfill(a_container: container);

            // Assert
            Assert.IsTrue(dependency.IsFulfilled);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="a_instanceServiceService">Instance.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="a_instanceServiceService"/> is null.</exception>
        public InstanceFactory(InstanceService a_instanceServiceService)
        {
            #region Argument Validation

            if (a_instanceServiceService == null)
                throw new ArgumentNullException(nameof(a_instanceServiceService));

            #endregion

            _instanceService = a_instanceServiceService;
            DependencyComplexity = 0;
            Dependencies = new Dependency[0];
            CanCreate = true;
        }
Exemple #7
0
        public void FulfillWithServiceOfWrongType()
        {
            // Setup
            var container = new Container();
            var service = new Service(container, typeof(Dependency2), typeof(DependencyBase), null);
            var dependency = new Dependency(typeof (Dependency1));

            // Execute
            dependency.Fulfill(a_service: service);
        }
Exemple #8
0
        public void ResolveFulfilledDependency()
        {
            // Setup
            var container = new Container();
            container.Register<DependencyBase, Dependency2>();
            var dependency = new Dependency(typeof(DependencyBase));
            dependency.Fulfill(a_container: container);

            // Execute
            var instance = dependency.Resolve();

            // Assert
            Assert.IsTrue(dependency.IsFulfilled);
        }