private void OnCounterExample(object sender, RoutedEventArgs e) { var counterExampleSerialization = new SafetySharpCounterExampleSerialization(); var dialog = new OpenFileDialog { AddExtension = true, CheckFileExists = true, CheckPathExists = true, DefaultExt = ".ltsmin", Filter = $"S# Counter Examples (*{counterExampleSerialization.FileExtension})|*{counterExampleSerialization.FileExtension}", Title = "Open S# Counter Example", Multiselect = false }; if (dialog.ShowDialog() != true) { return; } try { var simulator = new SafetySharpSimulator(counterExampleSerialization.Load(dialog.FileName)); SetSimulator(simulator); CloseCounterExampleButton.Visibility = Visibility.Visible; } catch (Exception ex) { var message = "An incompatible change has been made to the model since the counter example has been generated: " + ex.Message; MessageBox.Show(message, "Failed to Load Counter Example", MessageBoxButton.OK, MessageBoxImage.Error); } }
protected void SimulateCounterExample(ExecutableCounterExample <SafetySharpRuntimeModel> counterExample, Action <SafetySharpSimulator> action) { // Test directly action(new SafetySharpSimulator(counterExample)); // Test persisted using (var file = new TemporaryFile(".ssharp")) { counterExample.Save(file.FilePath); var counterExampleSerialization = new SafetySharpCounterExampleSerialization(); action(new SafetySharpSimulator(counterExampleSerialization.Load(file.FilePath))); } }