public void Startable_WhenChildScopeBegins_NewStartableComponentsAreStarted() { var startable = new Startable(); var builder = new ContainerBuilder(); var container = builder.Build(); var scope = container.BeginLifetimeScope(b => b.RegisterInstance(startable).As <IStartable>()); Assert.True(startable.StartCount > 0); }
public void Startable_WhenNoStartIsSpecified_StartableComponentsAreIgnoredInChildLifetimeScope() { var startable = new Startable(); var builder = new ContainerBuilder(); var container = builder.Build(ContainerBuildOptions.IgnoreStartableComponents); var scope = container.BeginLifetimeScope(b => b.RegisterInstance(startable).As <IStartable>()); Assert.False(startable.StartCount > 0); }
public void Startable_WhenStartIsSpecified_StartableComponentsAreStarted() { var startable = new Startable(); var builder = new ContainerBuilder(); builder.RegisterInstance(startable).As <IStartable>(); builder.Build(); Assert.True(startable.StartCount > 0); }
public void SetUp() { _startable = new Startable(); _updatable = new Updatable(); _destroyable = new Destroyable(); _fixedUpdatable = new FixedUpdatable(); _lateUpdatable = new LateUpdatable(); _container = CreateContainerWith <DependencyContainer>(); }
public override void start() { for (int i = 0; i < particleSystems.Length; i++) { particleSystems[i].Play(); } for (int i = 0; i < Startables.Length; i++) { Startable startable = Startables[i]; if (startable != this && ((MonoBehaviour)startable).isActiveAndEnabled) { startable.start(); } } }
public void Startable_WhenTheContainerIsUpdated_NewStartableComponentsAreStarted() { // Issue #454: ContainerBuilder.Update() doesn't activate startable components. var container = new ContainerBuilder().Build(); var startable = new Startable(); var builder = new ContainerBuilder(); builder.RegisterInstance(startable).As <IStartable>(); #pragma warning disable CS0618 builder.Update(container); #pragma warning restore CS0618 Assert.Equal(1, startable.StartCount); }
private void beginFire() { if (curCooldown < cooldown) { return; } curCooldown = 0; for (int i = 0; i < particleSystems.Length; i++) { particleSystems[i].Play(); justFired = true; } for (int i = 0; i < _startables.Length; i++) { Startable startable = _startables[i]; if (((MonoBehaviour)startable).enabled) { startable.start(); } } }
public void Startable_WhenTheContainerIsUpdated_ExistingStartableComponentsAreNotRestarted() { var startable1 = new Startable(); var startable2 = new Startable(); var builder1 = new ContainerBuilder(); builder1.RegisterInstance(startable1).As <IStartable>(); var container = builder1.Build(); Assert.Equal(1, startable1.StartCount); var builder2 = new ContainerBuilder(); builder2.RegisterInstance(startable2).As <IStartable>(); #pragma warning disable CS0618 builder2.Update(container); #pragma warning restore CS0618 Assert.Equal(1, startable1.StartCount); Assert.Equal(1, startable2.StartCount); }
private void FixedUpdate() { if (step2 == null) { return; } if (!wasAtGround && step2.step.dockedState) { for (int i = 0; i < particleSystems.Length; i++) { particleSystems[i].Play(); } for (int i = 0; i < _startables.Length; i++) { Startable startable = _startables[i]; if (((MonoBehaviour)startable).enabled) { startable.start(); } } } wasAtGround = step2.step.dockedState; }
protected void SetUp() { sub = new CurrencyConverter(); }
public ServiceABC(Startable[] dependencies) { this.dependencies = dependencies; }