public void TestDependencyInjectionOfDerivedTypeSucceeds()
        {
            var container = new ContainerBuilder();
            var builder = new DemandB();
            builder.Build(container);

            var resolver = new AutofacResolver(container.Build());

            Assert.That(resolver.Resolve<IFoo>(), Is.InstanceOf<B>());
            Assert.That(resolver.Resolve<IFooBar>(), Is.InstanceOf<B>());
        }
        public void TestDependencyInjectionThrowsWhenMissing()
        {
            var container = new ContainerBuilder();
            var resolver = new AutofacResolver(container.Build());

            resolver.Resolve<IFoo>();
        }
        public Task <TAggregate> CreateNewAggregateAsync <TAggregate, TIdentity>(TIdentity id)
            where TAggregate : IAggregateRoot <TIdentity>
            where TIdentity : IIdentity
        {
            var aggregate = _resolver.Resolve <TAggregate>(new TypedParameter(typeof(TIdentity), id));

            return(Task.FromResult(aggregate));
        }
Example #4
0
        public void Autofac_Resolve_Success()
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<Math>().As<IMath>();
            var container = builder.Build();

            var slowpoke = new AutofacResolver();
            slowpoke.Resolve(typeof(IMath), container);
        }
Example #5
0
        public void Autofac_Resolve_Success()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <Math>().As <IMath>();
            var container = builder.Build();

            var slowpoke = new AutofacResolver();

            slowpoke.Resolve(typeof(IMath), container);
        }
Example #6
0
        public virtual void SetUp()
        {
            var configurationBuilder = new Autofac.ContainerBuilder();

            var fresh = new CreateFreshDatabase();
            fresh.Create(configurationBuilder);

            var resolver = new AutofacResolver(configurationBuilder);

            Database = resolver.Resolve<IDocumentStore>();
            Universe = new MockUniverse();
        }
 /// <summary>Resolves a service given the required contract type.</summary>
 /// <typeparam name="T">The type with which the service implementation was registered.</typeparam>
 /// <returns>An instance of type <typeparamref name="T"/>.</returns>
 public override T Resolve <T>()
 {
     return(_dependencyResolver.Resolve <T>());
 }
Example #8
0
 public void TestStudentService()
 {
     var studentService = AutofacResolver.Resolve <IStudentService>();
     var result         = studentService.GetAllStudentsResponse().ToList();
 }
Example #9
0
 public void TestClassService()
 {
     var classService = AutofacResolver.Resolve <IClassService>();
     var result       = classService.GetClassesResponse().ToList();
 }