public override void InstallBindings() { var disposer = Disposer.Create(); Container.Bind <IDisposable>().FromInstance(disposer); Container.Bind <IDisposer>().FromInstance(disposer); Container.BindInterfacesTo <UniRxEventBus>().AsSingle(); ServiceInstaller.Install(Container); PlayAreaInstaller.Install(Container); FactoryInstaller.Install(Container); PlayerInstaller.Install(Container); PreparationPhaseInstaller.Install(Container); CombatPhaseInstaller.Install(Container); HudInstaller.Install(Container); ShopInstaller.Install(Container); RoundInstaller.Install(Container); }
public void Value_ValueIsDisposed() { Disposer <TestClass> tc = null; using (tc = Disposer <TestClass> .Create(new TestClass(), (t) => { })) { } TestClass rawTc = tc.Value; }
/// <summary> /// Create a disposer to provide onEnter and onExit functionality. /// </summary> /// <param name="onEnter"></param> /// <param name="onExit"></param> /// <returns></returns> protected Disposer <T> Create(Action <T> onEnter, Action <T> onExit) { #region Input validation Insist.IsNotNull(onEnter, "onEnter"); Insist.IsNotNull(onExit, "onExit"); #endregion return(Disposer <T> .Create(_value, onEnter, onExit)); }
public override void InstallBindings() { var disposer = Disposer.Create(); Container.Rebind <IDisposer>().FromInstance(disposer); Container.Bind <IDisposable>().FromInstance(disposer); var shopPool = Container.Resolve <IUnitPool <IShopUnitModel> >(); shopPool.Clear(); // TODO create board controller and visuals }
public void Dispose_CalledExplicitly() { Disposer <TestClass> tc = Disposer <TestClass> .Create( new TestClass(), (t) => { t.Close(); }); TestClass rawTc = tc.Value; tc.Dispose(); Assert.IsTrue(tc.IsDisposed); Assert.IsTrue(rawTc.IsClosed); }
public void Dispose_CalledFromUsingBlock() { Disposer <TestClass> tc; TestClass rawTc; using (tc = Disposer <TestClass> .Create( new TestClass(), (t) => { t.Close(); })) { rawTc = tc.Value; } Assert.IsTrue(tc.IsDisposed); Assert.IsTrue(rawTc.IsClosed); }
public void Dispose_CalledExplicitlyMoreThanOnce() { Disposer <TestClass> tc = Disposer <TestClass> .Create( new TestClass(), (t) => { t.Close(); }); TestClass rawTc = tc.Value; //Dispose should be callable multiple times without throwing an error. tc.Dispose(); tc.Dispose(); Assert.IsTrue(tc.IsDisposed); Assert.IsTrue(rawTc.IsClosed); }
public void Create_EntryActionExecuted() { TestClass tc = new TestClass(); bool startupActionCalled = false; bool disposeActionCalled = false; using (Disposer <TestClass> subject = Disposer <TestClass> .Create( tc, t => startupActionCalled = true, t => disposeActionCalled = true)) {} Assert.IsTrue(startupActionCalled); Assert.IsTrue(disposeActionCalled); }
public void Dispose_DisposeCausesException() { Disposer <TestClass> tc = null; try { using (tc = Disposer <TestClass> .Create( new TestClass(), (t) => { t.CloseWithException(); })) { } } catch (ApplicationException) { } Assert.IsTrue(tc.IsDisposed); }
public async Task DisposeAsync_Then_OnDisposedAndOnDisposedAsyncShouldBeCalledOnceInOrder() { var disposableReporter = Mock.Create <IDisposableReporter>(); var disposable = Mock.Create <IDisposable>(); var asyncDisposable = Mock.Create <IAsyncDisposable>(); Mock.Arrange(() => disposableReporter.Disposed(disposable)).InOrder().Occurs(1); Mock.Arrange(() => disposableReporter.Disposed(asyncDisposable)).InOrder().Occurs(1); var disposer = Disposer.Create( disposerBuilder => { disposerBuilder.Add(disposable); disposerBuilder.AddAsync(asyncDisposable); }, disposableReporter); await disposer.DisposeAsync().ConfigureAwait(false); Mock.Assert(disposableReporter); }
public void Dispose_Then_OnDisposedAndOnDisposedAsyncShouldBeCalledOnceInOrder() { var disposableReporter = Mock.Create <IDisposableReporter>(); var disposable = Mock.Create <IDisposable>(); var asyncDisposable = Mock.Create <IAsyncDisposable>(); Mock.Arrange(() => disposableReporter.Disposed(disposable)).InOrder().Occurs(1); Mock.Arrange(() => disposableReporter.Disposed(asyncDisposable)).InOrder().Occurs(1); var disposer = Disposer.Create( disposerBuilder => { disposerBuilder.Add(disposable); disposerBuilder.AddAsync(asyncDisposable); }, disposableReporter); disposer.Dispose(); Mock.Assert(disposableReporter); }
public void Create_ValueAndActionNull() { using (Disposer <TestClass> tc = Disposer <TestClass> .Create(null, null)) { } }
public void Create_ActionNull() { using (Disposer <TestClass> tc = Disposer <TestClass> .Create(new TestClass(), null)) { } }
public void Create_ValueNull() { using (Disposer <TestClass> tc = Disposer <TestClass> .Create(null, (t) => { })) { } }