diff --git a/wpf-material-dialogs.test/AssemblyInfo.cs b/wpf-material-dialogs.test/AssemblyInfo.cs new file mode 100644 index 0000000..b8f2c7d --- /dev/null +++ b/wpf-material-dialogs.test/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Runtime.InteropServices; +using Xunit; + +// In SDK-style projects such as this one, several assembly attributes that were historically +// defined in this file are now automatically added during build and populated with +// values defined in project properties. For details of which attributes are included +// and how to customise this process see: https://aka.ms/assembly-info-properties + + +// Setting ComVisible to false makes the types in this assembly not visible to COM +// components. If you need to access a type in this assembly from COM, set the ComVisible +// attribute to true on that type. + +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM. + +[assembly: Guid("f0c835b6-35db-4ced-971f-f9e97b0d13b7")] +[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly, DisableTestParallelization = true)] \ No newline at end of file diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/entries b/wpf-material-dialogs.test/AvalonUnitTesting/.svn/entries deleted file mode 100644 index 79afee4..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/entries +++ /dev/null @@ -1,103 +0,0 @@ -8 - -dir -7 -file:///C:/svn-repos/source%20code/AvalonControlsLibrary/AvalonUnitTesting -file:///C:/svn-repos/source%20code - - - -2007-10-24T21:46:58.915000Z -6 -Marlon - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -bbe8d2cd-ae28-aa41-b0c7-d45f4a599f82 - -AvalonDataBindingTraceTester.cs -file - - - - -2007-10-24T21:15:46.750000Z -4263149c5c9aff8148f02672d0d53c86 -2007-10-24T21:16:38.370000Z -4 -Marlon - -AvalonActivatorHelper.cs -file - - - - -2007-10-24T18:00:02.846000Z -65a8351ef48f760ae22014e60b10a818 -2007-10-23T06:55:10.824200Z -3 -Marlon - -STAOperationRunner.cs -file - - - - -2007-10-24T21:14:18.267000Z -8262c371e550e98e5774452ce7f64bb4 -2007-10-24T21:16:38.370000Z -4 -Marlon - -AvalonTraceListener.cs -file - - - - -2007-10-24T18:00:02.885000Z -b0e1f3d4f177084c4f51a6c994e82c68 -2007-10-23T06:55:10.824200Z -3 -Marlon - -Properties -dir - -AvalonUnitTesting.csproj -file - - - - -2007-10-24T18:00:02.894000Z -b02396287995f0ff340e9fb403b7fdee -2007-10-23T06:55:10.824200Z -3 -Marlon - -AvalonTestRunner.cs -file - - - - -2007-10-24T21:46:30.755000Z -a00a1838fdcc9856005548bae3647347 -2007-10-24T21:46:58.915000Z -6 -Marlon - diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/format b/wpf-material-dialogs.test/AvalonUnitTesting/.svn/format deleted file mode 100644 index 45a4fb7..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/format +++ /dev/null @@ -1 +0,0 @@ -8 diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonActivatorHelper.cs.svn-base b/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonActivatorHelper.cs.svn-base deleted file mode 100644 index f98c39b..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonActivatorHelper.cs.svn-base +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Windows; - -namespace AvalonUnitTesting -{ - /// - /// Helper class that creates the instances of the objects - /// - internal static class AvalonActivatorHelper - { - /// - /// wrapps a control in a window so that it can be unit tested - /// - private class ControlWrapper : Window - { - /// - /// constructor to wrap a control inside a window - /// - /// The control to wrap in the window - public ControlWrapper(object controlToWrap) - { - Content = controlToWrap; - } - } - - /// - /// Creates the instance of the Type that is passed - /// - /// The type to cretae instance of - /// The constructor parameters if any - /// An object of the specified type. if the object is not a window it will be wrapped in a window - /// The type parameter is passed as null - internal static Window CreateInstance(Type type, params object[] parameters) - { - if (type == null) - throw new ArgumentNullException("type", "Type was passed as null"); - - object instance; - if (parameters != null && parameters.Length != 0) - instance = Activator.CreateInstance(type, parameters); - else - instance = Activator.CreateInstance(type); - - return VerifyObjectType(instance); - } - - /// - /// Checks if the object is of type window - /// If not it creates a wrapper window - /// - /// The instance of the object to check - /// Returns a window instance - public static Window VerifyObjectType(object instance) - { - Window returnValue = instance as Window; - //return the value if it is alread a window - if (returnValue != null) - return returnValue; - - //wrap the control in a window and return it - ControlWrapper wrapper = new ControlWrapper(instance); - return wrapper; - } - } -} diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonDataBindingTraceTester.cs.svn-base b/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonDataBindingTraceTester.cs.svn-base deleted file mode 100644 index ddfb626..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonDataBindingTraceTester.cs.svn-base +++ /dev/null @@ -1,52 +0,0 @@ -using System.Diagnostics; -using System.Windows; - -namespace AvalonUnitTesting -{ - /// - /// Hooks to the Trace of the WPF databinding to check for dat binding errors - /// - public static class AvalonDataBindingTraceTester - { - private static AvalonTraceListener dataBindingListener; - - /// - /// Gets a databinding trace listener - /// - internal static AvalonTraceListener DataBindingListener - { - get - { - if (dataBindingListener == null) - dataBindingListener = new AvalonTraceListener(); - return dataBindingListener; - } - } - - /// - /// hooks the window to the wpf trace - /// - /// The window to test - public static void TestDataBindingsForObject(Window windowToTest) - { - EnforceDataBindingTraceListener(windowToTest); - windowToTest.ShowInTaskbar = false; - windowToTest.Show(); - windowToTest.Hide(); - } - - //check if there is already a databinding trace listener, if not creates it - private static void EnforceDataBindingTraceListener(Window currentWindow) - { - PresentationTraceSources.Refresh(); - PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Warning; - - //add the databinding listener - if (!PresentationTraceSources.DataBindingSource.Listeners.Contains(DataBindingListener)) - PresentationTraceSources.DataBindingSource.Listeners.Add(DataBindingListener); - - //set the current window being tested - DataBindingListener.CurrentWindowBeingTested = currentWindow; - } - } -} diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonTestRunner.cs.svn-base b/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonTestRunner.cs.svn-base deleted file mode 100644 index 97440c4..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonTestRunner.cs.svn-base +++ /dev/null @@ -1,35 +0,0 @@ -using System.Threading; -using System.Windows; - -namespace AvalonUnitTesting -{ - /// - /// base class for unit test of wpf - /// - public class AvalonTestRunner - { - /// - /// Runs a set of tests for data binding - /// - /// - public static void RunDataBindingTests(object objectToTest) - { - //get the window instance. This will create a wrapper window if a window is not passes as parameter - Window windowToTest = AvalonActivatorHelper.VerifyObjectType(objectToTest); - if (windowToTest != null) - AvalonDataBindingTraceTester.TestDataBindingsForObject(windowToTest); - - } - - private static readonly STAOperationRunner runner = new STAOperationRunner(); - - /// - /// Runs a delegate in a STA thread - /// - /// The operation to run - public static void RunInSTA(ThreadStart userDelegate) - { - runner.RunInSTA(userDelegate); - } - } -} diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonTraceListener.cs.svn-base b/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonTraceListener.cs.svn-base deleted file mode 100644 index 8f80904..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonTraceListener.cs.svn-base +++ /dev/null @@ -1,42 +0,0 @@ -using System.Diagnostics; -using System.Windows; -using NUnit.Framework; - -namespace AvalonUnitTesting -{ - /// - /// Trace listener that asserts when a data binding error is encontered in a specific page - /// - public class AvalonTraceListener : TraceListener - { - private Window currentWindowBeingTested; - - /// - /// The current window that is being tests - /// - internal Window CurrentWindowBeingTested - { - get { return currentWindowBeingTested; } - set { currentWindowBeingTested = value; } - } - /// - /// Fails the unit test if this method is called - /// - /// The message to push in the fail - public override void Write(string message) - { } - - /// - /// Fails the unit test if this method is called - /// - /// The message to push in the fail - public override void WriteLine(string message) - { - //close the window before failing the tests - if (currentWindowBeingTested != null) - currentWindowBeingTested.Close(); - - Assert.Fail(message); - } - } -} diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonUnitTesting.csproj.svn-base b/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonUnitTesting.csproj.svn-base deleted file mode 100644 index 1550165..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/AvalonUnitTesting.csproj.svn-base +++ /dev/null @@ -1,85 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {0071B386-1F4D-45D4-9D1B-4B11385B5E1C} - library - Properties - AvalonUnitTesting - AvalonUnitTesting - v3.0 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - - - - - - - - - - - - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - \ No newline at end of file diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/STAOperationRunner.cs.svn-base b/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/STAOperationRunner.cs.svn-base deleted file mode 100644 index 62d9120..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/.svn/text-base/STAOperationRunner.cs.svn-base +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Reflection; -using System.Security.Permissions; -using System.Threading; - -namespace AvalonUnitTesting -{ - /// - /// Runs a specific job in a specific thread apartment - /// - public class STAOperationRunner - { - private Exception lastException; - - /// - /// Runs a specific method in Single Threaded apartment - /// - /// A delegate to run - public void RunInSTA(ThreadStart userDelegate) - { - if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA) - Run(userDelegate, ApartmentState.STA); - else - userDelegate.Invoke(); - } - - private void Run(ThreadStart userDelegate, ApartmentState apartmentState) - { - lastException = null; - - Thread thread = new Thread( - delegate() - { - try - { - userDelegate.Invoke(); - } - catch (Exception e) - { - lastException = e; - } - }); - thread.SetApartmentState(apartmentState); - - thread.Start(); - thread.Join(); - - if (ExceptionWasThrown()) - ThrowExceptionPreservingStack(lastException); - } - - private bool ExceptionWasThrown() - { - return lastException != null; - } - - [ReflectionPermission(SecurityAction.Demand)] - private static void ThrowExceptionPreservingStack(Exception exception) - { - FieldInfo remoteStackTraceString = typeof(Exception).GetField( - "_remoteStackTraceString", - BindingFlags.Instance | BindingFlags.NonPublic); - remoteStackTraceString.SetValue(exception, exception.StackTrace + Environment.NewLine); - throw exception; - } - } -} diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/AvalonActivatorHelper.cs b/wpf-material-dialogs.test/AvalonUnitTesting/AvalonActivatorHelper.cs deleted file mode 100644 index 93733ca..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/AvalonActivatorHelper.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Windows; - -namespace wpf_material_dialogs.test.AvalonUnitTesting -{ - /// - /// Helper class that creates the instances of the objects - /// - internal static class AvalonActivatorHelper - { - /// - /// wraps a control in a window so that it can be unit tested - /// - private class ControlWrapper : Window - { - /// - /// constructor to wrap a control inside a window - /// - /// The control to wrap in the window - public ControlWrapper(object controlToWrap) - { - Content = controlToWrap; - } - } - - /// - /// Creates the instance of the Type that is passed - /// - /// The type to cretae instance of - /// The constructor parameters if any - /// An object of the specified type. if the object is not a window it will be wrapped in a window - /// The type parameter is passed as null - internal static Window CreateInstance(Type type, params object[] parameters) - { - if (type == null) - throw new ArgumentNullException("type", "Type was passed as null"); - - object instance; - if (parameters != null && parameters.Length != 0) - instance = Activator.CreateInstance(type, parameters); - else - instance = Activator.CreateInstance(type); - - return VerifyObjectType(instance); - } - - /// - /// Checks if the object is of type window - /// If not it creates a wrapper window - /// - /// The instance of the object to check - /// Returns a window instance - public static Window VerifyObjectType(object instance) - { - var returnValue = instance as Window; - - //return the value if it is alread a window - if (returnValue != null) - return returnValue; - - //wrap the control in a window and return it - var wrapper = new ControlWrapper(instance); - - return wrapper; - } - } -} diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/AvalonDataBindingTraceTester.cs b/wpf-material-dialogs.test/AvalonUnitTesting/AvalonDataBindingTraceTester.cs deleted file mode 100644 index 0db065b..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/AvalonDataBindingTraceTester.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Diagnostics; -using System.Windows; - -namespace wpf_material_dialogs.test.AvalonUnitTesting -{ - /// - /// Hooks to the Trace of the WPF databinding to check for dat binding errors - /// - public static class AvalonDataBindingTraceTester - { - private static AvalonTraceListener dataBindingListener; - - /// - /// Gets a databinding trace listener - /// - internal static AvalonTraceListener DataBindingListener - { - get - { - if (dataBindingListener == null) - dataBindingListener = new AvalonTraceListener(); - return dataBindingListener; - } - } - - /// - /// hooks the window to the wpf trace - /// - /// The window to test - public static void TestDataBindingsForObject(Window windowToTest) - { - EnforceDataBindingTraceListener(windowToTest); - windowToTest.ShowInTaskbar = false; - windowToTest.Show(); - windowToTest.Hide(); - } - - //check if there is already a databinding trace listener, if not creates it - private static void EnforceDataBindingTraceListener(Window currentWindow) - { - PresentationTraceSources.Refresh(); - PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Warning; - - //add the databinding listener - if (!PresentationTraceSources.DataBindingSource.Listeners.Contains(DataBindingListener)) - PresentationTraceSources.DataBindingSource.Listeners.Add(DataBindingListener); - - //set the current window being tested - DataBindingListener.CurrentWindowBeingTested = currentWindow; - } - } -} diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/AvalonTestRunner.cs b/wpf-material-dialogs.test/AvalonUnitTesting/AvalonTestRunner.cs deleted file mode 100644 index 663b09e..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/AvalonTestRunner.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Threading; - -namespace wpf_material_dialogs.test.AvalonUnitTesting -{ - /// - /// base class for unit test of wpf - /// - public class AvalonTestRunner - { - /// - /// Runs a set of tests for data binding - /// - /// - public static void RunDataBindingTests(object objectToTest) - { - //get the window instance. This will create a wrapper window if a window is not passes as parameter - var windowToTest = AvalonActivatorHelper.VerifyObjectType(objectToTest); - if (windowToTest != null) - AvalonDataBindingTraceTester.TestDataBindingsForObject(windowToTest); - } - - private static readonly STAOperationRunner runner = new(); - - /// - /// Runs a delegate in a STA thread - /// - /// The operation to run - public static void RunInSTA(ThreadStart userDelegate) - { - runner.RunInSTA(userDelegate); - } - } -} diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/AvalonTraceListener.cs b/wpf-material-dialogs.test/AvalonUnitTesting/AvalonTraceListener.cs deleted file mode 100644 index 0a909e7..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/AvalonTraceListener.cs +++ /dev/null @@ -1,42 +0,0 @@ -using NUnit.Framework; -using System.Diagnostics; -using System.Windows; - -namespace wpf_material_dialogs.test.AvalonUnitTesting -{ - /// - /// Trace listener that asserts when a data binding error is encontered in a specific page - /// - public class AvalonTraceListener : TraceListener - { - private Window currentWindowBeingTested; - - /// - /// The current window that is being tests - /// - internal Window CurrentWindowBeingTested - { - get { return currentWindowBeingTested; } - set { currentWindowBeingTested = value; } - } - /// - /// Fails the unit test if this method is called - /// - /// The message to push in the fail - public override void Write(string message) - { } - - /// - /// Fails the unit test if this method is called - /// - /// The message to push in the fail - public override void WriteLine(string message) - { - //close the window before failing the tests - if (currentWindowBeingTested != null) - currentWindowBeingTested.Close(); - - Assert.Fail(message); - } - } -} diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/AvalonUnitTesting.csproj b/wpf-material-dialogs.test/AvalonUnitTesting/AvalonUnitTesting.csproj deleted file mode 100644 index 1550165..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/AvalonUnitTesting.csproj +++ /dev/null @@ -1,85 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {0071B386-1F4D-45D4-9D1B-4B11385B5E1C} - library - Properties - AvalonUnitTesting - AvalonUnitTesting - v3.0 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - - - - - - - - - - - - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - \ No newline at end of file diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/entries b/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/entries deleted file mode 100644 index e205272..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/entries +++ /dev/null @@ -1,76 +0,0 @@ -8 - -dir -7 -file:///C:/svn-repos/source%20code/AvalonControlsLibrary/AvalonUnitTesting/Properties -file:///C:/svn-repos/source%20code - - - -2007-10-21T12:42:48.069000Z -2 -Marlon - - -svn:special svn:externals svn:needs-lock - -AssemblyInfo.cs -file - - - - -2007-10-11T21:33:50.587000Z -07ea9c7721e0f83a592720298df780ee -2007-10-21T12:42:48.069000Z -2 -Marlon - -Settings.settings -file - - - - -2007-10-11T21:33:50.517000Z -af5b91869ef1266c0a33c882a311cd20 -2007-10-21T12:42:48.069000Z -2 -Marlon - -Settings.Designer.cs -file - - - - -2007-10-11T21:33:50.728000Z -30bd36bdcb3420c1ae6a81f47aa7ab2b -2007-10-21T12:42:48.069000Z -2 -Marlon - -Resources.resx -file - - - - -2007-10-11T21:33:50.605000Z -0cd8c971317d19bbed44757809bcb92b -2007-10-21T12:42:48.069000Z -2 -Marlon - -Resources.Designer.cs -file - - - - -2007-10-11T21:33:50.692000Z -64a5728fbcb3ceec68e9032da0dfc3fa -2007-10-21T12:42:48.069000Z -2 -Marlon - diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/format b/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/format deleted file mode 100644 index 45a4fb7..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/format +++ /dev/null @@ -1 +0,0 @@ -8 diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/AssemblyInfo.cs.svn-base b/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/AssemblyInfo.cs.svn-base deleted file mode 100644 index ef8036c..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/AssemblyInfo.cs.svn-base +++ /dev/null @@ -1,55 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("AvalonUnitTesting")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("AvalonUnitTesting")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/Resources.Designer.cs.svn-base b/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/Resources.Designer.cs.svn-base deleted file mode 100644 index 5fadfcc..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/Resources.Designer.cs.svn-base +++ /dev/null @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1378 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace AvalonUnitTesting.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AvalonUnitTesting.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/Resources.resx.svn-base b/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/Resources.resx.svn-base deleted file mode 100644 index af7dbeb..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/Resources.resx.svn-base +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/Settings.Designer.cs.svn-base b/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/Settings.Designer.cs.svn-base deleted file mode 100644 index 0a89a5d..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/Settings.Designer.cs.svn-base +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1378 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace AvalonUnitTesting.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/Settings.settings.svn-base b/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/Settings.settings.svn-base deleted file mode 100644 index 033d7a5..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/.svn/text-base/Settings.settings.svn-base +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/Resources.Designer.cs b/wpf-material-dialogs.test/AvalonUnitTesting/Properties/Resources.Designer.cs deleted file mode 100644 index 5fadfcc..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/Resources.Designer.cs +++ /dev/null @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1378 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace AvalonUnitTesting.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AvalonUnitTesting.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/Resources.resx b/wpf-material-dialogs.test/AvalonUnitTesting/Properties/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/Settings.Designer.cs b/wpf-material-dialogs.test/AvalonUnitTesting/Properties/Settings.Designer.cs deleted file mode 100644 index 0a89a5d..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1378 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace AvalonUnitTesting.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/Settings.settings b/wpf-material-dialogs.test/AvalonUnitTesting/Properties/Settings.settings deleted file mode 100644 index 033d7a5..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/wpf-material-dialogs.test/AvalonUnitTesting/STAOperationRunner.cs b/wpf-material-dialogs.test/AvalonUnitTesting/STAOperationRunner.cs deleted file mode 100644 index 22a2ffd..0000000 --- a/wpf-material-dialogs.test/AvalonUnitTesting/STAOperationRunner.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Reflection; -using System.Threading; - -namespace wpf_material_dialogs.test.AvalonUnitTesting -{ - /// - /// Runs a specific job in a specific thread apartment - /// - public class STAOperationRunner - { - private Exception lastException; - - /// - /// Runs a specific method in Single Threaded apartment - /// - /// A delegate to run - public void RunInSTA(ThreadStart userDelegate) - { - if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA) - Run(userDelegate, ApartmentState.STA); - else - userDelegate.Invoke(); - } - - private void Run(ThreadStart userDelegate, ApartmentState apartmentState) - { - lastException = null; - - var thread = new Thread(delegate() - { - try - { - userDelegate.Invoke(); - } - catch (Exception e) - { - lastException = e; - } - }); - thread.SetApartmentState(apartmentState); - - thread.Start(); - thread.Join(); - - if (ExceptionWasThrown()) - ThrowExceptionPreservingStack(lastException); - } - - private bool ExceptionWasThrown() - { - return lastException != null; - } - - private static void ThrowExceptionPreservingStack(Exception exception) - { - var remoteStackTraceString = typeof(Exception).GetField("_remoteStackTraceString", - BindingFlags.Instance | BindingFlags.NonPublic); - remoteStackTraceString?.SetValue(exception, exception.StackTrace + Environment.NewLine); - - throw exception; - } - } -} diff --git a/wpf-material-dialogs.test/DialogTests.cs b/wpf-material-dialogs.test/DialogTests.cs index cc61f0b..9efcb58 100644 --- a/wpf-material-dialogs.test/DialogTests.cs +++ b/wpf-material-dialogs.test/DialogTests.cs @@ -1,6 +1,5 @@ using FluentAssertions; using MaterialDesignThemes.Wpf; -using NUnit.Framework; using System; using System.Reflection; using System.Threading; @@ -11,16 +10,19 @@ using wpf_material_dialogs.Dialogs; using wpf_material_dialogs.Enums; using wpf_material_dialogs.Interfaces; +using Xunit; namespace wpf_material_dialogs.test { - [NUnit.Framework.Ignore("base class")] - internal class DialogTestBase : IDisposable where TDialog : IDialog, new() + [Collection("tests")] + [CollectionDefinition("test", DisableParallelization = true)] + public abstract class DialogTestBase : IDisposable where TDialog : IDialog, new() { private DialogHost dialogHost; private IDialog testDialog; - [SetUp] + protected DialogTestBase() => SetupTests(); + public void SetupTests() { var mi = typeof(DialogHost).GetMethod("GetInstance", BindingFlags.NonPublic | BindingFlags.Static); @@ -34,7 +36,7 @@ public void SetupTests() } dialogHost ??= new DialogHost(); - dialogHost?.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); + dialogHost.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); //_dialogHost.Identifier = hostId; testDialog = new TDialog { @@ -49,7 +51,7 @@ public void SetupTests() public void Dispose() => dialogHost?.RaiseEvent(new RoutedEventArgs(FrameworkElement.UnloadedEvent)); - [Test] + [StaFact] public void CanOpenAndCloseDialogWithShowDialogIsOpen() { dialogHost.IsOpen = false; @@ -63,7 +65,7 @@ public void CanOpenAndCloseDialogWithShowDialogIsOpen() session?.IsEnded.Should().BeTrue(); } - [Test] + [StaFact] public async Task CanOpenAndCloseDialogWithShowMethodDialogResult() { var id = Guid.NewGuid(); @@ -75,7 +77,7 @@ public async Task CanOpenAndCloseDialogWithShowMethodDialogResult() dialogHost.IsOpen.Should().BeFalse(); } - [Test] + [StaFact] public async Task CanOpenAndCloseDialogWithShowMethodAnyObject() { var result = await OpenTestDialogObject(testDialog, (sender, args) => args.Session.Close(42)); @@ -84,7 +86,7 @@ public async Task CanOpenAndCloseDialogWithShowMethodAnyObject() dialogHost.IsOpen.Should().BeFalse(); } - [Test] + [StaFact] public async Task CanOpenDialogWithShowMethodAndCloseWithIsOpen() { var result = await OpenTestDialogObject(testDialog, (sender, args) => dialogHost.IsOpen = false); @@ -93,7 +95,7 @@ public async Task CanOpenDialogWithShowMethodAndCloseWithIsOpen() dialogHost.IsOpen.Should().BeFalse(); } - [Test] + [StaFact] public async Task CanCloseDialogWithRoutedEvent() { var closeParameter = Guid.NewGuid(); @@ -103,15 +105,15 @@ public async Task CanCloseDialogWithRoutedEvent() Assert.False(session?.IsEnded ?? false); DialogHost.CloseDialogCommand.Execute(closeParameter, dialogHost); - Thread.Sleep(200); + Thread.Yield(); Assert.False(dialogHost.IsOpen); Assert.Null(dialogHost.CurrentSession); Assert.True(session?.IsEnded ?? false); Task.WaitAll(showTask); - Assert.AreEqual(closeParameter, await showTask); + Assert.Equivalent(closeParameter, await showTask); } - [Test] + [StaFact] public async Task DialogHostExposesSessionAsProperty() => await OpenTestDialogObject(testDialog, (sender, args) => @@ -120,7 +122,7 @@ await OpenTestDialogObject(testDialog, args.Session.Close(); }); - [Test] + [StaFact] public async Task WhenNoIdentifierIsSpecifiedItUsesSingleDialogHost() { var isOpen = false; @@ -133,7 +135,7 @@ await OpenTestDialogObject(testDialog, isOpen.Should().BeTrue(); } - [Test] + [StaFact] public async Task WhenContentIsUpdatedClosingEventHandlerIsInvoked() { var closeInvokeCount = 0; @@ -153,15 +155,15 @@ void ClosingHandler(object s, DialogClosingEventArgs e) dialogHost.CurrentSession?.Close("SecondResult"); var result = await dialogTask; - Assert.AreEqual("SecondResult", result); - Assert.AreEqual(2, closeInvokeCount); + Assert.Equivalent("SecondResult", result); + Assert.Equivalent(2, closeInvokeCount); } - [Test] + [StaFact] public void WhenOpenDialogsAreOpenIsExist() { var isExist = false; - OpenTestDialogObject(testDialog, (sender, arg) => isExist = DialogHost.IsDialogOpen(dialogHost.Identifier)); + _ = OpenTestDialogObject(testDialog, (sender, arg) => isExist = DialogHost.IsDialogOpen(dialogHost.Identifier)); Assert.True(isExist); DialogHost.Close(dialogHost.Identifier); Assert.False(DialogHost.IsDialogOpen(dialogHost.Identifier)); @@ -183,23 +185,19 @@ private async Task OpenTestDialog(IDialog dialog, DialogOpenedEven } } - [Apartment(ApartmentState.STA)] - internal class AlertDialogTests : DialogTestBase + public class AlertDialogTests : DialogTestBase { } - [Apartment(ApartmentState.STA)] - internal class ErrorDialogTests : DialogTestBase + public class ErrorDialogTests : DialogTestBase { } - [Apartment(ApartmentState.STA)] - internal class InfoDialogTests : DialogTestBase + public class InfoDialogTests : DialogTestBase { } - [Apartment(ApartmentState.STA)] - internal class WarningDialogTests : DialogTestBase + public class WarningDialogTests : DialogTestBase { } } diff --git a/wpf-material-dialogs.test/wpf-material-dialogs.test.csproj b/wpf-material-dialogs.test/wpf-material-dialogs.test.csproj index fce2694..0c0e9b6 100644 --- a/wpf-material-dialogs.test/wpf-material-dialogs.test.csproj +++ b/wpf-material-dialogs.test/wpf-material-dialogs.test.csproj @@ -1,28 +1,41 @@  - - net6.0-windows;net7.0-windows;net8.0-windows - wpf_material_dialogs.test - AnyCPU - true - latest - false - true - + + net6.0-windows;net7.0-windows;net8.0-windows + wpf_material_dialogs.test + AnyCPU + true + latest + false + true + - - DEBUG;TRACE - + + DEBUG;TRACE + - - - - - - - + + + + + + + all + runtime; build; native; contentfiles; buildtransitive + analyzers + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - - - + + + + + + +