From 86510aa9657ca9dcddc3614c439ad73c5cc59f59 Mon Sep 17 00:00:00 2001 From: Dan Siegel Date: Fri, 21 Aug 2020 15:59:24 -0700 Subject: [PATCH 1/3] remove ILoggerFacade --- src/Forms/Prism.Forms/PrismApplicationBase.cs | 2 - src/Prism.Core/Logging/Category.cs | 31 ------- src/Prism.Core/Logging/DebugLogger.cs | 29 ------ src/Prism.Core/Logging/EmptyLogger.cs | 24 ----- src/Prism.Core/Logging/ILoggerFacade.cs | 19 ---- src/Prism.Core/Logging/Priority.cs | 31 ------- src/Uno/Prism.Uno/PrismApplicationBase.cs | 1 - .../Legacy/DryIocBootstrapper.cs | 44 ++++----- .../Legacy/UnityBootstrapper.cs | 53 +++++------ src/Wpf/Prism.Wpf/Bootstrapper.cs | 23 ++--- src/Wpf/Prism.Wpf/Logging/TextLogger.cs | 64 ------------- src/Wpf/Prism.Wpf/Logging/TraceLogger.cs | 30 ------- .../Prism.Wpf/Modularity/ModuleInitializer.cs | 8 +- src/Wpf/Prism.Wpf/Modularity/ModuleManager.cs | 14 +-- .../PrismInitializationExtensions.cs | 2 - tests/Forms/MockApp/MockPrismApp.cs | 1 - .../Fixtures/Ioc/ContainerProviderFixture.cs | 1 - .../Fixtures/PrismApplicationFixture.cs | 11 --- .../Mocks/Logging/XUnitLogger.cs | 23 ----- .../Navigation/CustomNavigationServiceMock.cs | 2 - .../Mocks/PrismApplicationMock.cs | 11 +-- .../PrismApplicationMockPlatformAware.cs | 2 - .../Prism.DI.Forms.Tests.projitems | 1 - .../Mocks/PageNavigationServiceMock.cs | 1 - .../PageNavigationServiceFixture.cs | 3 - .../Logging/DebugLoggerFixture.cs | 15 ---- .../Logging/EmptyLoggerFixture.cs | 16 ---- .../Bootstrapper/BootstrapperFixture.cs | 11 --- .../BootstrapperNullLoggerFixture.cs | 18 ---- .../BootstrapperRunMethodFixture.cs | 70 ++++++--------- .../Mocks/NullLoggerBootstrapper.cs | 24 ----- .../Mocks/NullModuleManagerBootstrapper.cs | 4 +- .../Prism.Container.Wpf.Shared.projitems | 2 - .../Fixtures/BootstrapperRunMethodFixture.cs | 14 --- .../Mocks/MockBootstrapper.cs | 18 ++-- .../Mocks/MockedContainerBootstrapper.cs | 2 - .../Mocks/MockLoggerAdapter.cs | 17 ---- .../Mocks/MockModuleLoader.cs | 2 - .../Mocks/MockRegionManager.cs | 2 - .../Fixtures/BootstrapperRunMethodFixture.cs | 14 --- .../Mocks/MockBootstrapper.cs | 22 ++--- .../Mocks/MockedContainerBootstrapper.cs | 2 - .../Prism.Wpf.Tests/BootstrapperFixture.cs | 33 ------- .../Logging/TextLoggerFixture.cs | 52 ----------- .../Logging/TraceLoggerFixture.Desktop.cs | 89 ------------------- tests/Wpf/Prism.Wpf.Tests/Mocks/MockLogger.cs | 17 ---- .../Modularity/ModuleInitializerFixture.cs | 35 +++----- .../Modularity/ModuleManagerFixture.cs | 79 +++++----------- .../PrismApplicationBaseFixture.cs | 9 +- .../PrismBootstapperBaseFixture.cs | 9 +- 50 files changed, 129 insertions(+), 878 deletions(-) delete mode 100644 src/Prism.Core/Logging/Category.cs delete mode 100644 src/Prism.Core/Logging/DebugLogger.cs delete mode 100644 src/Prism.Core/Logging/EmptyLogger.cs delete mode 100644 src/Prism.Core/Logging/ILoggerFacade.cs delete mode 100644 src/Prism.Core/Logging/Priority.cs delete mode 100644 src/Wpf/Prism.Wpf/Logging/TextLogger.cs delete mode 100644 src/Wpf/Prism.Wpf/Logging/TraceLogger.cs delete mode 100644 tests/Forms/Prism.DI.Forms.Tests/Mocks/Logging/XUnitLogger.cs delete mode 100644 tests/Prism.Core.Tests/Logging/DebugLoggerFixture.cs delete mode 100644 tests/Prism.Core.Tests/Logging/EmptyLoggerFixture.cs delete mode 100644 tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Bootstrapper/BootstrapperNullLoggerFixture.cs delete mode 100644 tests/Wpf/Prism.Container.Wpf.Shared/Mocks/NullLoggerBootstrapper.cs delete mode 100644 tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockLoggerAdapter.cs delete mode 100644 tests/Wpf/Prism.Wpf.Tests/Logging/TextLoggerFixture.cs delete mode 100644 tests/Wpf/Prism.Wpf.Tests/Logging/TraceLoggerFixture.Desktop.cs delete mode 100644 tests/Wpf/Prism.Wpf.Tests/Mocks/MockLogger.cs diff --git a/src/Forms/Prism.Forms/PrismApplicationBase.cs b/src/Forms/Prism.Forms/PrismApplicationBase.cs index fb8c229ef8..fa090f575f 100644 --- a/src/Forms/Prism.Forms/PrismApplicationBase.cs +++ b/src/Forms/Prism.Forms/PrismApplicationBase.cs @@ -7,7 +7,6 @@ using Prism.Events; using Prism.Extensions; using Prism.Ioc; -using Prism.Logging; using Prism.Modularity; using Prism.Mvvm; using Prism.Navigation; @@ -182,7 +181,6 @@ protected virtual string GetNavigationSegmentNameFromType(Type pageType) => /// protected virtual void RegisterRequiredTypes(IContainerRegistry containerRegistry) { - containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); diff --git a/src/Prism.Core/Logging/Category.cs b/src/Prism.Core/Logging/Category.cs deleted file mode 100644 index a6079d49bf..0000000000 --- a/src/Prism.Core/Logging/Category.cs +++ /dev/null @@ -1,31 +0,0 @@ - - - -namespace Prism.Logging -{ - /// - /// Defines values for the categories used by . - /// - public enum Category - { - /// - /// Debug category. - /// - Debug, - - /// - /// Exception category. - /// - Exception, - - /// - /// Informational category. - /// - Info, - - /// - /// Warning category. - /// - Warn - } -} \ No newline at end of file diff --git a/src/Prism.Core/Logging/DebugLogger.cs b/src/Prism.Core/Logging/DebugLogger.cs deleted file mode 100644 index 2ef950214f..0000000000 --- a/src/Prism.Core/Logging/DebugLogger.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Define DEBUG symbol to enable Debug.WriteLine to work even when Prism is compiled in Release-mode for Nuget-feed. -#define DEBUG -using System; -using System.Diagnostics; -using System.Globalization; -using Prism.Properties; - -namespace Prism.Logging -{ - /// - /// Implementation of that logs into a message into the Debug.Listeners collection. - /// - public class DebugLogger : ILoggerFacade - { - /// - /// Write a new log entry with the specified category and priority. - /// - /// Message body to log. - /// Category of the entry. - /// The priority of the entry. - public void Log(string message, Category category, Priority priority) - { - string messageToLog = string.Format(CultureInfo.InvariantCulture, Resources.DefaultDebugLoggerPattern, DateTime.Now, - category.ToString().ToUpper(), message, priority); - - Debug.WriteLine(messageToLog); - } - } -} diff --git a/src/Prism.Core/Logging/EmptyLogger.cs b/src/Prism.Core/Logging/EmptyLogger.cs deleted file mode 100644 index 12ac3f8825..0000000000 --- a/src/Prism.Core/Logging/EmptyLogger.cs +++ /dev/null @@ -1,24 +0,0 @@ - - - -namespace Prism.Logging -{ - /// - /// Implementation of that does nothing. This - /// implementation is useful when the application does not need logging - /// but there are infrastructure pieces that assume there is a logger. - /// - public class EmptyLogger : ILoggerFacade - { - /// - /// This method does nothing. - /// - /// Message body to log. - /// Category of the entry. - /// The priority of the entry. - public void Log(string message, Category category, Priority priority) - { - - } - } -} \ No newline at end of file diff --git a/src/Prism.Core/Logging/ILoggerFacade.cs b/src/Prism.Core/Logging/ILoggerFacade.cs deleted file mode 100644 index 2beadfdeba..0000000000 --- a/src/Prism.Core/Logging/ILoggerFacade.cs +++ /dev/null @@ -1,19 +0,0 @@ - - - -namespace Prism.Logging -{ - /// - /// Defines a simple logger façade to be used by the Prism Library. - /// - public interface ILoggerFacade - { - /// - /// Write a new log entry with the specified category and priority. - /// - /// Message body to log. - /// Category of the entry. - /// The priority of the entry. - void Log(string message, Category category, Priority priority); - } -} \ No newline at end of file diff --git a/src/Prism.Core/Logging/Priority.cs b/src/Prism.Core/Logging/Priority.cs deleted file mode 100644 index 6522bffdc8..0000000000 --- a/src/Prism.Core/Logging/Priority.cs +++ /dev/null @@ -1,31 +0,0 @@ - - - -namespace Prism.Logging -{ - /// - /// Defines values for the priorities used by . - /// - public enum Priority - { - /// - /// No priority specified. - /// - None = 0, - - /// - /// High priority entry. - /// - High = 1, - - /// - /// Medium priority entry. - /// - Medium, - - /// - /// Low priority entry. - /// - Low - } -} \ No newline at end of file diff --git a/src/Uno/Prism.Uno/PrismApplicationBase.cs b/src/Uno/Prism.Uno/PrismApplicationBase.cs index 5cdc21b928..ebd426e640 100644 --- a/src/Uno/Prism.Uno/PrismApplicationBase.cs +++ b/src/Uno/Prism.Uno/PrismApplicationBase.cs @@ -1,7 +1,6 @@ using Prism.Common; using Prism.Events; using Prism.Ioc; -using Prism.Logging; using Prism.Modularity; using Prism.Mvvm; using Prism.Regions; diff --git a/src/Wpf/Prism.DryIoc.Wpf/Legacy/DryIocBootstrapper.cs b/src/Wpf/Prism.DryIoc.Wpf/Legacy/DryIocBootstrapper.cs index dc8221dc58..f3ba27ed76 100644 --- a/src/Wpf/Prism.DryIoc.Wpf/Legacy/DryIocBootstrapper.cs +++ b/src/Wpf/Prism.DryIoc.Wpf/Legacy/DryIocBootstrapper.cs @@ -4,7 +4,6 @@ using Prism.DryIoc.Properties; using Prism.Events; using Prism.Ioc; -using Prism.Logging; using Prism.Modularity; using Prism.Mvvm; using Prism.Regions; @@ -39,25 +38,19 @@ public override void Run(bool runWithDefaultConfiguration) { _useDefaultConfiguration = runWithDefaultConfiguration; - Logger = CreateLogger(); - if (Logger == null) - { - throw new InvalidOperationException(Resources.NullLoggerFacadeException); - } - - Logger.Log(Resources.LoggerCreatedSuccessfully, Category.Debug, Priority.Low); + Log(Resources.LoggerCreatedSuccessfully); - Logger.Log(Resources.CreatingModuleCatalog, Category.Debug, Priority.Low); + Log(Resources.CreatingModuleCatalog); ModuleCatalog = CreateModuleCatalog(); if (ModuleCatalog == null) { throw new InvalidOperationException(Resources.NullModuleCatalogException); } - Logger.Log(Resources.ConfiguringModuleCatalog, Category.Debug, Priority.Low); + Log(Resources.ConfiguringModuleCatalog); ConfigureModuleCatalog(); - Logger.Log(Resources.CreatingContainer, Category.Debug, Priority.Low); + Log(Resources.CreatingContainer); Container = CreateContainer(); if (Container == null) { @@ -67,42 +60,42 @@ public override void Run(bool runWithDefaultConfiguration) ContainerLocator.SetContainerExtension(CreateContainerExtension); ContainerExtension = ContainerLocator.Current; - Logger.Log(Resources.ConfiguringContainer, Category.Debug, Priority.Low); + Log(Resources.ConfiguringContainer); ConfigureContainer(); - Logger.Log(Resources.ConfiguringViewModelLocator, Category.Debug, Priority.Low); + Log(Resources.ConfiguringViewModelLocator); ConfigureViewModelLocator(); - Logger.Log(Resources.ConfiguringRegionAdapters, Category.Debug, Priority.Low); + Log(Resources.ConfiguringRegionAdapters); ConfigureRegionAdapterMappings(); - Logger.Log(Resources.ConfiguringDefaultRegionBehaviors, Category.Debug, Priority.Low); + Log(Resources.ConfiguringDefaultRegionBehaviors); ConfigureDefaultRegionBehaviors(); - Logger.Log(Resources.RegisteringFrameworkExceptionTypes, Category.Debug, Priority.Low); + Log(Resources.RegisteringFrameworkExceptionTypes); RegisterFrameworkExceptionTypes(); - Logger.Log(Resources.CreatingShell, Category.Debug, Priority.Low); + Log(Resources.CreatingShell); Shell = CreateShell(); if (Shell != null) { - Logger.Log(Resources.SettingTheRegionManager, Category.Debug, Priority.Low); + Log(Resources.SettingTheRegionManager); RegionManager.SetRegionManager(Shell, Container.Resolve()); - Logger.Log(Resources.UpdatingRegions, Category.Debug, Priority.Low); + Log(Resources.UpdatingRegions); RegionManager.UpdateRegions(); - Logger.Log(Resources.InitializingShell, Category.Debug, Priority.Low); + Log(Resources.InitializingShell); InitializeShell(); } if (Container.IsRegistered()) { - Logger.Log(Resources.InitializingModules, Category.Debug, Priority.Low); + Log(Resources.InitializingModules); InitializeModules(); } - Logger.Log(Resources.BootstrapperSequenceCompleted, Category.Debug, Priority.Low); + Log(Resources.BootstrapperSequenceCompleted); } /// @@ -119,7 +112,6 @@ protected override void ConfigureViewModelLocator() /// protected virtual void ConfigureContainer() { - Container.UseInstance(Logger); Container.UseInstance(ModuleCatalog); if (_useDefaultConfiguration) @@ -193,8 +185,7 @@ protected void RegisterTypeIfMissing(bool registerAsSingleton = { if(Container!=null && Container.IsRegistered()) { - Logger.Log(String.Format(CultureInfo.CurrentCulture, Resources.TypeMappingAlreadyRegistered, typeof(TFrom).Name), - Category.Debug, Priority.Low); + Log(string.Format(CultureInfo.CurrentCulture, Resources.TypeMappingAlreadyRegistered, typeof(TFrom).Name)); } else { @@ -227,8 +218,7 @@ protected void RegisterTypeIfMissing(Type fromType, Type toType, bool registerAs } if (Container.IsRegistered(fromType)) { - Logger.Log(String.Format(CultureInfo.CurrentCulture, Resources.TypeMappingAlreadyRegistered, fromType.Name), - Category.Debug, Priority.Low); + Log(string.Format(CultureInfo.CurrentCulture, Resources.TypeMappingAlreadyRegistered, fromType.Name)); } else { diff --git a/src/Wpf/Prism.Unity.Wpf/Legacy/UnityBootstrapper.cs b/src/Wpf/Prism.Unity.Wpf/Legacy/UnityBootstrapper.cs index 21cff50a31..ba3ade042f 100644 --- a/src/Wpf/Prism.Unity.Wpf/Legacy/UnityBootstrapper.cs +++ b/src/Wpf/Prism.Unity.Wpf/Legacy/UnityBootstrapper.cs @@ -2,7 +2,6 @@ using System.Globalization; using Prism.Events; using Prism.Ioc; -using Prism.Logging; using Prism.Modularity; using Prism.Regions; using Prism.Services.Dialogs; @@ -39,27 +38,21 @@ public abstract class UnityBootstrapper : Bootstrapper /// If , registers default Prism Library services in the container. This is the default behavior. public override void Run(bool runWithDefaultConfiguration) { - this.useDefaultConfiguration = runWithDefaultConfiguration; + useDefaultConfiguration = runWithDefaultConfiguration; - this.Logger = this.CreateLogger(); - if (this.Logger == null) - { - throw new InvalidOperationException(Resources.NullLoggerFacadeException); - } + Log(Resources.LoggerCreatedSuccessfully); - this.Logger.Log(Resources.LoggerCreatedSuccessfully, Category.Debug, Priority.Low); - - this.Logger.Log(Resources.CreatingModuleCatalog, Category.Debug, Priority.Low); - this.ModuleCatalog = this.CreateModuleCatalog(); + Log(Resources.CreatingModuleCatalog); + ModuleCatalog = CreateModuleCatalog(); if (this.ModuleCatalog == null) { throw new InvalidOperationException(Resources.NullModuleCatalogException); } - this.Logger.Log(Resources.ConfiguringModuleCatalog, Category.Debug, Priority.Low); + Log(Resources.ConfiguringModuleCatalog); this.ConfigureModuleCatalog(); - this.Logger.Log(Resources.CreatingContainer, Category.Debug, Priority.Low); + Log(Resources.CreatingContainer); this.Container = this.CreateContainer(); if (this.Container == null) { @@ -69,42 +62,42 @@ public override void Run(bool runWithDefaultConfiguration) ContainerLocator.SetContainerExtension(CreateContainerExtension); ContainerExtension = ContainerLocator.Current; - this.Logger.Log(Resources.ConfiguringContainer, Category.Debug, Priority.Low); + Log(Resources.ConfiguringContainer); this.ConfigureContainer(); - this.Logger.Log(Resources.ConfiguringViewModelLocator, Category.Debug, Priority.Low); + Log(Resources.ConfiguringViewModelLocator); this.ConfigureViewModelLocator(); - this.Logger.Log(Resources.ConfiguringRegionAdapters, Category.Debug, Priority.Low); + Log(Resources.ConfiguringRegionAdapters); this.ConfigureRegionAdapterMappings(); - this.Logger.Log(Resources.ConfiguringDefaultRegionBehaviors, Category.Debug, Priority.Low); + Log(Resources.ConfiguringDefaultRegionBehaviors); this.ConfigureDefaultRegionBehaviors(); - this.Logger.Log(Resources.RegisteringFrameworkExceptionTypes, Category.Debug, Priority.Low); + Log(Resources.RegisteringFrameworkExceptionTypes); this.RegisterFrameworkExceptionTypes(); - this.Logger.Log(Resources.CreatingShell, Category.Debug, Priority.Low); + Log(Resources.CreatingShell); this.Shell = this.CreateShell(); if (this.Shell != null) { - this.Logger.Log(Resources.SettingTheRegionManager, Category.Debug, Priority.Low); + Log(Resources.SettingTheRegionManager); RegionManager.SetRegionManager(this.Shell, this.Container.Resolve()); - this.Logger.Log(Resources.UpdatingRegions, Category.Debug, Priority.Low); + Log(Resources.UpdatingRegions); RegionManager.UpdateRegions(); - this.Logger.Log(Resources.InitializingShell, Category.Debug, Priority.Low); + Log(Resources.InitializingShell); this.InitializeShell(); } - if (this.Container.IsRegistered()) + if (Container.IsRegistered()) { - this.Logger.Log(Resources.InitializingModules, Category.Debug, Priority.Low); - this.InitializeModules(); + Log(Resources.InitializingModules); + InitializeModules(); } - this.Logger.Log(Resources.BootstrapperSequenceCompleted, Category.Debug, Priority.Low); + Log(Resources.BootstrapperSequenceCompleted); } /// @@ -113,9 +106,7 @@ public override void Run(bool runWithDefaultConfiguration) /// protected virtual void ConfigureContainer() { - Container.RegisterInstance(Logger); - - this.Container.RegisterInstance(this.ModuleCatalog); + Container.RegisterInstance(ModuleCatalog); if (useDefaultConfiguration) { @@ -196,10 +187,10 @@ protected void RegisterTypeIfMissing(Type fromType, Type toType, bool registerAs } if (Container.IsTypeRegistered(fromType)) { - Logger.Log( + Log( string.Format(CultureInfo.CurrentCulture, Resources.TypeMappingAlreadyRegistered, - fromType.Name), Category.Debug, Priority.Low); + fromType.Name)); } else { diff --git a/src/Wpf/Prism.Wpf/Bootstrapper.cs b/src/Wpf/Prism.Wpf/Bootstrapper.cs index 09d6f19347..ab6ab63733 100644 --- a/src/Wpf/Prism.Wpf/Bootstrapper.cs +++ b/src/Wpf/Prism.Wpf/Bootstrapper.cs @@ -3,7 +3,6 @@ using System.Windows.Controls; using System.Windows.Controls.Primitives; using Prism.Ioc; -using Prism.Logging; using Prism.Modularity; using Prism.Mvvm; using Prism.Regions; @@ -26,12 +25,6 @@ public abstract class Bootstrapper /// /// A instance. protected IContainerExtension ContainerExtension; - - /// - /// Gets the for the application. - /// - /// A instance. - protected ILoggerFacade Logger { get; set; } /// /// Gets the default for the application. @@ -51,17 +44,6 @@ public abstract class Bootstrapper /// The container extension. protected abstract IContainerExtension CreateContainerExtension(); - /// - /// Create the used by the bootstrapper. - /// - /// - /// The base implementation returns a new TextLogger. - /// - protected virtual ILoggerFacade CreateLogger() - { - return new TextLogger(); - } - /// /// Runs the bootstrapper process. /// @@ -72,6 +54,11 @@ public void Run() this.OnInitialized(); } + protected virtual void Log(string message) + { + // Intentionally left blank + } + /// /// Creates the used by Prism. /// diff --git a/src/Wpf/Prism.Wpf/Logging/TextLogger.cs b/src/Wpf/Prism.Wpf/Logging/TextLogger.cs deleted file mode 100644 index 2baab33c6d..0000000000 --- a/src/Wpf/Prism.Wpf/Logging/TextLogger.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Prism.Properties; -using System; -using System.Globalization; -using System.IO; - -namespace Prism.Logging -{ - /// - /// Implementation of that logs into a . - /// - public class TextLogger : ILoggerFacade, IDisposable - { - /// - /// A that writes to console output. - /// - public TextWriter Writer { get; set; } = Console.Out; - - /// - /// Initializes a new instance of that writes to - /// the console output. - /// - public TextLogger() { } - - /// - /// Write a new log entry with the specified category and priority. - /// - /// Message body to log. - /// Category of the entry. - /// The priority of the entry. - public void Log(string message, Category category, Priority priority) - { - string messageToLog = String.Format(CultureInfo.InvariantCulture, Resources.DefaultTextLoggerPattern, DateTime.Now, - category.ToString().ToUpper(CultureInfo.InvariantCulture), message, priority.ToString()); - - Writer.WriteLine(messageToLog); - } - - /// - /// Disposes the associated . - /// - /// When , disposes the associated . - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - if (Writer != null) - { - Writer.Dispose(); - } - } - } - - /// - ///Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - /// Calls . - ///2 - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - } -} \ No newline at end of file diff --git a/src/Wpf/Prism.Wpf/Logging/TraceLogger.cs b/src/Wpf/Prism.Wpf/Logging/TraceLogger.cs deleted file mode 100644 index 9289cb2fa9..0000000000 --- a/src/Wpf/Prism.Wpf/Logging/TraceLogger.cs +++ /dev/null @@ -1,30 +0,0 @@ - - -using System.Diagnostics; - -namespace Prism.Logging -{ - /// - /// Implementation of that logs to .NET class. - /// - public class TraceLogger : ILoggerFacade - { - /// - /// Write a new log entry with the specified category and priority. - /// - /// Message body to log. - /// Category of the entry. - /// The priority of the entry. - public void Log(string message, Category category, Priority priority) - { - if (category == Category.Exception) - { - Trace.TraceError(message); - } - else - { - Trace.TraceInformation(message); - } - } - } -} \ No newline at end of file diff --git a/src/Wpf/Prism.Wpf/Modularity/ModuleInitializer.cs b/src/Wpf/Prism.Wpf/Modularity/ModuleInitializer.cs index 81a312c821..62c28284a9 100644 --- a/src/Wpf/Prism.Wpf/Modularity/ModuleInitializer.cs +++ b/src/Wpf/Prism.Wpf/Modularity/ModuleInitializer.cs @@ -1,5 +1,4 @@ using Prism.Ioc; -using Prism.Logging; using System; using System.Globalization; @@ -11,17 +10,14 @@ namespace Prism.Modularity public class ModuleInitializer : IModuleInitializer { private readonly IContainerExtension _containerExtension; - private readonly ILoggerFacade _loggerFacade; /// /// Initializes a new instance of . /// /// The container that will be used to resolve the modules by specifying its type. - /// The logger to use. - public ModuleInitializer(IContainerExtension containerExtension, ILoggerFacade loggerFacade) + public ModuleInitializer(IContainerExtension containerExtension) { this._containerExtension = containerExtension ?? throw new ArgumentNullException(nameof(containerExtension)); - this._loggerFacade = loggerFacade ?? throw new ArgumentNullException(nameof(loggerFacade)); } /// @@ -88,8 +84,6 @@ public virtual void HandleModuleInitializationError(IModuleInfo moduleInfo, stri } } - this._loggerFacade.Log(moduleException.ToString(), Category.Exception, Priority.High); - throw moduleException; } diff --git a/src/Wpf/Prism.Wpf/Modularity/ModuleManager.cs b/src/Wpf/Prism.Wpf/Modularity/ModuleManager.cs index 95d28f7f58..eb6a412e22 100644 --- a/src/Wpf/Prism.Wpf/Modularity/ModuleManager.cs +++ b/src/Wpf/Prism.Wpf/Modularity/ModuleManager.cs @@ -1,6 +1,3 @@ - - -using Prism.Logging; using Prism.Properties; using System; using System.Collections.Generic; @@ -15,7 +12,6 @@ namespace Prism.Modularity public partial class ModuleManager : IModuleManager, IDisposable { private readonly IModuleInitializer moduleInitializer; - private readonly ILoggerFacade loggerFacade; private IEnumerable typeLoaders; private HashSet subscribedToModuleTypeLoaders = new HashSet(); @@ -24,12 +20,10 @@ public partial class ModuleManager : IModuleManager, IDisposable /// /// Service used for initialization of modules. /// Catalog that enumerates the modules to be loaded and initialized. - /// Logger used during the load and initialization of modules. - public ModuleManager(IModuleInitializer moduleInitializer, IModuleCatalog moduleCatalog, ILoggerFacade loggerFacade) + public ModuleManager(IModuleInitializer moduleInitializer, IModuleCatalog moduleCatalog) { this.moduleInitializer = moduleInitializer ?? throw new ArgumentNullException(nameof(moduleInitializer)); - this.ModuleCatalog = moduleCatalog ?? throw new ArgumentNullException(nameof(moduleCatalog)); - this.loggerFacade = loggerFacade ?? throw new ArgumentNullException(nameof(loggerFacade)); + ModuleCatalog = moduleCatalog ?? throw new ArgumentNullException(nameof(moduleCatalog)); } /// @@ -226,7 +220,7 @@ private void IModuleTypeLoader_LoadModuleCompleted(object sender, LoadModuleComp /// /// Handles any exception occurred in the module typeloading process, - /// logs the error using the and throws a . + /// and throws a . /// This method can be overridden to provide a different behavior. /// /// The module metadata where the error happenened. @@ -244,8 +238,6 @@ protected virtual void HandleModuleTypeLoadingError(IModuleInfo moduleInfo, Exce moduleTypeLoadingException = new ModuleTypeLoadingException(moduleInfo.ModuleName, exception.Message, exception); } - this.loggerFacade.Log(moduleTypeLoadingException.Message, Category.Exception, Priority.High); - throw moduleTypeLoadingException; } diff --git a/src/Wpf/Prism.Wpf/PrismInitializationExtensions.cs b/src/Wpf/Prism.Wpf/PrismInitializationExtensions.cs index ed70dfcb20..e0c47c4e35 100644 --- a/src/Wpf/Prism.Wpf/PrismInitializationExtensions.cs +++ b/src/Wpf/Prism.Wpf/PrismInitializationExtensions.cs @@ -1,6 +1,5 @@ using Prism.Events; using Prism.Ioc; -using Prism.Logging; using Prism.Modularity; using Prism.Mvvm; using Prism.Regions; @@ -30,7 +29,6 @@ internal static void ConfigureViewModelLocator() internal static void RegisterRequiredTypes(this IContainerRegistry containerRegistry, IModuleCatalog moduleCatalog) { containerRegistry.RegisterInstance(moduleCatalog); - containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); diff --git a/tests/Forms/MockApp/MockPrismApp.cs b/tests/Forms/MockApp/MockPrismApp.cs index 550dd07feb..fc27fa1485 100644 --- a/tests/Forms/MockApp/MockPrismApp.cs +++ b/tests/Forms/MockApp/MockPrismApp.cs @@ -4,7 +4,6 @@ using Prism.Behaviors; using Prism.Common; using Prism.Ioc; -using Prism.Logging; using Prism.Modularity; using Prism.Navigation; diff --git a/tests/Forms/Prism.DI.Forms.Tests/Fixtures/Ioc/ContainerProviderFixture.cs b/tests/Forms/Prism.DI.Forms.Tests/Fixtures/Ioc/ContainerProviderFixture.cs index 0717f56e2d..6c88713852 100644 --- a/tests/Forms/Prism.DI.Forms.Tests/Fixtures/Ioc/ContainerProviderFixture.cs +++ b/tests/Forms/Prism.DI.Forms.Tests/Fixtures/Ioc/ContainerProviderFixture.cs @@ -6,7 +6,6 @@ using Prism.Events; using Prism.Forms.Tests.Mocks.Events; using Prism.Ioc; -using Prism.Logging; using Xunit; using Xunit.Abstractions; diff --git a/tests/Forms/Prism.DI.Forms.Tests/Fixtures/PrismApplicationFixture.cs b/tests/Forms/Prism.DI.Forms.Tests/Fixtures/PrismApplicationFixture.cs index d7f81ecf43..f40e67ea49 100644 --- a/tests/Forms/Prism.DI.Forms.Tests/Fixtures/PrismApplicationFixture.cs +++ b/tests/Forms/Prism.DI.Forms.Tests/Fixtures/PrismApplicationFixture.cs @@ -11,9 +11,7 @@ using Prism.DI.Forms.Tests.Mocks.ViewModels; using Prism.DI.Forms.Tests.Mocks.Views; using Prism.DI.Forms.Tests.Navigation; -using Prism.Forms.Tests.Mocks.Logging; using Prism.Ioc; -using Prism.Logging; using Prism.Navigation; using Xamarin.Forms; using Xamarin.Forms.Mocks; @@ -47,15 +45,6 @@ public void PlatformTypesRegistered() Assert.IsAssignableFrom(app.Container.Resolve()); } - [Fact] - public void ResolvesCustom_ILoggerFacade() - { - var app = CreateMockApplication(); - var logger = app.Container.Resolve(); - logger.Log("Test Message", Category.Debug, Priority.None); - Assert.IsType(logger); - } - [Fact] public void OnInitialized_SetPage() { diff --git a/tests/Forms/Prism.DI.Forms.Tests/Mocks/Logging/XUnitLogger.cs b/tests/Forms/Prism.DI.Forms.Tests/Mocks/Logging/XUnitLogger.cs deleted file mode 100644 index 97b82a0543..0000000000 --- a/tests/Forms/Prism.DI.Forms.Tests/Mocks/Logging/XUnitLogger.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Prism.Logging; -using System; -using System.Collections.Generic; -using System.Text; -using Xunit.Abstractions; - -namespace Prism.Forms.Tests.Mocks.Logging -{ - public class XunitLogger : ILoggerFacade - { - private ITestOutputHelper _output { get; } - - public XunitLogger(ITestOutputHelper output) - { - _output = output; - } - - public void Log(string message, Category category, Priority priority) - { - _output.WriteLine($"{category} - {priority}: {message}"); - } - } -} diff --git a/tests/Forms/Prism.DI.Forms.Tests/Mocks/Navigation/CustomNavigationServiceMock.cs b/tests/Forms/Prism.DI.Forms.Tests/Mocks/Navigation/CustomNavigationServiceMock.cs index c3821cd647..6a98dd5853 100644 --- a/tests/Forms/Prism.DI.Forms.Tests/Mocks/Navigation/CustomNavigationServiceMock.cs +++ b/tests/Forms/Prism.DI.Forms.Tests/Mocks/Navigation/CustomNavigationServiceMock.cs @@ -1,8 +1,6 @@ -using Prism.AppModel; using Prism.Behaviors; using Prism.Common; using Prism.Ioc; -using Prism.Logging; using Prism.Navigation; namespace Prism.DI.Forms.Tests.Navigation diff --git a/tests/Forms/Prism.DI.Forms.Tests/Mocks/PrismApplicationMock.cs b/tests/Forms/Prism.DI.Forms.Tests/Mocks/PrismApplicationMock.cs index 83f1093f73..b84b47eefb 100644 --- a/tests/Forms/Prism.DI.Forms.Tests/Mocks/PrismApplicationMock.cs +++ b/tests/Forms/Prism.DI.Forms.Tests/Mocks/PrismApplicationMock.cs @@ -6,19 +6,11 @@ using Prism.Modularity; using Prism.Navigation; using Xamarin.Forms; -using Prism.Logging; -using Prism.Forms.Tests.Mocks.Logging; using Prism.Mvvm; using System; -#if Autofac -using Prism.Autofac; -using Autofac; -#elif DryIoc +#if DryIoc using Prism.DryIoc; using DryIoc; -#elif Ninject -using Prism.Ninject; -using Ninject; #elif Unity using Prism.Unity; using Unity; @@ -56,7 +48,6 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry) containerRegistry.Register(ViewModelBMock.Key); containerRegistry.Register(); containerRegistry.RegisterSingleton(); - containerRegistry.RegisterSingleton(); containerRegistry.RegisterForNavigation(); containerRegistry.RegisterForNavigation("view"); diff --git a/tests/Forms/Prism.DI.Forms.Tests/Mocks/PrismApplicationMockPlatformAware.cs b/tests/Forms/Prism.DI.Forms.Tests/Mocks/PrismApplicationMockPlatformAware.cs index 82de877ade..f9b4ac6bf2 100644 --- a/tests/Forms/Prism.DI.Forms.Tests/Mocks/PrismApplicationMockPlatformAware.cs +++ b/tests/Forms/Prism.DI.Forms.Tests/Mocks/PrismApplicationMockPlatformAware.cs @@ -6,8 +6,6 @@ using Prism.Modularity; using Prism.Navigation; using Xamarin.Forms; -using Prism.Logging; -using Prism.Forms.Tests.Mocks.Logging; using Prism.Mvvm; using System; #if DryIoc diff --git a/tests/Forms/Prism.DI.Forms.Tests/Prism.DI.Forms.Tests.projitems b/tests/Forms/Prism.DI.Forms.Tests/Prism.DI.Forms.Tests.projitems index c3d5a883e0..946780be28 100644 --- a/tests/Forms/Prism.DI.Forms.Tests/Prism.DI.Forms.Tests.projitems +++ b/tests/Forms/Prism.DI.Forms.Tests/Prism.DI.Forms.Tests.projitems @@ -18,7 +18,6 @@ - diff --git a/tests/Forms/Prism.Forms.Tests/Mocks/PageNavigationServiceMock.cs b/tests/Forms/Prism.Forms.Tests/Mocks/PageNavigationServiceMock.cs index 1ee7b0f80a..b7195dcf52 100644 --- a/tests/Forms/Prism.Forms.Tests/Mocks/PageNavigationServiceMock.cs +++ b/tests/Forms/Prism.Forms.Tests/Mocks/PageNavigationServiceMock.cs @@ -1,7 +1,6 @@ using Prism.Behaviors; using Prism.Common; using Prism.Ioc; -using Prism.Logging; using Prism.Navigation; using Xamarin.Forms; diff --git a/tests/Forms/Prism.Forms.Tests/Navigation/PageNavigationServiceFixture.cs b/tests/Forms/Prism.Forms.Tests/Navigation/PageNavigationServiceFixture.cs index 078bc90521..af443adeb3 100644 --- a/tests/Forms/Prism.Forms.Tests/Navigation/PageNavigationServiceFixture.cs +++ b/tests/Forms/Prism.Forms.Tests/Navigation/PageNavigationServiceFixture.cs @@ -5,7 +5,6 @@ using Prism.Forms.Tests.Mocks.Views; using Prism.Forms.Tests.Navigation.Mocks.Views; using Prism.Ioc; -using Prism.Logging; using Prism.Navigation; using System; using System.Linq; @@ -19,7 +18,6 @@ public class PageNavigationServiceFixture : IDisposable { PageNavigationContainerMock _container; IApplicationProvider _applicationProvider; - ILoggerFacade _loggerFacade; public PageNavigationServiceFixture() { @@ -58,7 +56,6 @@ public PageNavigationServiceFixture() _container.Register("CarouselPage", typeof(CarouselPageMock)); _applicationProvider = new ApplicationProviderMock(); - _loggerFacade = new EmptyLogger(); } [Fact] diff --git a/tests/Prism.Core.Tests/Logging/DebugLoggerFixture.cs b/tests/Prism.Core.Tests/Logging/DebugLoggerFixture.cs deleted file mode 100644 index 0d40cc9590..0000000000 --- a/tests/Prism.Core.Tests/Logging/DebugLoggerFixture.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Xunit; -using Prism.Logging; - -namespace Prism.Tests.Logging -{ - public class DebugLoggerFixture - { - [Fact] - public void LogShouldNotFail() - { - ILoggerFacade logger = new DebugLogger(); - logger.Log(null, Category.Debug, Priority.Medium); - } - } -} \ No newline at end of file diff --git a/tests/Prism.Core.Tests/Logging/EmptyLoggerFixture.cs b/tests/Prism.Core.Tests/Logging/EmptyLoggerFixture.cs deleted file mode 100644 index 3d10ff18fe..0000000000 --- a/tests/Prism.Core.Tests/Logging/EmptyLoggerFixture.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Xunit; -using Prism.Logging; - -namespace Prism.Tests.Logging -{ - public class EmptyLoggerFixture - { - [Fact] - public void LogShouldNotFail() - { - ILoggerFacade logger = new EmptyLogger(); - - logger.Log(null, Category.Debug, Priority.Medium); - } - } -} \ No newline at end of file diff --git a/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Bootstrapper/BootstrapperFixture.cs b/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Bootstrapper/BootstrapperFixture.cs index 6703b9dbea..2cc21680b2 100644 --- a/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Bootstrapper/BootstrapperFixture.cs +++ b/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Bootstrapper/BootstrapperFixture.cs @@ -1,7 +1,6 @@ using System; using Prism.Container.Wpf.Mocks; using Prism.Ioc; -using Prism.Logging; using Prism.Modularity; using Prism.Regions; using Xunit; @@ -49,16 +48,6 @@ public void ConfigureContainerAddsModuleCatalogToContainer() Assert.IsType(returnedCatalog); } - [StaFact] - public void ConfigureContainerAddsLoggerFacadeToContainer() - { - var bootstrapper = new MockBootstrapper(); - bootstrapper.Run(); - - var returnedCatalog = bootstrapper.ContainerExtension.Resolve(); - Assert.NotNull(returnedCatalog); - } - [StaFact] public void ConfigureContainerAddsRegionNavigationJournalEntryToContainer() { diff --git a/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Bootstrapper/BootstrapperNullLoggerFixture.cs b/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Bootstrapper/BootstrapperNullLoggerFixture.cs deleted file mode 100644 index d9c865319b..0000000000 --- a/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Bootstrapper/BootstrapperNullLoggerFixture.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using Prism.Container.Wpf.Mocks; -using Prism.IocContainer.Wpf.Tests.Support; -using Xunit; - -namespace Prism.Container.Wpf.Tests.Bootstrapper -{ - public class BootstrapperNullLoggerFixture : BootstrapperFixtureBase - { - [Fact] - public void NullLoggerThrows() - { - var bootstrapper = new NullLoggerBootstrapper(); - - AssertExceptionThrownOnRun(bootstrapper, typeof(InvalidOperationException), "ILoggerFacade"); - } - } -} diff --git a/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Bootstrapper/BootstrapperRunMethodFixture.cs b/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Bootstrapper/BootstrapperRunMethodFixture.cs index b8d7b7eb82..5b88bbb94b 100644 --- a/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Bootstrapper/BootstrapperRunMethodFixture.cs +++ b/tests/Wpf/Prism.Container.Wpf.Shared/Fixtures/Bootstrapper/BootstrapperRunMethodFixture.cs @@ -90,16 +90,6 @@ public void RunShouldAssignRegionManagerToReturnedShell() Assert.NotNull(RegionManager.GetRegionManager(bootstrapper.BaseShell)); } - [StaFact] - public void RunShouldCallCreateLogger() - { - var bootstrapper = new MockBootstrapper(); - - bootstrapper.Run(); - - Assert.True(bootstrapper.CreateLoggerCalled); - } - [StaFact] public void RunShouldCallCreateModuleCatalog() { @@ -216,7 +206,6 @@ public void RunShouldCallTheMethodsInOrder() bootstrapper.Run(); var index = 0; - Assert.Equal("CreateLogger", bootstrapper.MethodCalls[index++]); Assert.Equal("CreateModuleCatalog", bootstrapper.MethodCalls[index++]); Assert.Equal("ConfigureModuleCatalog", bootstrapper.MethodCalls[index++]); Assert.Equal("CreateContainer", bootstrapper.MethodCalls[index++]); @@ -235,7 +224,7 @@ public void RunShouldLogBootstrapperSteps() { var bootstrapper = new MockBootstrapper(); bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; + var messages = bootstrapper.Messages; var index = 0; Assert.Contains(ContainerResources.LoggerCreatedSuccessfully, messages[index++]); @@ -260,18 +249,17 @@ public void RunShouldLogLoggerCreationSuccess() { var bootstrapper = new MockBootstrapper(); bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; + var messages = bootstrapper.Messages; - Assert.True(messages.Contains(ContainerResources.LoggerCreatedSuccessfully)); + Assert.Contains(ContainerResources.LoggerCreatedSuccessfully, messages); } [StaFact] public void RunShouldLogAboutModuleCatalogCreation() { var bootstrapper = new MockBootstrapper(); bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; - - Assert.True(messages.Contains(ContainerResources.CreatingModuleCatalog)); + var messages = bootstrapper.Messages; + Assert.Contains(ContainerResources.CreatingModuleCatalog, messages); } [StaFact] @@ -279,9 +267,9 @@ public void RunShouldLogAboutConfiguringModuleCatalog() { var bootstrapper = new MockBootstrapper(); bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; + var messages = bootstrapper.Messages; - Assert.True(messages.Contains(ContainerResources.ConfiguringModuleCatalog)); + Assert.Contains(ContainerResources.ConfiguringModuleCatalog, messages); } [StaFact] @@ -289,9 +277,9 @@ public void RunShouldLogAboutCreatingTheContainer() { var bootstrapper = new MockBootstrapper(); bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; + var messages = bootstrapper.Messages; - Assert.True(messages.Contains(ContainerResources.CreatingContainer)); + Assert.Contains(ContainerResources.CreatingContainer, messages); } [StaFact] @@ -299,9 +287,9 @@ public void RunShouldLogAboutConfiguringContainer() { var bootstrapper = new MockBootstrapper(); bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; + var messages = bootstrapper.Messages; - Assert.True(messages.Contains(ContainerResources.ConfiguringContainer)); + Assert.Contains(ContainerResources.ConfiguringContainer, messages); } [StaFact] @@ -309,9 +297,9 @@ public void RunShouldLogAboutConfiguringViewModelLocator() { var bootstrapper = new MockBootstrapper(); bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; + var messages = bootstrapper.Messages; - Assert.True(messages.Contains(ContainerResources.ConfiguringViewModelLocator)); + Assert.Contains(ContainerResources.ConfiguringViewModelLocator, messages); } [StaFact] @@ -319,9 +307,9 @@ public void RunShouldLogAboutConfiguringRegionAdapters() { var bootstrapper = new MockBootstrapper(); bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; + var messages = bootstrapper.Messages; - Assert.True(messages.Contains(ContainerResources.ConfiguringRegionAdapters)); + Assert.Contains(ContainerResources.ConfiguringRegionAdapters, messages); } [StaFact] @@ -329,9 +317,9 @@ public void RunShouldLogAboutConfiguringRegionBehaviors() { var bootstrapper = new MockBootstrapper(); bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; + var messages = bootstrapper.Messages; - Assert.True(messages.Contains(ContainerResources.ConfiguringDefaultRegionBehaviors)); + Assert.Contains(ContainerResources.ConfiguringDefaultRegionBehaviors, messages); } [StaFact] @@ -339,9 +327,9 @@ public void RunShouldLogAboutRegisteringFrameworkExceptionTypes() { var bootstrapper = new MockBootstrapper(); bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; + var messages = bootstrapper.Messages; - Assert.True(messages.Contains(ContainerResources.RegisteringFrameworkExceptionTypes)); + Assert.Contains(ContainerResources.RegisteringFrameworkExceptionTypes, messages); } [StaFact] @@ -349,9 +337,9 @@ public void RunShouldLogAboutCreatingTheShell() { var bootstrapper = new MockBootstrapper(); bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; + var messages = bootstrapper.Messages; - Assert.True(messages.Contains(ContainerResources.CreatingShell)); + Assert.Contains(ContainerResources.CreatingShell, messages); } [StaFact] @@ -360,9 +348,9 @@ public void RunShouldLogAboutInitializingTheShellIfShellCreated() var bootstrapper = new MockBootstrapper(); bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; + var messages = bootstrapper.Messages; - Assert.True(messages.Contains(ContainerResources.InitializingShell)); + Assert.Contains(ContainerResources.InitializingShell, messages); } [StaFact] @@ -371,9 +359,9 @@ public void RunShouldNotLogAboutInitializingTheShellIfShellIsNotCreated() var bootstrapper = new MockBootstrapper { ShellObject = null }; bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; + var messages = bootstrapper.Messages; - Assert.False(messages.Contains(ContainerResources.InitializingShell)); + Assert.DoesNotContain(ContainerResources.InitializingShell, messages); } [StaFact] @@ -381,9 +369,9 @@ public void RunShouldLogAboutInitializingModules() { var bootstrapper = new MockBootstrapper(); bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; + var messages = bootstrapper.Messages; - Assert.True(messages.Contains(ContainerResources.InitializingModules)); + Assert.Contains(ContainerResources.InitializingModules, messages); } [StaFact] @@ -391,9 +379,9 @@ public void RunShouldLogAboutRunCompleting() { var bootstrapper = new MockBootstrapper(); bootstrapper.Run(); - var messages = bootstrapper.BaseLogger.Messages; + var messages = bootstrapper.Messages; - Assert.True(messages.Contains(ContainerResources.BootstrapperSequenceCompleted)); + Assert.Contains(ContainerResources.BootstrapperSequenceCompleted, messages); } } } diff --git a/tests/Wpf/Prism.Container.Wpf.Shared/Mocks/NullLoggerBootstrapper.cs b/tests/Wpf/Prism.Container.Wpf.Shared/Mocks/NullLoggerBootstrapper.cs deleted file mode 100644 index 9abad316a8..0000000000 --- a/tests/Wpf/Prism.Container.Wpf.Shared/Mocks/NullLoggerBootstrapper.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Windows; -using Prism.Logging; - -namespace Prism.Container.Wpf.Mocks -{ - internal partial class NullLoggerBootstrapper - { - protected override ILoggerFacade CreateLogger() - { - return null; - } - - protected override DependencyObject CreateShell() - { - throw new NotImplementedException(); - } - - protected override void InitializeShell() - { - throw new NotImplementedException(); - } - } -} diff --git a/tests/Wpf/Prism.Container.Wpf.Shared/Mocks/NullModuleManagerBootstrapper.cs b/tests/Wpf/Prism.Container.Wpf.Shared/Mocks/NullModuleManagerBootstrapper.cs index 66c2b9e0d0..74ff67e571 100644 --- a/tests/Wpf/Prism.Container.Wpf.Shared/Mocks/NullModuleManagerBootstrapper.cs +++ b/tests/Wpf/Prism.Container.Wpf.Shared/Mocks/NullModuleManagerBootstrapper.cs @@ -1,6 +1,5 @@ using System.Windows; using Prism.Ioc; -using Prism.Logging; using Prism.Regions; namespace Prism.Container.Wpf.Mocks @@ -12,9 +11,8 @@ internal partial class NullModuleManagerBootstrapper protected override void ConfigureContainer() { //base.RegisterDefaultTypesIfMissing(); - ContainerExtension.RegisterInstance(Logger); - ContainerExtension.RegisterInstance(this.ModuleCatalog); + ContainerExtension.RegisterInstance(ModuleCatalog); } protected override IRegionBehaviorFactory ConfigureDefaultRegionBehaviors() diff --git a/tests/Wpf/Prism.Container.Wpf.Shared/Prism.Container.Wpf.Shared.projitems b/tests/Wpf/Prism.Container.Wpf.Shared/Prism.Container.Wpf.Shared.projitems index 7ad14f8d4a..68e34ac7f4 100644 --- a/tests/Wpf/Prism.Container.Wpf.Shared/Prism.Container.Wpf.Shared.projitems +++ b/tests/Wpf/Prism.Container.Wpf.Shared/Prism.Container.Wpf.Shared.projitems @@ -12,13 +12,11 @@ - - diff --git a/tests/Wpf/Prism.DryIoc.Wpf.Tests/Fixtures/BootstrapperRunMethodFixture.cs b/tests/Wpf/Prism.DryIoc.Wpf.Tests/Fixtures/BootstrapperRunMethodFixture.cs index 55f9321ccd..7b2fc13ef1 100644 --- a/tests/Wpf/Prism.DryIoc.Wpf.Tests/Fixtures/BootstrapperRunMethodFixture.cs +++ b/tests/Wpf/Prism.DryIoc.Wpf.Tests/Fixtures/BootstrapperRunMethodFixture.cs @@ -3,7 +3,6 @@ using Prism.Container.Wpf.Mocks; using Prism.Events; using Prism.Ioc; -using Prism.Logging; using Prism.Modularity; using Prism.Regions; using Prism.DryIoc; @@ -25,19 +24,6 @@ public void RunAddsCompositionContainerToContainer() Assert.Equal(typeof(global::DryIoc.Container), returnedContainer.GetType()); } - [StaFact] - public void RunRegistersInstanceOfILoggerFacade() - { - var mockedContainer = new Mock(); - SetupMockedContainerForVerificationTests(mockedContainer); - - var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); - - bootstrapper.Run(); - - mockedContainer.Verify(c => c.UseInstance(typeof(ILoggerFacade), It.IsAny(), IfAlreadyRegistered.Replace, It.IsAny(), It.IsAny(), It.IsAny())); - } - [StaFact] public void RunRegistersInstanceOfIModuleCatalog() { diff --git a/tests/Wpf/Prism.DryIoc.Wpf.Tests/Mocks/MockBootstrapper.cs b/tests/Wpf/Prism.DryIoc.Wpf.Tests/Mocks/MockBootstrapper.cs index b36043af29..f5afa3f47e 100644 --- a/tests/Wpf/Prism.DryIoc.Wpf.Tests/Mocks/MockBootstrapper.cs +++ b/tests/Wpf/Prism.DryIoc.Wpf.Tests/Mocks/MockBootstrapper.cs @@ -6,7 +6,6 @@ using Prism.DryIoc; using Prism.Ioc; using Prism.IocContainer.Wpf.Tests.Support.Mocks; -using Prism.Logging; using Prism.Modularity; using Prism.Regions; @@ -18,7 +17,6 @@ internal class MockBootstrapper : DryIocBootstrapper public bool InitializeModulesCalled; public bool ConfigureRegionAdapterMappingsCalled; public RegionAdapterMappings DefaultRegionAdapterMappings; - public bool CreateLoggerCalled; public bool CreateModuleCatalogCalled; public bool ConfigureContainerCalled; public bool CreateShellCalled; @@ -47,8 +45,6 @@ public override void Run(bool runWithDefaultConfiguration) public IContainerRegistry ContainerRegistry => base.ContainerExtension; - public MockLoggerAdapter BaseLogger => base.Logger as MockLoggerAdapter; - public IContainer CallCreateContainer() { return this.CreateContainer(); @@ -68,13 +64,6 @@ protected override void ConfigureContainer() base.ConfigureContainer(); } - protected override ILoggerFacade CreateLogger() - { - this.MethodCalls.Add(MethodBase.GetCurrentMethod().Name); - this.CreateLoggerCalled = true; - return new MockLoggerAdapter(); - } - protected override DependencyObject CreateShell() { this.MethodCalls.Add(MethodBase.GetCurrentMethod().Name); @@ -145,5 +134,12 @@ public void CallRegisterFrameworkExceptionTypes() { base.RegisterFrameworkExceptionTypes(); } + + public List Messages { get; } = new List(); + + protected override void Log(string message) + { + Messages.Add(message); + } } } diff --git a/tests/Wpf/Prism.DryIoc.Wpf.Tests/Mocks/MockedContainerBootstrapper.cs b/tests/Wpf/Prism.DryIoc.Wpf.Tests/Mocks/MockedContainerBootstrapper.cs index e6b4eadf61..2e3d0e8159 100644 --- a/tests/Wpf/Prism.DryIoc.Wpf.Tests/Mocks/MockedContainerBootstrapper.cs +++ b/tests/Wpf/Prism.DryIoc.Wpf.Tests/Mocks/MockedContainerBootstrapper.cs @@ -3,14 +3,12 @@ using DryIoc; using Prism.DryIoc; using Prism.Ioc; -using Prism.Logging; namespace Prism.Container.Wpf.Mocks { internal class MockedContainerBootstrapper : DryIocBootstrapper { private readonly IContainer container; - public ILoggerFacade BaseLogger => base.Logger; public void CallConfigureContainer() { diff --git a/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockLoggerAdapter.cs b/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockLoggerAdapter.cs deleted file mode 100644 index ad8fdd4970..0000000000 --- a/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockLoggerAdapter.cs +++ /dev/null @@ -1,17 +0,0 @@ - - -using System.Collections.Generic; -using Prism.Logging; - -namespace Prism.IocContainer.Wpf.Tests.Support.Mocks -{ - public class MockLoggerAdapter : ILoggerFacade - { - public IList Messages = new List(); - - public void Log(string message, Category category, Priority priority) - { - Messages.Add(message); - } - } -} \ No newline at end of file diff --git a/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockModuleLoader.cs b/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockModuleLoader.cs index ea309d688f..558b58927b 100644 --- a/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockModuleLoader.cs +++ b/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockModuleLoader.cs @@ -1,5 +1,3 @@ - - using Prism.Modularity; namespace Prism.IocContainer.Wpf.Tests.Support.Mocks diff --git a/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockRegionManager.cs b/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockRegionManager.cs index 8bbaf764de..74e0676763 100644 --- a/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockRegionManager.cs +++ b/tests/Wpf/Prism.IocContainer.Wpf.Tests.Support/Mocks/MockRegionManager.cs @@ -1,5 +1,3 @@ - - using System; using Prism.Regions; diff --git a/tests/Wpf/Prism.Unity.Wpf.Tests/Fixtures/BootstrapperRunMethodFixture.cs b/tests/Wpf/Prism.Unity.Wpf.Tests/Fixtures/BootstrapperRunMethodFixture.cs index c5520a4cfa..b3529af97a 100644 --- a/tests/Wpf/Prism.Unity.Wpf.Tests/Fixtures/BootstrapperRunMethodFixture.cs +++ b/tests/Wpf/Prism.Unity.Wpf.Tests/Fixtures/BootstrapperRunMethodFixture.cs @@ -3,7 +3,6 @@ using Prism.Container.Wpf.Mocks; using Prism.Events; using Prism.Ioc; -using Prism.Logging; using Prism.Modularity; using Prism.Regions; using Prism.Unity; @@ -26,19 +25,6 @@ public void RunAddsCompositionContainerToContainer() Assert.Equal(typeof(UnityContainer), returnedContainer.GetType()); } - [StaFact] - public void RunRegistersInstanceOfILoggerFacade() - { - var mockedContainer = new Mock(); - SetupMockedContainerForVerificationTests(mockedContainer); - - var bootstrapper = new MockedContainerBootstrapper(mockedContainer.Object); - - bootstrapper.Run(); - - mockedContainer.Verify(c => c.RegisterInstance(typeof(ILoggerFacade), null, bootstrapper.BaseLogger, It.IsAny()), Times.Once()); - } - [StaFact] public void RunRegistersInstanceOfIModuleCatalog() { diff --git a/tests/Wpf/Prism.Unity.Wpf.Tests/Mocks/MockBootstrapper.cs b/tests/Wpf/Prism.Unity.Wpf.Tests/Mocks/MockBootstrapper.cs index 5d8b0c76b0..7c4fd2dc96 100644 --- a/tests/Wpf/Prism.Unity.Wpf.Tests/Mocks/MockBootstrapper.cs +++ b/tests/Wpf/Prism.Unity.Wpf.Tests/Mocks/MockBootstrapper.cs @@ -2,13 +2,11 @@ using System.Reflection; using System.Windows; using System.Windows.Controls; -using Unity; -using Prism.IocContainer.Wpf.Tests.Support.Mocks; -using Prism.Logging; +using Prism.Ioc; using Prism.Modularity; using Prism.Regions; using Prism.Unity; -using Prism.Ioc; +using Unity; namespace Prism.Container.Wpf.Mocks { @@ -47,8 +45,6 @@ public override void Run(bool runWithDefaultConfiguration) public IContainerRegistry ContainerRegistry => base.ContainerExtension; - public MockLoggerAdapter BaseLogger => base.Logger as MockLoggerAdapter; - public IUnityContainer CallCreateContainer() { return this.CreateContainer(); @@ -68,13 +64,6 @@ protected override void ConfigureContainer() base.ConfigureContainer(); } - protected override ILoggerFacade CreateLogger() - { - this.MethodCalls.Add(MethodBase.GetCurrentMethod().Name); - this.CreateLoggerCalled = true; - return new MockLoggerAdapter(); - } - protected override DependencyObject CreateShell() { this.MethodCalls.Add(MethodBase.GetCurrentMethod().Name); @@ -145,5 +134,12 @@ public void CallRegisterFrameworkExceptionTypes() { base.RegisterFrameworkExceptionTypes(); } + + public List Messages { get; } = new List(); + + protected override void Log(string message) + { + Messages.Add(message); + } } } diff --git a/tests/Wpf/Prism.Unity.Wpf.Tests/Mocks/MockedContainerBootstrapper.cs b/tests/Wpf/Prism.Unity.Wpf.Tests/Mocks/MockedContainerBootstrapper.cs index 7c72790419..d2670f95ce 100644 --- a/tests/Wpf/Prism.Unity.Wpf.Tests/Mocks/MockedContainerBootstrapper.cs +++ b/tests/Wpf/Prism.Unity.Wpf.Tests/Mocks/MockedContainerBootstrapper.cs @@ -1,7 +1,6 @@ using System.Windows; using System.Windows.Controls; using Prism.Ioc; -using Prism.Logging; using Prism.Unity; using Unity; @@ -10,7 +9,6 @@ namespace Prism.Container.Wpf.Mocks internal class MockedContainerBootstrapper : UnityBootstrapper { private readonly IUnityContainer container; - public ILoggerFacade BaseLogger => base.Logger; public void CallConfigureContainer() { diff --git a/tests/Wpf/Prism.Wpf.Tests/BootstrapperFixture.cs b/tests/Wpf/Prism.Wpf.Tests/BootstrapperFixture.cs index 69be8f5160..3cd57868d0 100644 --- a/tests/Wpf/Prism.Wpf.Tests/BootstrapperFixture.cs +++ b/tests/Wpf/Prism.Wpf.Tests/BootstrapperFixture.cs @@ -5,7 +5,6 @@ using System.Windows.Controls.Primitives; using Xunit; using Moq; -using Prism.Logging; using Prism.Modularity; using Prism.Regions; using Prism.Regions.Behaviors; @@ -21,14 +20,6 @@ namespace Prism.Wpf.Tests public class BootstrapperFixture { - [Fact] - public void LoggerDefaultsToNull() - { - var bootstrapper = new DefaultBootstrapper(); - - Assert.Null(bootstrapper.BaseLogger); - } - [Fact] public void ModuleCatalogDefaultsToNull() { @@ -45,17 +36,6 @@ public void ShellDefaultsToNull() Assert.Null(bootstrapper.BaseShell); } - [Fact] - public void CreateLoggerInitializesLogger() - { - var bootstrapper = new DefaultBootstrapper(); - bootstrapper.CallCreateLogger(); - - Assert.NotNull(bootstrapper.BaseLogger); - - Assert.IsType(bootstrapper.BaseLogger); - } - private static void CreateAndConfigureServiceLocatorForViewModelLocator() { var container = new MockContainerAdapter(); @@ -247,14 +227,6 @@ internal class DefaultBootstrapper : Bootstrapper public IRegionBehaviorFactory DefaultRegionBehaviorTypes; public bool ExtraInitialization; - public ILoggerFacade BaseLogger - { - get - { - return base.Logger; - } - } - public IModuleCatalog BaseModuleCatalog { get { return base.ModuleCatalog; } @@ -267,11 +239,6 @@ public DependencyObject BaseShell set { base.Shell = value; } } - public void CallCreateLogger() - { - this.Logger = base.CreateLogger(); - } - public void CallCreateModuleCatalog() { this.ModuleCatalog = base.CreateModuleCatalog(); diff --git a/tests/Wpf/Prism.Wpf.Tests/Logging/TextLoggerFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Logging/TextLoggerFixture.cs deleted file mode 100644 index bdbca33e5c..0000000000 --- a/tests/Wpf/Prism.Wpf.Tests/Logging/TextLoggerFixture.cs +++ /dev/null @@ -1,52 +0,0 @@ - - -using System; -using System.IO; -using System.Text; -using Xunit; -using Prism.Logging; - -namespace Prism.Wpf.Tests.Logging -{ - - public class TextLoggerFixture - { - [Fact] - public void ShouldWriteToTextWriter() - { - TextWriter writer = new StringWriter(); - ILoggerFacade logger = new TextLogger() { Writer = writer }; - - logger.Log("Test", Category.Debug, Priority.Low); - Assert.Contains("Test", writer.ToString()); - Assert.Contains("DEBUG", writer.ToString()); - Assert.Contains("Low", writer.ToString()); - } - - [Fact] - public void ShouldDisposeWriterOnDispose() - { - MockWriter writer = new MockWriter(); - ILoggerFacade logger = new TextLogger() { Writer = writer }; - - Assert.False(writer.DisposeCalled); - writer.Dispose(); - Assert.True(writer.DisposeCalled); - } - } - - internal class MockWriter : TextWriter - { - public bool DisposeCalled; - public override Encoding Encoding - { - get { throw new NotImplementedException(); } - } - - protected override void Dispose(bool disposing) - { - DisposeCalled = true; - base.Dispose(disposing); - } - } -} \ No newline at end of file diff --git a/tests/Wpf/Prism.Wpf.Tests/Logging/TraceLoggerFixture.Desktop.cs b/tests/Wpf/Prism.Wpf.Tests/Logging/TraceLoggerFixture.Desktop.cs deleted file mode 100644 index 2f06fb6c08..0000000000 --- a/tests/Wpf/Prism.Wpf.Tests/Logging/TraceLoggerFixture.Desktop.cs +++ /dev/null @@ -1,89 +0,0 @@ - - -using System.Diagnostics; -using Xunit; -using Prism.Logging; -using System; - -namespace Prism.Wpf.Tests.Logging -{ - - public class TraceLoggerFixture: IDisposable - { - TraceListener[] existingListeners; - - public TraceLoggerFixture() - { - existingListeners = new TraceListener[Trace.Listeners.Count]; - Trace.Listeners.CopyTo(existingListeners, 0); - Trace.Listeners.Clear(); - } - - [Fact] - public void ShouldWriteToTraceWriter() - { - var listener = new MockTraceListener(); - Trace.Listeners.Add(listener); - - var traceLogger = new TraceLogger(); - traceLogger.Log("Test debug message", Category.Debug, Priority.Low); - - Assert.Equal("Test debug message", listener.LogMessage); - - Trace.Listeners.Remove(listener); - } - - - [Fact] - public void ShouldTraceErrorException() - { - var listener = new MockTraceListener(); - Trace.Listeners.Add(listener); - - var traceLogger = new TraceLogger(); - traceLogger.Log("Test exception message", Category.Exception, Priority.Low); - - Assert.Equal("Test exception message", listener.ErrorMessage); - - Trace.Listeners.Remove(listener); - } - - public void Dispose() - { - Trace.Listeners.AddRange(existingListeners); - } - } - - class MockTraceListener : TraceListener - { - public string LogMessage { get; set; } - public string ErrorMessage { get; set; } - - public override void Write(string message) - { - LogMessage = message; - } - - public override void WriteLine(string message) - { - LogMessage = message; - } - - public override void WriteLine(string message, string category) - { - LogMessage = message; - } - - public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message) - { - if (eventType == TraceEventType.Error) - { - ErrorMessage = message; - } - else - { - LogMessage = message; - } - } - } -} \ No newline at end of file diff --git a/tests/Wpf/Prism.Wpf.Tests/Mocks/MockLogger.cs b/tests/Wpf/Prism.Wpf.Tests/Mocks/MockLogger.cs deleted file mode 100644 index 10836b6a01..0000000000 --- a/tests/Wpf/Prism.Wpf.Tests/Mocks/MockLogger.cs +++ /dev/null @@ -1,17 +0,0 @@ - - -using Prism.Logging; - -namespace Prism.Wpf.Tests.Mocks -{ - internal class MockLogger : ILoggerFacade - { - public string LastMessage; - public Category LastMessageCategory; - public void Log(string message, Category category, Priority priority) - { - LastMessage = message; - LastMessageCategory = category; - } - } -} \ No newline at end of file diff --git a/tests/Wpf/Prism.Wpf.Tests/Modularity/ModuleInitializerFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Modularity/ModuleInitializerFixture.cs index 7137eb5c94..67e87cb3fd 100644 --- a/tests/Wpf/Prism.Wpf.Tests/Modularity/ModuleInitializerFixture.cs +++ b/tests/Wpf/Prism.Wpf.Tests/Modularity/ModuleInitializerFixture.cs @@ -3,7 +3,6 @@ using System.Collections.ObjectModel; using Xunit; using Prism.Ioc; -using Prism.Logging; using Prism.Modularity; using Prism.Wpf.Tests.Mocks; @@ -20,17 +19,7 @@ public void NullContainerThrows() { var ex = Assert.Throws(() => { - ModuleInitializer loader = new ModuleInitializer(null, new MockLogger()); - }); - - } - - [Fact] - public void NullLoggerThrows() - { - var ex = Assert.Throws(() => - { - ModuleInitializer loader = new ModuleInitializer(new MockContainerAdapter(), null); + ModuleInitializer loader = new ModuleInitializer(null); }); } @@ -42,7 +31,7 @@ public void InitializationExceptionsAreWrapped() { var moduleInfo = CreateModuleInfo(typeof(ExceptionThrowingModule)); - ModuleInitializer loader = new ModuleInitializer(new MockContainerAdapter(), new MockLogger()); + ModuleInitializer loader = new ModuleInitializer(new MockContainerAdapter()); loader.Initialize(moduleInfo); }); @@ -54,7 +43,7 @@ public void InitializationExceptionsAreWrapped() public void ShouldResolveModuleAndInitializeSingleModule() { IContainerExtension containerFacade = new MockContainerAdapter(); - var service = new ModuleInitializer(containerFacade, new MockLogger()); + var service = new ModuleInitializer(containerFacade); FirstTestModule.wasInitializedOnce = false; var info = CreateModuleInfo(typeof(FirstTestModule)); service.Initialize(info); @@ -66,8 +55,7 @@ public void ShouldResolveModuleAndInitializeSingleModule() public void ShouldLogModuleInitializeErrorsAndContinueLoading() { IContainerExtension containerFacade = new MockContainerAdapter(); - var logger = new MockLogger(); - var service = new CustomModuleInitializerService(containerFacade, logger); + var service = new CustomModuleInitializerService(containerFacade); var invalidModule = CreateModuleInfo(typeof(InvalidModule)); Assert.False(service.HandleModuleInitializerrorCalled); @@ -79,8 +67,7 @@ public void ShouldLogModuleInitializeErrorsAndContinueLoading() public void ShouldLogModuleInitializationError() { IContainerExtension containerFacade = new MockContainerAdapter(); - var logger = new MockLogger(); - var service = new ModuleInitializer(containerFacade, logger); + var service = new ModuleInitializer(containerFacade); ExceptionThrowingModule.wasInitializedOnce = false; var exceptionModule = CreateModuleInfo(typeof(ExceptionThrowingModule)); @@ -88,12 +75,10 @@ public void ShouldLogModuleInitializationError() { service.Initialize(exceptionModule); } - catch (ModuleInitializeException) + catch (ModuleInitializeException mie) { + Assert.Contains("ExceptionThrowingModule", mie.Message); } - - Assert.NotNull(logger.LastMessage); - Assert.Contains("ExceptionThrowingModule", logger.LastMessage); } [Fact] @@ -101,7 +86,7 @@ public void ShouldThrowExceptionIfBogusType() { var moduleInfo = new ModuleInfo("TestModule", "BadAssembly.BadType"); - ModuleInitializer loader = new ModuleInitializer(new MockContainerAdapter(), new MockLogger()); + ModuleInitializer loader = new ModuleInitializer(new MockContainerAdapter()); try { @@ -219,8 +204,8 @@ public class CustomModuleInitializerService : ModuleInitializer { public bool HandleModuleInitializerrorCalled; - public CustomModuleInitializerService(IContainerExtension containerFacade, ILoggerFacade logger) - : base(containerFacade, logger) + public CustomModuleInitializerService(IContainerExtension containerFacade) + : base(containerFacade) { } diff --git a/tests/Wpf/Prism.Wpf.Tests/Modularity/ModuleManagerFixture.cs b/tests/Wpf/Prism.Wpf.Tests/Modularity/ModuleManagerFixture.cs index a292066499..5f2d6426cb 100644 --- a/tests/Wpf/Prism.Wpf.Tests/Modularity/ModuleManagerFixture.cs +++ b/tests/Wpf/Prism.Wpf.Tests/Modularity/ModuleManagerFixture.cs @@ -4,7 +4,6 @@ using Xunit; using Moq; using Prism.Ioc; -using Prism.Logging; using Prism.Modularity; using Prism.Wpf.Tests.Mocks; @@ -18,7 +17,7 @@ public void NullLoaderThrows() { var ex = Assert.Throws(() => { - new ModuleManager(null, new MockModuleCatalog(), new MockLogger()); + new ModuleManager(null, new MockModuleCatalog()); }); } @@ -28,28 +27,18 @@ public void NullCatalogThrows() { var ex = Assert.Throws(() => { - new ModuleManager(new MockModuleInitializer(), null, new MockLogger()); + new ModuleManager(new MockModuleInitializer(), null); }); } - [Fact] - public void NullLoggerThrows() - { - var ex = Assert.Throws(() => - { - new ModuleManager(new MockModuleInitializer(), new MockModuleCatalog(), null); - }); - - } - [Fact] public void ShouldInvokeRetrieverForModules() { var loader = new MockModuleInitializer(); var moduleInfo = CreateModuleInfo("needsRetrieval", InitializationMode.WhenAvailable); var catalog = new MockModuleCatalog { Modules = { moduleInfo } }; - ModuleManager manager = new ModuleManager(loader, catalog, new MockLogger()); + ModuleManager manager = new ModuleManager(loader, catalog); var moduleTypeLoader = new MockModuleTypeLoader(); manager.ModuleTypeLoaders = new List { moduleTypeLoader }; @@ -64,7 +53,7 @@ public void ShouldInitializeModulesOnRetrievalCompleted() var loader = new MockModuleInitializer(); var backgroungModuleInfo = CreateModuleInfo("NeedsRetrieval", InitializationMode.WhenAvailable); var catalog = new MockModuleCatalog { Modules = { backgroungModuleInfo } }; - ModuleManager manager = new ModuleManager(loader, catalog, new MockLogger()); + ModuleManager manager = new ModuleManager(loader, catalog); var moduleTypeLoader = new MockModuleTypeLoader(); manager.ModuleTypeLoaders = new List { moduleTypeLoader }; Assert.False(loader.InitializeCalled); @@ -82,7 +71,7 @@ public void ShouldInitializeModuleOnDemand() var loader = new MockModuleInitializer(); var onDemandModule = CreateModuleInfo("NeedsRetrieval", InitializationMode.OnDemand); var catalog = new MockModuleCatalog { Modules = { onDemandModule } }; - ModuleManager manager = new ModuleManager(loader, catalog, new MockLogger()); + ModuleManager manager = new ModuleManager(loader, catalog); var moduleRetriever = new MockModuleTypeLoader(); manager.ModuleTypeLoaders = new List { moduleRetriever }; manager.Run(); @@ -107,7 +96,7 @@ public void InvalidOnDemandModuleNameThrows() var catalog = new MockModuleCatalog { Modules = new List { CreateModuleInfo("Missing", InitializationMode.OnDemand) } }; - ModuleManager manager = new ModuleManager(loader, catalog, new MockLogger()); + ModuleManager manager = new ModuleManager(loader, catalog); var moduleTypeLoader = new MockModuleTypeLoader(); manager.ModuleTypeLoaders = new List { moduleTypeLoader }; @@ -127,7 +116,7 @@ public void EmptyOnDemandModuleReturnedThrows() var loader = new MockModuleInitializer(); var catalog = new MockModuleCatalog { CompleteListWithDependencies = modules => new List() }; - ModuleManager manager = new ModuleManager(loader, catalog, new MockLogger()); + ModuleManager manager = new ModuleManager(loader, catalog); var moduleRetriever = new MockModuleTypeLoader(); manager.ModuleTypeLoaders = new List { moduleRetriever }; manager.Run(); @@ -145,7 +134,7 @@ public void ShouldNotLoadTypeIfModuleInitialized() var alreadyPresentModule = CreateModuleInfo(typeof(MockModule), InitializationMode.WhenAvailable); alreadyPresentModule.State = ModuleState.ReadyForInitialization; var catalog = new MockModuleCatalog { Modules = { alreadyPresentModule } }; - var manager = new ModuleManager(loader, catalog, new MockLogger()); + var manager = new ModuleManager(loader, catalog); var moduleTypeLoader = new MockModuleTypeLoader(); manager.ModuleTypeLoaders = new List { moduleTypeLoader }; @@ -163,7 +152,7 @@ public void ShouldNotLoadSameModuleTwice() var loader = new MockModuleInitializer(); var onDemandModule = CreateModuleInfo(typeof(MockModule), InitializationMode.OnDemand); var catalog = new MockModuleCatalog { Modules = { onDemandModule } }; - var manager = new ModuleManager(loader, catalog, new MockLogger()); + var manager = new ModuleManager(loader, catalog); manager.Run(); manager.LoadModule("MockModule"); loader.InitializeCalled = false; @@ -178,7 +167,7 @@ public void ShouldNotLoadModuleThatNeedsRetrievalTwice() var loader = new MockModuleInitializer(); var onDemandModule = CreateModuleInfo("ModuleThatNeedsRetrieval", InitializationMode.OnDemand); var catalog = new MockModuleCatalog { Modules = { onDemandModule } }; - var manager = new ModuleManager(loader, catalog, new MockLogger()); + var manager = new ModuleManager(loader, catalog); var moduleTypeLoader = new MockModuleTypeLoader(); manager.ModuleTypeLoaders = new List { moduleTypeLoader }; manager.Run(); @@ -196,7 +185,7 @@ public void ShouldCallValidateCatalogBeforeGettingGroupsFromCatalog() { var loader = new MockModuleInitializer(); var catalog = new MockModuleCatalog(); - var manager = new ModuleManager(loader, catalog, new MockLogger()); + var manager = new ModuleManager(loader, catalog); bool validateCatalogCalled = false; bool getModulesCalledBeforeValidate = false; @@ -227,7 +216,7 @@ public void ShouldNotInitializeIfDependenciesAreNotMet() var catalog = new MockModuleCatalog { Modules = { requiredModule, dependantModuleInfo } }; catalog.GetDependentModules = m => new[] { requiredModule }; - ModuleManager manager = new ModuleManager(loader, catalog, new MockLogger()); + ModuleManager manager = new ModuleManager(loader, catalog); var moduleTypeLoader = new MockModuleTypeLoader(); manager.ModuleTypeLoaders = new List { moduleTypeLoader }; @@ -256,7 +245,7 @@ public void ShouldInitializeIfDependenciesAreMet() return null; }; - ModuleManager manager = new ModuleManager(initializer, catalog, new MockLogger()); + ModuleManager manager = new ModuleManager(initializer, catalog); var moduleTypeLoader = new MockModuleTypeLoader(); manager.ModuleTypeLoaders = new List { moduleTypeLoader }; @@ -272,7 +261,7 @@ public void ShouldThrowOnRetrieverErrorAndWrapException() var loader = new MockModuleInitializer(); var moduleInfo = CreateModuleInfo("NeedsRetrieval", InitializationMode.WhenAvailable); var catalog = new MockModuleCatalog { Modules = { moduleInfo } }; - ModuleManager manager = new ModuleManager(loader, catalog, new MockLogger()); + ModuleManager manager = new ModuleManager(loader, catalog); var moduleTypeLoader = new MockModuleTypeLoader(); Exception retrieverException = new Exception(); @@ -305,7 +294,7 @@ public void ShouldThrowIfNoRetrieverCanRetrieveModule() var loader = new MockModuleInitializer(); var catalog = new MockModuleCatalog { Modules = { CreateModuleInfo("ModuleThatNeedsRetrieval", InitializationMode.WhenAvailable) } }; - ModuleManager manager = new ModuleManager(loader, catalog, new MockLogger()) + ModuleManager manager = new ModuleManager(loader, catalog) { ModuleTypeLoaders = new List { new MockModuleTypeLoader() { canLoadModuleTypeReturnValue = false } } }; @@ -314,34 +303,6 @@ public void ShouldThrowIfNoRetrieverCanRetrieveModule() } - [Fact] - public void ShouldLogMessageOnModuleRetrievalError() - { - var loader = new MockModuleInitializer(); - var moduleInfo = CreateModuleInfo("ModuleThatNeedsRetrieval", InitializationMode.WhenAvailable); - var catalog = new MockModuleCatalog { Modules = { moduleInfo } }; - var logger = new MockLogger(); - ModuleManager manager = new ModuleManager(loader, catalog, logger); - var moduleTypeLoader = new MockModuleTypeLoader - { - LoadCompletedError = new Exception() - }; - manager.ModuleTypeLoaders = new List { moduleTypeLoader }; - - try - { - manager.Run(); - } - catch - { - // Ignore all errors to make sure logger is called even if errors thrown. - } - - Assert.NotNull(logger.LastMessage); - Assert.Contains("ModuleThatNeedsRetrieval", logger.LastMessage); - Assert.Equal(Category.Exception, logger.LastMessageCategory); - } - [Fact] public void ShouldWorkIfModuleLoadsAnotherOnDemandModuleWhenInitializing() { @@ -350,7 +311,7 @@ public void ShouldWorkIfModuleLoadsAnotherOnDemandModuleWhenInitializing() onDemandModule.ModuleName = "OnDemandModule"; var moduleThatLoadsOtherModule = CreateModuleInfo(typeof(MockModule), InitializationMode.WhenAvailable); var catalog = new MockModuleCatalog { Modules = { moduleThatLoadsOtherModule, onDemandModule } }; - ModuleManager manager = new ModuleManager(initializer, catalog, new MockLogger()); + ModuleManager manager = new ModuleManager(initializer, catalog); bool onDemandModuleWasInitialized = false; initializer.Initialize = m => @@ -377,7 +338,7 @@ public void ModuleManagerIsDisposable() Mock mockInit = new Mock(); var moduleInfo = CreateModuleInfo("needsRetrieval", InitializationMode.WhenAvailable); var catalog = new Mock(); - ModuleManager manager = new ModuleManager(mockInit.Object, catalog.Object, new MockLogger()); + ModuleManager manager = new ModuleManager(mockInit.Object, catalog.Object); IDisposable disposableManager = manager as IDisposable; Assert.NotNull(disposableManager); @@ -389,7 +350,7 @@ public void DisposeDoesNotThrowWithNonDisposableTypeLoaders() Mock mockInit = new Mock(); var moduleInfo = CreateModuleInfo("needsRetrieval", InitializationMode.WhenAvailable); var catalog = new Mock(); - ModuleManager manager = new ModuleManager(mockInit.Object, catalog.Object, new MockLogger()); + ModuleManager manager = new ModuleManager(mockInit.Object, catalog.Object); var mockTypeLoader = new Mock(); manager.ModuleTypeLoaders = new List {mockTypeLoader.Object}; @@ -410,7 +371,7 @@ public void DisposeCleansUpDisposableTypeLoaders() Mock mockInit = new Mock(); var moduleInfo = CreateModuleInfo("needsRetrieval", InitializationMode.WhenAvailable); var catalog = new Mock(); - ModuleManager manager = new ModuleManager(mockInit.Object, catalog.Object, new MockLogger()); + ModuleManager manager = new ModuleManager(mockInit.Object, catalog.Object); var mockTypeLoader = new Mock(); var disposableMockTypeLoader = mockTypeLoader.As(); @@ -429,7 +390,7 @@ public void DisposeDoesNotThrowWithMixedTypeLoaders() Mock mockInit = new Mock(); var moduleInfo = CreateModuleInfo("needsRetrieval", InitializationMode.WhenAvailable); var catalog = new Mock(); - ModuleManager manager = new ModuleManager(mockInit.Object, catalog.Object, new MockLogger()); + ModuleManager manager = new ModuleManager(mockInit.Object, catalog.Object); var mockTypeLoader1 = new Mock(); diff --git a/tests/Wpf/Prism.Wpf.Tests/PrismApplicationBaseFixture.cs b/tests/Wpf/Prism.Wpf.Tests/PrismApplicationBaseFixture.cs index 55f8290d47..806eb49fa1 100644 --- a/tests/Wpf/Prism.Wpf.Tests/PrismApplicationBaseFixture.cs +++ b/tests/Wpf/Prism.Wpf.Tests/PrismApplicationBaseFixture.cs @@ -1,7 +1,6 @@ using Moq; using Prism.Events; using Prism.Ioc; -using Prism.Logging; using Prism.Modularity; using Prism.Regions; using Prism.Regions.Behaviors; @@ -194,7 +193,6 @@ public void RequiredTypesAreRegistered() { application.MockContainer.Verify(x => x.RegisterInstance(typeof(IModuleCatalog), It.IsAny()), Times.Once); - application.MockContainer.Verify(x => x.RegisterSingleton(typeof(ILoggerFacade), It.IsAny()), Times.Once); application.MockContainer.Verify(x => x.RegisterSingleton(typeof(IDialogService), typeof(DialogService)), Times.Once); application.MockContainer.Verify(x => x.RegisterSingleton(typeof(IModuleInitializer), typeof(ModuleInitializer)), Times.Once); application.MockContainer.Verify(x => x.RegisterSingleton(typeof(IModuleManager), typeof(ModuleManager)), Times.Once); @@ -292,12 +290,9 @@ protected override void RegisterRequiredTypes(IContainerRegistry containerRegist base.RegisterRequiredTypes(containerRegistry); - var logger = new TextLogger(); - MockContainer.Setup(x => x.Resolve(typeof(ILoggerFacade))).Returns(logger); - - var moduleInitializer = new ModuleInitializer(MockContainer.Object, logger); + var moduleInitializer = new ModuleInitializer(MockContainer.Object); MockContainer.Setup(x => x.Resolve(typeof(IModuleInitializer))).Returns(moduleInitializer); - MockContainer.Setup(x => x.Resolve(typeof(IModuleManager))).Returns(new ModuleManager(moduleInitializer, DefaultModuleCatalog, logger)); + MockContainer.Setup(x => x.Resolve(typeof(IModuleManager))).Returns(new ModuleManager(moduleInitializer, DefaultModuleCatalog)); MockContainer.Setup(x => x.Resolve(typeof(IRegionBehaviorFactory))).Returns(new RegionBehaviorFactory(MockContainer.Object)); var regionBehaviorFactory = new RegionBehaviorFactory(MockContainer.Object); diff --git a/tests/Wpf/Prism.Wpf.Tests/PrismBootstapperBaseFixture.cs b/tests/Wpf/Prism.Wpf.Tests/PrismBootstapperBaseFixture.cs index c25c74b815..dc8174c953 100644 --- a/tests/Wpf/Prism.Wpf.Tests/PrismBootstapperBaseFixture.cs +++ b/tests/Wpf/Prism.Wpf.Tests/PrismBootstapperBaseFixture.cs @@ -1,7 +1,6 @@ using Moq; using Prism.Events; using Prism.Ioc; -using Prism.Logging; using Prism.Modularity; using Prism.Regions; using Prism.Regions.Behaviors; @@ -193,7 +192,6 @@ public void RequiredTypesAreRegistered() { bootstrapper.MockContainer.Verify(x => x.RegisterInstance(typeof(IModuleCatalog), It.IsAny()), Times.Once); - bootstrapper.MockContainer.Verify(x => x.RegisterSingleton(typeof(ILoggerFacade), It.IsAny()), Times.Once); bootstrapper.MockContainer.Verify(x => x.RegisterSingleton(typeof(IDialogService), typeof(DialogService)), Times.Once); bootstrapper.MockContainer.Verify(x => x.RegisterSingleton(typeof(IModuleInitializer), typeof(ModuleInitializer)), Times.Once); bootstrapper.MockContainer.Verify(x => x.RegisterSingleton(typeof(IModuleManager), typeof(ModuleManager)), Times.Once); @@ -286,12 +284,9 @@ protected override void RegisterRequiredTypes(IContainerRegistry containerRegist base.RegisterRequiredTypes(containerRegistry); - var logger = new TextLogger(); - MockContainer.Setup(x => x.Resolve(typeof(ILoggerFacade))).Returns(logger); - - var moduleInitializer = new ModuleInitializer(MockContainer.Object, logger); + var moduleInitializer = new ModuleInitializer(MockContainer.Object); MockContainer.Setup(x => x.Resolve(typeof(IModuleInitializer))).Returns(moduleInitializer); - MockContainer.Setup(x => x.Resolve(typeof(IModuleManager))).Returns(new ModuleManager(moduleInitializer, DefaultModuleCatalog, logger)); + MockContainer.Setup(x => x.Resolve(typeof(IModuleManager))).Returns(new ModuleManager(moduleInitializer, DefaultModuleCatalog)); MockContainer.Setup(x => x.Resolve(typeof(IRegionBehaviorFactory))).Returns(new RegionBehaviorFactory(MockContainer.Object)); var regionBehaviorFactory = new RegionBehaviorFactory(MockContainer.Object); From 48c2533cd8bab5f8f3ef9eaec6fce30418a70f92 Mon Sep 17 00:00:00 2001 From: Dan Siegel Date: Sat, 22 Aug 2020 10:45:01 -0700 Subject: [PATCH 2/3] fixing xml docs --- .../Ioc/RegionNavigationRegistrationExtensions.cs | 2 +- .../Behaviors/BindRegionContextToVisualElementBehavior.cs | 2 +- .../Regions/Behaviors/RegionManagerRegistrationBehavior.cs | 2 +- src/Wpf/Prism.Wpf/Interactivity/CommandBehaviorBase.cs | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Forms/Prism.Forms.Regions/Ioc/RegionNavigationRegistrationExtensions.cs b/src/Forms/Prism.Forms.Regions/Ioc/RegionNavigationRegistrationExtensions.cs index f76f3c6d18..a02634cf6b 100644 --- a/src/Forms/Prism.Forms.Regions/Ioc/RegionNavigationRegistrationExtensions.cs +++ b/src/Forms/Prism.Forms.Regions/Ioc/RegionNavigationRegistrationExtensions.cs @@ -29,7 +29,7 @@ public static void RegisterForRegionNavigation(this IContainerRegistry co /// /// Registers a for region navigation. /// - /// The Type of + /// The Type of to register /// The ViewModel to use as the BindingContext for the View /// The unique name to register with the View /// diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs b/src/Forms/Prism.Forms.Regions/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs index 3677204365..e84320712d 100644 --- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs +++ b/src/Forms/Prism.Forms.Regions/Regions/Behaviors/BindRegionContextToVisualElementBehavior.cs @@ -7,7 +7,7 @@ namespace Prism.Regions.Behaviors { /// - /// Defines a behavior that forwards the + /// Defines a behavior that forwards the /// to the views in the region. /// public class BindRegionContextToVisualElementBehavior : IRegionBehavior diff --git a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionManagerRegistrationBehavior.cs b/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionManagerRegistrationBehavior.cs index 043850686f..28e5538187 100644 --- a/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionManagerRegistrationBehavior.cs +++ b/src/Forms/Prism.Forms.Regions/Regions/Behaviors/RegionManagerRegistrationBehavior.cs @@ -8,7 +8,7 @@ namespace Prism.Regions.Behaviors /// /// Subscribes to a static event from the in order to register the target /// in a when one is available on the host control by walking up the tree and finding - /// a control whose property is not . + /// a control whose property is not . /// public class RegionManagerRegistrationBehavior : RegionBehavior, IHostAwareRegionBehavior { diff --git a/src/Wpf/Prism.Wpf/Interactivity/CommandBehaviorBase.cs b/src/Wpf/Prism.Wpf/Interactivity/CommandBehaviorBase.cs index 967907b4ce..73452e9cbb 100644 --- a/src/Wpf/Prism.Wpf/Interactivity/CommandBehaviorBase.cs +++ b/src/Wpf/Prism.Wpf/Interactivity/CommandBehaviorBase.cs @@ -6,12 +6,13 @@ using Windows.UI.Xaml.Controls; #else using System.Windows; +using System.Windows.Controls; #endif namespace Prism.Interactivity { /// - /// Base behavior to handle connecting a to a Command. + /// Base behavior to handle connecting a to a Command. /// /// The target object must derive from Control. /// From f1bf6ca8fd9b44e0b1846a2cabb54b26e3f094c2 Mon Sep 17 00:00:00 2001 From: Dan Siegel Date: Sat, 22 Aug 2020 11:31:00 -0700 Subject: [PATCH 3/3] add missing shared test project --- PrismLibrary.sln | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PrismLibrary.sln b/PrismLibrary.sln index 29c4cefefd..73b5c70de9 100644 --- a/PrismLibrary.sln +++ b/PrismLibrary.sln @@ -84,6 +84,8 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Prism.Ioc.Shared", "tests\C EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Containers", "Containers", "{D62DD517-CA80-449D-A26B-9AB427379825}" EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Prism.Container.Wpf.Shared", "tests\Wpf\Prism.Container.Wpf.Shared\Prism.Container.Wpf.Shared.shproj", "{BD42A7D6-A84D-4D27-9C28-7F6A2EC477F1}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{02e0ecaa-b8c6-4eab-a9ab-164b1b99af35}*SharedItemsImports = 5 @@ -99,6 +101,7 @@ Global src\Containers\Prism.Unity.Shared\Prism.Unity.Shared.projitems*{9a1c368f-30ae-4c82-be03-9168ce089b56}*SharedItemsImports = 5 src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{aad8a958-546b-4b7d-bbd1-d79e825530eb}*SharedItemsImports = 5 tests\Wpf\Prism.Container.Wpf.Shared\Prism.Container.Wpf.Shared.projitems*{ba05687e-2317-4a65-805b-c596f52f7203}*SharedItemsImports = 5 + tests\Wpf\Prism.Container.Wpf.Shared\Prism.Container.Wpf.Shared.projitems*{bd42a7d6-a84d-4d27-9c28-7f6a2ec477f1}*SharedItemsImports = 13 src\Containers\Prism.Unity.Shared\Prism.Unity.Shared.projitems*{c2f58215-92f0-4501-a9f4-862c78b2b4ce}*SharedItemsImports = 5 tests\Forms\Prism.DI.Forms.Tests\Prism.DI.Forms.Tests.projitems*{c2ff8459-f2d1-4b87-a31a-82a1835f89cf}*SharedItemsImports = 5 src\Containers\Prism.Unity.Shared\Prism.Unity.Shared.projitems*{d66336a6-07e5-401a-a710-daedd6975d59}*SharedItemsImports = 13 @@ -416,6 +419,7 @@ Global {704E14A4-C3A2-492D-9C4E-7D386A18B698} = {D62DD517-CA80-449D-A26B-9AB427379825} {78932299-2281-4A59-BFB8-07DE3014F748} = {D62DD517-CA80-449D-A26B-9AB427379825} {D62DD517-CA80-449D-A26B-9AB427379825} = {00FFDC13-7397-46F1-897E-A62A7575D28A} + {BD42A7D6-A84D-4D27-9C28-7F6A2EC477F1} = {F1F91777-01EA-43A3-A3ED-D473B382F46C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C7433AE2-B1A0-4C1A-887E-5CAA7AAF67A6}