public void ServiceViaFactory()
        {
            // Act
            _sut.Register <IMagicInterface>(r => new MagicClass());

            // Assert
            Assert_Service();
        }
Exemple #2
0
        public void DecoratorWorks()
        {
            // Arrange
            _sut.Register <IMagicInterface, MagicClass>();
            _sut.Decorate <IMagicInterface>((r, inner) => new MagicClassDecorator1(inner));
            _sut.Decorate <IMagicInterface>((r, inner) => new MagicClassDecorator2(inner));

            // Act
            var resolver = _sut.CreateResolver(true);
            var magic    = resolver.Resolve <IMagicInterface>();

            // Assert
            magic.Should().BeAssignableTo <MagicClassDecorator1>();
            var magicClassDecorator1 = (MagicClassDecorator1)magic;

            magicClassDecorator1.Inner.Should().BeAssignableTo <MagicClassDecorator2>();
            var magicClassDecorator2 = (MagicClassDecorator2)magicClassDecorator1.Inner;

            magicClassDecorator2.Inner.Should().BeAssignableTo <MagicClass>();
        }