it_should_register_the_instance_returned_from_the_Func_delegate_with_the_generic_contract_specified() { using (var helper = new AutofacServiceLocatorHelper()) { var myType = new MyImplementation(); helper.AutofacServiceLocator.Register <IMyTestingContract>(() => myType); helper.Container.Resolve <IMyTestingContract>().Should().BeOfType <MyImplementation>().And.Be(myType); } }
public void it_should_inject_an_existing_instance() { using (var helper = new AutofacServiceLocatorHelper()) { helper.AutofacServiceLocator.Register <Additionaltype>(new Additionaltype()); var myObject = new MyImplementation(); myObject = helper.AutofacServiceLocator.Inject(myObject); myObject.Should().NotBeNull().And.BeOfType <MyImplementation>(); myObject.AdditionalType.Should().NotBeNull().And.BeOfType <Additionaltype>(); } }
public void it_should_tear_down_the_specified_instance() { using (var helper = new AutofacServiceLocatorHelper()) { var myObject = new MyImplementation(); helper.AutofacServiceLocator.Invoking(x => x.Release(myObject)); helper.AutofacServiceLocator.Register <IMyTestingContract>(myObject); helper.AutofacServiceLocator.Invoking(x => x.TearDown(myObject)) .ShouldNotThrow(); } }
public void it_should_inject_an_existing_instance() { using (var helper = new AutofacServiceLocatorHelper()) { helper.AutofacServiceLocator.Register<Additionaltype>(new Additionaltype()); var myObject = new MyImplementation(); myObject = helper.AutofacServiceLocator.Inject(myObject); myObject.Should().NotBeNull().And.BeOfType<MyImplementation>(); myObject.AdditionalType.Should().NotBeNull().And.BeOfType<Additionaltype>(); } }
public void it_should_tear_down_the_specified_instance() { using (var helper = new AutofacServiceLocatorHelper()) { var myObject = new MyImplementation(); helper.AutofacServiceLocator.Invoking(x => x.Release(myObject)); helper.AutofacServiceLocator.Register<IMyTestingContract>(myObject); helper.AutofacServiceLocator.Invoking(x => x.TearDown(myObject)) .ShouldNotThrow(); } }
public void it_should_register_the_instance_specified_with_the_generic_contract_specified() { using (var helper = new AutofacServiceLocatorHelper()) { var myType = new MyImplementation(); helper.AutofacServiceLocator.Register<IMyTestingContract>(myType); helper.Container.Resolve<IMyTestingContract>().Should().BeOfType<MyImplementation>().And.Be(myType); } }