예제 #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();
        }
예제 #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);
        }
예제 #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();
        }
예제 #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()
                );
        }