public void ComponentIsResolved() { var config = new ComponentConfig(); config.Add <SimpleObject>(); using var container = config.ToContainer(); var obj = container.Get <SimpleObject>(); Assert.NotNull(obj); }
public void ComponentIsResolvedSameObject() { var config = new ComponentConfig(); config.Add <SimpleObject>(); using var container = config.ToContainer(); var obj1 = container.Get <SimpleObject>(); var obj2 = container.GetService(typeof(SimpleObject)); Assert.Same(obj1, obj2); }
public void ComponentIsMultipleResolvedByGetService() { var config = new ComponentConfig(); config.Add <ICalcService, AddCalcService>(); config.Add <ICalcService, SubCalcService>(); using var container = config.ToContainer(); var services = (IEnumerable <ICalcService>?)container.GetService(typeof(IEnumerable <ICalcService>)); Assert.Equal(2, services?.Count()); }
public void ComponentIsMultipleResolved() { var config = new ComponentConfig(); config.Add <ICalcService, AddCalcService>(); config.Add <ICalcService, SubCalcService>(); using var container = config.ToContainer(); var services = container.GetAll <ICalcService>(); Assert.Equal(2, services.Count()); }
public void ComponentIsResolvedByDefaultConstructor() { var config = new ComponentConfig(); config.Add <MultiConstructorObject>(); using var container = config.ToContainer(); var obj = container.Get <MultiConstructorObject>(); Assert.Equal(0, obj.Arguments); Assert.Null(obj.CalcService); }
public void ComponentIsResolvedWithMultipleArgument() { var config = new ComponentConfig(); config.Add <ArrayParameterObject>(); config.Add <ICalcService, AddCalcService>(); config.Add <ICalcService, SubCalcService>(); using var container = config.ToContainer(); var obj = container.Get <ArrayParameterObject>(); Assert.Equal(2, obj.CalcServices.Length); }
public void ComponentIsDisposed() { var config = new ComponentConfig(); config.Add <DisposableObject>(); DisposableObject obj; using (var container = config.ToContainer()) { obj = container.Get <DisposableObject>(); } Assert.Equal(1, obj.Disposed); }