protected override bool TryLoadControl(TestHostAutomationControl testHost, out string testedControlAutomationId) { var controlType = typeof(TControl); TestHost = testHost; var testDirectory = TestContext.CurrentContext.TestDirectory; testHost.TryLoadAssembly(Path.Combine(testDirectory, "DiffEngine.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "ApprovalUtilities.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "ApprovalTests.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "ControlzEx.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "Orc.Theming.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "Orc.Controls.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "Orc.FileSystem.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "Orc.Automation.Tests.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "Orc.Snapshots.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "Orc.Snapshots.Xaml.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "Orc.Snapshots.Tests.dll")); testHost.TryLoadResources("pack://application:,,,/Orc.Theming;component/Themes/Generic.xaml"); testHost.TryLoadResources("pack://application:,,,/Orc.Snapshots.Xaml;component/Themes/Generic.xaml"); var result = testHost.TryLoadControlWithForwarders(controlType, out testedControlAutomationId, $"pack://application:,,,/{controlType.Assembly.GetName().Name};component/Themes/Generic.xaml"); return(result); }
protected override bool TryLoadControl(TestHostAutomationControl testHost, out string testedControlAutomationId) { var controlType = typeof(System.Windows.Controls.ItemsControl); var testDirectory = TestContext.CurrentContext.TestDirectory; testHost.TryLoadAssembly(Path.Combine(testDirectory, "DiffEngine.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "ApprovalUtilities.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "ApprovalTests.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "ControlzEx.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "Orc.Theming.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "Orc.Controls.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "Orc.Automation.Tests.dll")); testHost.TryLoadAssembly(Path.Combine(testDirectory, "Orc.Controls.Tests.dll")); testHost.TryLoadResources("pack://application:,,,/Orc.Theming;component/Themes/Generic.xaml"); testHost.TryLoadResources("pack://application:,,,/Orc.Controls;component/Themes/Generic.xaml"); return(testHost.TryLoadControlWithForwarders(controlType, out testedControlAutomationId)); }
public static bool TryLoadControlWithForwarders(this TestHostAutomationControl testHost, Type controlType, out string testHostAutomationId, params string[] resources) { var controlAssembly = controlType.Assembly; var controlTypeFullName = controlType.FullName; var controlAssemblyLocation = controlAssembly.Location; testHostAutomationId = string.Empty; if (!testHost.TryLoadAssembly(controlAssemblyLocation)) { testHostAutomationId = $"Error! Can't load control assembly from: {controlAssemblyLocation}"; return(false); } foreach (var resource in resources ?? Enumerable.Empty <string>()) { if (!testHost.TryLoadResources(resource)) { testHostAutomationId = $"Error! Can't load control resource: {resource}"; } } //Apply style forwarders testHost.RunMethod(typeof(StyleHelper), nameof(StyleHelper.CreateStyleForwardersForDefaultStyles)); testHostAutomationId = testHost.PutControl(controlTypeFullName); if (string.IsNullOrWhiteSpace(testHostAutomationId) || testHostAutomationId.StartsWith("Error")) { testHostAutomationId = $"Error! Can't put control inside test host control: {controlTypeFullName}"; return(false); } return(true); }