public void Test_Inject_Does_Not_ReWrap_BindingResolutionException() { BindingResolutionException ex = new BindingResolutionException(typeof(INeedSample), new Exception()); bool caught = false; var injection = Inject() .Where(value => InjectedInto(value) as INeedSample) .Select(value => { value.Sample = null; throw ex; }); try { INeedSample needSample = new NeedSample(); injection.Inject(needSample); } catch (BindingResolutionException e) { Assert.Same(ex, e); caught = true; } Assert.True(caught); }
public void Test_Create_Exception_With_BindingType() { var exception = new BindingResolutionException(typeof(ISample), null); var otherException = new BindingResolutionException("Message", typeof(ISample), null); Assert.Equal(typeof(ISample), exception.BindingType); Assert.Equal(typeof(ISample), otherException.BindingType); }
public void Test_Constructor_Throws_ArgumentNullExeption_When_Given_Null_BindingType() { Assert.Throws <ArgumentNullException>(() => { var exception = new BindingResolutionException(null, null); var exception1 = new BindingResolutionException("Message", null, null); }); }
public void Test_Resolve_Throws_InvalidOperationException_When_Dependencies_Have_Not_Been_Set() { DerivedLazyConstructorBinding binding = new DerivedLazyConstructorBinding(); binding.ConstructionExpression = bindings => new object(); BindingResolutionException ex = Assert.Throws <BindingResolutionException>(() => { object obj = binding.Resolve(); }); Assert.NotNull(ex.InnerException); Assert.IsType <InvalidOperationException>(ex.InnerException); }