Example #1
0
        public void DeveRegistrarOperacaoDeCompraUtilizandoNinjectConstructorInjection()
        {
            using (IKernel kernel = new StandardKernel())
            {
                kernel.Bind <ILog>().To <LogNovo>().InSingletonScope();
                kernel.Bind <IRepositorio <Carteira> >().To <RepositorioCarteiraFake>().InTransientScope();

                CarteiraService carteiraService = kernel.Get <CarteiraService>();
                Assert.IsTrue(
                    carteiraService.RegistrarOperacaoDeCompra(new Operacao(), new Carteira())
                    );
            }
        }
        public void DeveRegistrarOperacaoDeCompraUtilizandoUnityConstructorInjection()
        {
            var container = new UnityContainer();

            container.RegisterType <ILog, LogNovo>();
            container.RegisterType <IRepositorio <Carteira>, RepositorioCarteiraFake>();


            CarteiraService carteiraService = container.Resolve <CarteiraService>();

            Assert.IsTrue(
                carteiraService.RegistrarOperacaoDeCompra(new Operacao(), new Carteira())
                );
        }
        public void DeveRegistrarOperacaoDeCompraUtilizandoAutofacConstructorInjection()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <CarteiraService>().AsSelf();
            builder.RegisterType <Log>().As <ILog>();
            builder.RegisterType <RepositorioCarteiraFake>().As <IRepositorio <Carteira> >();

            var container = builder.Build();

            using (container.BeginLifetimeScope())
            {
                CarteiraService carteiraService = container.Resolve <CarteiraService>();
                Assert.IsTrue(
                    carteiraService.RegistrarOperacaoDeCompra(new Operacao(), new Carteira())
                    );
            }
        }