public void Assert_Service()
        {
            // Act
            var resolver       = _sut.CreateResolver(true);
            var magicInterface = resolver.Resolve <IMagicInterface>();

            // Assert
            magicInterface.Should().NotBeNull();
            magicInterface.Should().BeAssignableTo <MagicClass>();
        }
Пример #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>();
        }