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