Ejemplo n.º 1
0
        public void Dispose_DoesNotThrow_WhenCalledTwice()
        {
            var apiBuilder   = new ApiBuilder(Substitute.For <ISimulation>());
            var apiSimulator = new ApiSimulator(apiBuilder);

            Action action = () =>
            {
                apiSimulator.Dispose();
                apiSimulator.Dispose();
            };

            action.ShouldNotThrow();
        }
Ejemplo n.º 2
0
        public async Task Dispose_SetsStateToStopped()
        {
            var apiBuilder   = new ApiBuilder(Substitute.For <ISimulation>());
            var apiSimulator = new ApiSimulator(apiBuilder);
            await apiSimulator.StartAsync();

            apiSimulator.Dispose();

            apiSimulator.State.ShouldBe(SimulatorState.Stopped);
        }
Ejemplo n.º 3
0
        public async Task Dispose_DoesNotThrow_WhenSimulatorRunning()
        {
            var apiBuilder   = new ApiBuilder(Substitute.For <ISimulation>());
            var apiSimulator = new ApiSimulator(apiBuilder);

            await apiSimulator.StartAsync();

            await Task.Delay(100);

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

            action.ShouldNotThrow();
        }
Ejemplo n.º 4
0
        public void Dispose_DoesNotThrow_WhenCertificateNotSet()
        {
            ApiBuilder apiBuilder = new ApiBuilder(Substitute.For <ISimulation>())
                                    .SetCertificate(null);
            var apiSimulator = new ApiSimulator(apiBuilder);

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

            apiSimulator.ShouldSatisfyAllConditions(
                () => apiSimulator.Settings.Certificate.ShouldBeNull(),
                () => action.ShouldNotThrow()
                );
        }