-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WAF: MockSettingsService move to UnitTesting.Core
- Loading branch information
Showing
5 changed files
with
60 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/System.Waf/System.Waf/System.Waf.UnitTesting.Core/Mocks/MockSettingsService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Collections.Concurrent; | ||
using System.Waf.Applications.Services; | ||
|
||
namespace System.Waf.UnitTesting.Mocks | ||
{ | ||
/// <summary>Mock for the ISettingsService interface.</summary> | ||
public class MockSettingsService : ISettingsService | ||
{ | ||
private readonly ConcurrentDictionary<Type, Lazy<object>> services = new(); | ||
|
||
/// <summary>Gets or sets a delegate that is called when Get is called.</summary> | ||
public Func<Type, object>? GetStub { get; set; } | ||
|
||
/// <summary>Gets or sets a delegate that is called when Save is called.</summary> | ||
public Action? SaveStub { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public string FileName { get; set; } = default!; | ||
|
||
/// <inheritdoc /> | ||
public event EventHandler<SettingsErrorEventArgs>? ErrorOccurred; | ||
|
||
/// <inheritdoc /> | ||
public T Get<T>() where T : class, new() => (T)(GetStub?.Invoke(typeof(T)) ?? services.GetOrAdd(typeof(T), new Lazy<object>(() => new T())).Value); | ||
|
||
/// <inheritdoc /> | ||
public void Save() => SaveStub?.Invoke(); | ||
|
||
/// <summary>Raise the ErrorOccurred event.</summary> | ||
/// <param name="e">The error event args.</param> | ||
public void RaiseErrorOccurred(SettingsErrorEventArgs e) => ErrorOccurred?.Invoke(this, e); | ||
} | ||
} |
39 changes: 15 additions & 24 deletions
39
src/System.Waf/System.Waf/System.Waf.UnitTesting.Wpf/GlobalSuppressions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,17 @@ | ||
// This file is used by Code Analysis to maintain SuppressMessage | ||
// attributes that are applied to this project. | ||
// Project-level suppressions either have no target or are given | ||
// a specific target and scoped to a namespace, type, member, etc. | ||
// | ||
// To add a suppression to this file, right-click the message in the | ||
// Error List, point to "Suppress Message(s)", and click | ||
// "In Project Suppression File". | ||
// You do not need to add suppressions to this file manually. | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "CanExecuteChanged", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.CanExecuteChangedEvent(System.Windows.Input.ICommand,System.Action)")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "PropertyChanged", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.PropertyChangedEvent``1(``0,System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.Action)")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.ExpectedException``1(System.Action)~``0")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.ExpectedException``1(System.Action)~``0")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.PropertyChangedEvent``1(``0,System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.Action)")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.ThrowExpressionArgumentException")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Scope = "member", Target = "~P:System.Waf.UnitTesting.Mocks.MockMessageService.ShowQuestionAction")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Scope = "member", Target = "~P:System.Waf.UnitTesting.Mocks.MockDialogView`1.ShowDialogAction")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "~M:System.Waf.UnitTesting.UnitTestSynchronizationContext.Create~System.Waf.UnitTesting.UnitTestSynchronizationContext")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "~M:System.Waf.UnitTesting.UnitTestSynchronizationContext.CreateCopy~System.Threading.SynchronizationContext")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "~M:System.Waf.UnitTesting.UnitTestSynchronizationContext.Wait(System.TimeSpan)")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "CanExecuteChanged", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.CanExecuteChangedEvent(System.Windows.Input.ICommand,System.Action,System.Int32,System.Waf.UnitTesting.ExpectedChangedCountMode)")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.PropertyChangedEvent``1(``0,System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.Action,System.Int32,System.Waf.UnitTesting.ExpectedChangedCountMode)")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "PropertyChanged", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.PropertyChangedEvent``1(``0,System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.Action,System.Int32,System.Waf.UnitTesting.ExpectedChangedCountMode)")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate", Scope = "member", Target = "~M:System.Waf.UnitTesting.Mocks.MockSettingsService.RaiseErrorOccurred(System.Waf.Applications.Services.SettingsErrorEventArgs)")] | ||
[assembly: SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "CanExecuteChanged", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.CanExecuteChangedEvent(System.Windows.Input.ICommand,System.Action)")] | ||
[assembly: SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "PropertyChanged", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.PropertyChangedEvent``1(``0,System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.Action)")] | ||
[assembly: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.ExpectedException``1(System.Action)~``0")] | ||
[assembly: SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.ExpectedException``1(System.Action)~``0")] | ||
[assembly: SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.PropertyChangedEvent``1(``0,System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.Action)")] | ||
[assembly: SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Scope = "member", Target = "~P:System.Waf.UnitTesting.Mocks.MockMessageService.ShowQuestionAction")] | ||
[assembly: SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Scope = "member", Target = "~P:System.Waf.UnitTesting.Mocks.MockDialogView`1.ShowDialogAction")] | ||
[assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "~M:System.Waf.UnitTesting.UnitTestSynchronizationContext.Create~System.Waf.UnitTesting.UnitTestSynchronizationContext")] | ||
[assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "~M:System.Waf.UnitTesting.UnitTestSynchronizationContext.CreateCopy~System.Threading.SynchronizationContext")] | ||
[assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "~M:System.Waf.UnitTesting.UnitTestSynchronizationContext.Wait(System.TimeSpan)")] | ||
[assembly: SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "CanExecuteChanged", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.CanExecuteChangedEvent(System.Windows.Input.ICommand,System.Action,System.Int32,System.Waf.UnitTesting.ExpectedChangedCountMode)")] | ||
[assembly: SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.PropertyChangedEvent``1(``0,System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.Action,System.Int32,System.Waf.UnitTesting.ExpectedChangedCountMode)")] | ||
[assembly: SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "PropertyChanged", Scope = "member", Target = "~M:System.Waf.UnitTesting.AssertHelper.PropertyChangedEvent``1(``0,System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.Action,System.Int32,System.Waf.UnitTesting.ExpectedChangedCountMode)")] | ||
[assembly: SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate", Scope = "member", Target = "~M:System.Waf.UnitTesting.Mocks.MockSettingsService.RaiseErrorOccurred(System.Waf.Applications.Services.SettingsErrorEventArgs)")] | ||
|
11 changes: 11 additions & 0 deletions
11
src/System.Waf/System.Waf/System.Waf.UnitTesting.Wpf/Mocks/MefMockSettingsService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.ComponentModel.Composition; | ||
using System.Waf.Applications.Services; | ||
|
||
namespace System.Waf.UnitTesting.Mocks | ||
{ | ||
/// <summary>Mock for the ISettingsService interface.</summary> | ||
[Export(typeof(ISettingsService)), Export(typeof(MockSettingsService)), Export] | ||
public class MefMockSettingsService : MockSettingsService | ||
{ | ||
} | ||
} |
54 changes: 0 additions & 54 deletions
54
src/System.Waf/System.Waf/System.Waf.UnitTesting.Wpf/Mocks/MockSettingsService.cs
This file was deleted.
Oops, something went wrong.