From 4958defdeb38db888255d3405be99e6244ece5d5 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Sat, 3 Jun 2017 19:39:54 -0700 Subject: [PATCH] Revise DeleteProfileWorksForGuest test - Prevent null reference on SyncPrinterProfiles() --- SlicerConfiguration/Settings/SettingsHelpers.cs | 4 ++-- .../SliceSettingsTests.cs | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/SlicerConfiguration/Settings/SettingsHelpers.cs b/SlicerConfiguration/Settings/SettingsHelpers.cs index ce4667614..f63166e84 100644 --- a/SlicerConfiguration/Settings/SettingsHelpers.cs +++ b/SlicerConfiguration/Settings/SettingsHelpers.cs @@ -215,8 +215,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration // Notify listeners of a ProfileListChange event due to this printers removal ProfileManager.ProfilesListChanged.CallEvents(this, null); - // Force sync after marking for delete - ApplicationController.SyncPrinterProfiles("SettingsHelpers.SetMarkedForDelete()", null); + // Force sync after marking for delete if assigned + ApplicationController.SyncPrinterProfiles?.Invoke("SettingsHelpers.SetMarkedForDelete()", null); }); } diff --git a/Tests/MatterControl.AutomationTests/SliceSettingsTests.cs b/Tests/MatterControl.AutomationTests/SliceSettingsTests.cs index af0d4033c..97f694aa9 100644 --- a/Tests/MatterControl.AutomationTests/SliceSettingsTests.cs +++ b/Tests/MatterControl.AutomationTests/SliceSettingsTests.cs @@ -242,27 +242,23 @@ namespace MatterHackers.MatterControl.Tests.Automation [Test] public async Task DeleteProfileWorksForGuest() { - AutomationTest testToRun = (testRunner) => + await MatterControlUtilities.RunTest((testRunner) => { - testRunner.CloseSignInAndPrinterSelect(); - // assert no profiles - Assert.IsTrue(ProfileManager.Instance.ActiveProfiles.Count() == 0); + Assert.AreEqual(0, ProfileManager.Instance.ActiveProfiles.Count()); MatterControlUtilities.AddAndSelectPrinter(testRunner, "Airwolf 3D", "HD"); // assert one profile - Assert.IsTrue(ProfileManager.Instance.ActiveProfiles.Count() == 1); + Assert.AreEqual(1, ProfileManager.Instance.ActiveProfiles.Count(), "One profile should exist after add"); MatterControlUtilities.DeleteSelectedPrinter(testRunner); // assert no profiles - Assert.IsTrue(ProfileManager.Instance.ActiveProfiles.Count() == 0); + Assert.AreEqual(0, ProfileManager.Instance.ActiveProfiles.Count(), "No profiles should exist after delete"); return Task.FromResult(0); - }; - - await MatterControlUtilities.RunTest(testToRun, overrideWidth: 1224, overrideHeight: 900); + }, overrideWidth: 1224, overrideHeight: 900); } private static void CheckAndUncheckSetting(AutomationRunner testRunner, string settingToChange, string checkBoxName, bool expected)