Beispiel #1
0
        public void ShouldResolveDefaultImplementation()
        {
            // arrange
            var target = new Composition.CompositionRoot();

            // act
            var actual = target.Container.Resolve <IController>();

            // assert
            Assert.AreEqual(actual.GetMessage(), "Hello World");
        }
Beispiel #2
0
        public void UseOfDynamicDependencyOverrideAsPartOfStrategy()
        {
            // arrange
            var target = new Composition.CompositionRoot();

            // act
            var actual = target.Container.Resolve <ILayer>();

            // assert
            Assert.IsNotNull(actual);
        }
Beispiel #3
0
        public void ShouldResolveAlternativeImplementationWhenUsingOverride()
        {
            // arrange
            var target             = new Composition.CompositionRoot();
            var resolvedParameter  = new ResolvedParameter <IMessageProvider>(nameof(AlternativeMessageProvider));
            var dependencyOverride = new DependencyOverride <IMessageProvider>(resolvedParameter);

            // act
            var actual = target.Container.Resolve <IController>(dependencyOverride);

            // assert
            Assert.AreEqual(actual.GetMessage(), "Goodbye cruel world!");
        }
Beispiel #4
0
        public void DirectUseOfDependencyOverride()
        {
            // arrange
            var target             = new Composition.CompositionRoot();
            var resolvedParameter  = new ResolvedParameter <IDrillBit>(CompositionRoot.SecondDrill);
            var dependencyOverride = new DependencyOverride <IDrillBit>(resolvedParameter);

            // act
            var actual = target.Container.Resolve <ILayer>(dependencyOverride);

            // assert
            Assert.IsNotNull(actual);
        }