Example #1
0
        public void Dispose_DisposesOnlyOnce()
        {
            object      simulator  = Substitute.For <ISimulator, IDisposable>();
            ISimulation simulation = Simulation.Create();

            ((IAddSimulator)simulation).Add((ISimulator)simulator);

#pragma warning disable S3966 // Objects should not be disposed more than once - required for unit test
            simulation.Dispose();
            simulation.Dispose();
#pragma warning restore S3966 // Objects should not be disposed more than once

            ((IDisposable)simulator).Received(1).Dispose();
        }
Example #2
0
        static void Main(string[] args)
        {
            // Setup
            var form = SlimDXHelper.InitD3D(out _device, out _swapChain, out _renderView);
            var temp = form.ClientRectangle;

            _finalRender = new FSQ(_device, _renderView, "SimpleFSQ.fx");

            /*_simulation =
             *  new HybridFluidSim(
             *      _finalRender,
             *      _device);*/
            _simulation = new SemiGridSPHSimulation(_device, _finalRender.UAV);
            //_simulation = new MovingGridFluid.MovingGridFluid(_device, _finalRender.UAV);

            // Main loop
            MessagePump.Run(form, SimMain);

            // Tear down
            _finalRender.Dispose();

            _swapChain.Dispose();
            _renderView.Dispose();
            _simulation.Dispose();
            _device.Dispose();
        }
Example #3
0
        public void Dispose_DoesNotThrow_WhenSimulatorDoesNotImplementIDisposable()
        {
            ISimulator  simulator  = Substitute.For <ISimulator>();
            ISimulation simulation = Simulation.Create();

            ((IAddSimulator)simulation).Add(simulator);

            Action action = () => simulation.Dispose();

            action.ShouldNotThrow();
        }
Example #4
0
        public void Dispose_DoesNotThrow_WhenSimulatorThrowsWhenStopping()
        {
            ISimulator simulator = Substitute.For <ISimulator>();

            simulator.StopAsync().Returns(_ => Task.FromException(new ArgumentException("Task is null")));
            ISimulation simulation = Simulation.Create();

            ((IAddSimulator)simulation).Add(simulator);

            Action action = () => simulation.Dispose();

            action.ShouldNotThrow();
        }
Example #5
0
        public async Task TearDown()
        {
            await _simulation.StopAllAsync();

            _simulation.Dispose();
        }
Example #6
0
 public void TearDown()
 {
     _simulation.Dispose();
     _testCertificate?.Dispose();
 }