public void Can_override_service_creation_with_custom_implementation() { using (var appHost = new BasicAppHost(typeof(BasicService).Assembly).Init()) { var container = appHost.Container; var serviceController = appHost.ServiceController; container.Register<IFoo>(c => new Foo()); container.Register<IBar>(c => new Bar()); var request = new AutoWire(); var response = serviceController.Execute(request) as AutoWireResponse; Assert.That(response, Is.Not.Null); Assert.That(response.Foo as Foo, Is.Not.Null); Assert.That(response.Bar as Bar, Is.Not.Null); container.Register(c => new AutoWireService(new Foo2()) { Bar = new Bar2() }); response = serviceController.Execute(request) as AutoWireResponse; Assert.That(response, Is.Not.Null); Assert.That(response.Foo as Foo2, Is.Not.Null); Assert.That(response.Bar as Bar2, Is.Not.Null); } }
public void Can_override_service_creation_with_custom_implementation() { using (var appHost = new BasicAppHost(typeof(BasicService).Assembly).Init()) { var container = appHost.Container; var serviceController = appHost.ServiceController; container.Register <IFoo>(c => new Foo()); container.Register <IBar>(c => new Bar()); var request = new AutoWire(); var response = serviceController.Execute(request) as AutoWireResponse; Assert.That(response, Is.Not.Null); Assert.That(response.Foo as Foo, Is.Not.Null); Assert.That(response.Bar as Bar, Is.Not.Null); container.Register(c => new AutoWireService(new Foo2()) { Bar = new Bar2() }); response = serviceController.Execute(request) as AutoWireResponse; Assert.That(response, Is.Not.Null); Assert.That(response.Foo as Foo2, Is.Not.Null); Assert.That(response.Bar as Bar2, Is.Not.Null); } }
public void Can_register_all_services_in_an_assembly() { using (var appHost = new BasicAppHost(typeof(BasicService).Assembly).Init()) { var container = appHost.Container; var serviceController = appHost.ServiceController; container.Register<IFoo>(c => new Foo()); container.Register<IBar>(c => new Bar()); var request = new AutoWire(); var response = serviceController.Execute(request) as AutoWireResponse; Assert.That(response, Is.Not.Null); } }
public void Can_register_all_services_in_an_assembly() { using (var appHost = new BasicAppHost(typeof(BasicService).Assembly).Init()) { var container = appHost.Container; var serviceController = appHost.ServiceController; container.Register <IFoo>(c => new Foo()); container.Register <IBar>(c => new Bar()); var request = new AutoWire(); var response = serviceController.Execute(request) as AutoWireResponse; Assert.That(response, Is.Not.Null); } }
public object Any(AutoWire request) { return new AutoWireResponse { Foo = foo, Bar = Bar }; }
/// <summary>Anies the given request.</summary> /// /// <param name="request">The request.</param> /// /// <returns>An AutoWireResponse.</returns> public AutoWireResponse Any(AutoWire request) { return(new AutoWireResponse { Foo = foo, Bar = Bar }); }