SEBWIN-220: Finally renamed RuntimeInfo to AppConfig.

This commit is contained in:
dbuechel 2018-06-29 09:50:20 +02:00
parent 27d2907d12
commit 9a12bbdb7d
33 changed files with 227 additions and 228 deletions

View file

@ -24,11 +24,11 @@ namespace SafeExamBrowser.Browser
{
public class BrowserApplicationController : IBrowserApplicationController
{
private AppConfig appConfig;
private IApplicationButton button;
private IList<IApplicationInstance> instances;
private ILogger logger;
private IMessageBox messageBox;
private RuntimeInfo runtimeInfo;
private BrowserSettings settings;
private IText text;
private IUserInterfaceFactory uiFactory;
@ -36,17 +36,17 @@ namespace SafeExamBrowser.Browser
public event DownloadRequestedEventHandler ConfigurationDownloadRequested;
public BrowserApplicationController(
AppConfig appConfig,
BrowserSettings settings,
RuntimeInfo runtimeInfo,
ILogger logger,
IMessageBox messageBox,
IText text,
IUserInterfaceFactory uiFactory)
{
this.appConfig = appConfig;
this.instances = new List<IApplicationInstance>();
this.logger = logger;
this.messageBox = messageBox;
this.runtimeInfo = runtimeInfo;
this.settings = settings;
this.text = text;
this.uiFactory = uiFactory;
@ -82,7 +82,7 @@ namespace SafeExamBrowser.Browser
private void CreateNewInstance()
{
var instance = new BrowserApplicationInstance(settings, runtimeInfo, text, uiFactory, instances.Count == 0);
var instance = new BrowserApplicationInstance(appConfig, settings, text, uiFactory, instances.Count == 0);
instance.Initialize();
instance.ConfigurationDownloadRequested += (fileName, args) => ConfigurationDownloadRequested?.Invoke(fileName, args);
@ -97,8 +97,8 @@ namespace SafeExamBrowser.Browser
{
var cefSettings = new CefSettings
{
CachePath = runtimeInfo.BrowserCachePath,
LogFile = runtimeInfo.BrowserLogFile,
CachePath = appConfig.BrowserCachePath,
LogFile = appConfig.BrowserLogFile,
// TODO: Set according to current application LogLevel, but avoid verbose!
LogSeverity = LogSeverity.Info
};

View file

@ -20,10 +20,10 @@ namespace SafeExamBrowser.Browser
{
internal class BrowserApplicationInstance : IApplicationInstance
{
private AppConfig appConfig;
private IBrowserControl control;
private IBrowserWindow window;
private bool isMainInstance;
private RuntimeInfo runtimeInfo;
private BrowserSettings settings;
private IText text;
private IUserInterfaceFactory uiFactory;
@ -37,14 +37,14 @@ namespace SafeExamBrowser.Browser
public event TerminatedEventHandler Terminated;
public BrowserApplicationInstance(
AppConfig appConfig,
BrowserSettings settings,
RuntimeInfo runtimeInfo,
IText text,
IUserInterfaceFactory uiFactory,
bool isMainInstance)
{
this.appConfig = appConfig;
this.isMainInstance = isMainInstance;
this.runtimeInfo = runtimeInfo;
this.settings = settings;
this.text = text;
this.uiFactory = uiFactory;
@ -52,7 +52,7 @@ namespace SafeExamBrowser.Browser
internal void Initialize()
{
var downloadHandler = new DownloadHandler(settings, runtimeInfo);
var downloadHandler = new DownloadHandler(appConfig, settings);
Id = Guid.NewGuid();
downloadHandler.ConfigurationDownloadRequested += (fileName, args) => ConfigurationDownloadRequested?.Invoke(fileName, args);

View file

@ -22,24 +22,24 @@ namespace SafeExamBrowser.Browser.Handlers
/// </remarks>
internal class DownloadHandler : IDownloadHandler
{
private AppConfig appConfig;
private BrowserSettings settings;
private RuntimeInfo runtimeInfo;
private ConcurrentDictionary<int, DownloadFinishedCallback> callbacks;
public event DownloadRequestedEventHandler ConfigurationDownloadRequested;
public DownloadHandler(BrowserSettings settings, RuntimeInfo runtimeInfo)
public DownloadHandler(AppConfig appConfig, BrowserSettings settings)
{
this.appConfig = appConfig;
this.callbacks = new ConcurrentDictionary<int, DownloadFinishedCallback>();
this.settings = settings;
this.runtimeInfo = runtimeInfo;
}
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
{
var uri = new Uri(downloadItem.Url);
var extension = Path.GetExtension(uri.AbsolutePath);
var isConfigFile = String.Equals(extension, runtimeInfo.ConfigurationFileExtension, StringComparison.InvariantCultureIgnoreCase);
var isConfigFile = String.Equals(extension, appConfig.ConfigurationFileExtension, StringComparison.InvariantCultureIgnoreCase);
if (isConfigFile)
{

View file

@ -18,14 +18,14 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
[TestClass]
public class AboutNotificationControllerTests
{
private Mock<RuntimeInfo> runtimeInfoMock;
private Mock<IUserInterfaceFactory> uiFactoryMock;
private Mock<AppConfig> appConfig;
private Mock<IUserInterfaceFactory> uiFactory;
[TestInitialize]
public void Initialize()
{
runtimeInfoMock = new Mock<RuntimeInfo>();
uiFactoryMock = new Mock<IUserInterfaceFactory>();
appConfig = new Mock<AppConfig>();
uiFactory = new Mock<IUserInterfaceFactory>();
}
[TestMethod]
@ -33,9 +33,9 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
{
var button = new NotificationButtonMock();
var window = new Mock<IWindow>();
var sut = new AboutNotificationController(runtimeInfoMock.Object, uiFactoryMock.Object);
var sut = new AboutNotificationController(appConfig.Object, uiFactory.Object);
uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny<RuntimeInfo>())).Returns(window.Object);
uiFactory.Setup(u => u.CreateAboutWindow(It.IsAny<AppConfig>())).Returns(window.Object);
sut.RegisterNotification(button);
button.Click();
sut.Terminate();
@ -48,9 +48,9 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
{
var button = new NotificationButtonMock();
var window = new Mock<IWindow>();
var sut = new AboutNotificationController(runtimeInfoMock.Object, uiFactoryMock.Object);
var sut = new AboutNotificationController(appConfig.Object, uiFactory.Object);
uiFactoryMock.Setup(u => u.CreateAboutWindow(It.IsAny<RuntimeInfo>())).Returns(window.Object);
uiFactory.Setup(u => u.CreateAboutWindow(It.IsAny<AppConfig>())).Returns(window.Object);
sut.RegisterNotification(button);
button.Click();
button.Click();
@ -58,7 +58,7 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
button.Click();
button.Click();
uiFactoryMock.Verify(u => u.CreateAboutWindow(It.IsAny<RuntimeInfo>()), Times.Once);
uiFactory.Verify(u => u.CreateAboutWindow(It.IsAny<AppConfig>()), Times.Once);
window.Verify(u => u.Show(), Times.Once);
window.Verify(u => u.BringToForeground(), Times.Exactly(4));
}
@ -67,7 +67,7 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
public void MustSubscribeToClickEvent()
{
var button = new NotificationButtonMock();
var sut = new AboutNotificationController(runtimeInfoMock.Object, uiFactoryMock.Object);
var sut = new AboutNotificationController(appConfig.Object, uiFactory.Object);
sut.RegisterNotification(button);

View file

@ -39,22 +39,22 @@ namespace SafeExamBrowser.Client.Behaviour
private ITaskbar taskbar;
private IUserInterfaceFactory uiFactory;
private IWindowMonitor windowMonitor;
private RuntimeInfo runtimeInfo;
private AppConfig appConfig;
public IBrowserApplicationController Browser { private get; set; }
public IClientHost ClientHost { private get; set; }
public Guid SessionId { private get; set; }
public Settings Settings { private get; set; }
public RuntimeInfo RuntimeInfo
public AppConfig AppConfig
{
set
{
runtimeInfo = value;
appConfig = value;
if (splashScreen != null)
{
splashScreen.RuntimeInfo = value;
splashScreen.AppConfig = value;
}
}
}
@ -204,7 +204,7 @@ namespace SafeExamBrowser.Client.Behaviour
{
args.AllowDownload = true;
args.Callback = Browser_ConfigurationDownloadFinished;
args.DownloadPath = Path.Combine(runtimeInfo.DownloadDirectory, fileName);
args.DownloadPath = Path.Combine(appConfig.DownloadDirectory, fileName);
}
}
else

View file

@ -40,13 +40,13 @@ namespace SafeExamBrowser.Client.Behaviour.Operations
{
var config = runtime.GetConfiguration();
configuration.RuntimeInfo = config.RuntimeInfo;
configuration.AppConfig = config.AppConfig;
configuration.SessionId = config.SessionId;
configuration.Settings = config.Settings;
logger.Info("Successfully retrieved the application configuration from the runtime.");
logger.Info($" -> Client-ID: {configuration.RuntimeInfo.ClientId}");
logger.Info($" -> Runtime-ID: {configuration.RuntimeInfo.RuntimeId}");
logger.Info($" -> Client-ID: {configuration.AppConfig.ClientId}");
logger.Info($" -> Runtime-ID: {configuration.AppConfig.RuntimeId}");
logger.Info($" -> Session-ID: {configuration.SessionId}");
}
catch (Exception e)

View file

@ -152,7 +152,7 @@ namespace SafeExamBrowser.Client
private IOperation BuildBrowserOperation()
{
var moduleLogger = new ModuleLogger(logger, typeof(BrowserApplicationController));
var browserController = new BrowserApplicationController(configuration.Settings.Browser, configuration.RuntimeInfo, moduleLogger, messageBox, text, uiFactory);
var browserController = new BrowserApplicationController(configuration.AppConfig, configuration.Settings.Browser, moduleLogger, messageBox, text, uiFactory);
var browserInfo = new BrowserApplicationInfo();
var operation = new BrowserOperation(browserController, browserInfo, logger, Taskbar, uiFactory);
@ -165,7 +165,7 @@ namespace SafeExamBrowser.Client
{
var processId = Process.GetCurrentProcess().Id;
var factory = new HostObjectFactory();
var host = new ClientHost(configuration.RuntimeInfo.ClientAddress, factory, new ModuleLogger(logger, typeof(ClientHost)), processId);
var host = new ClientHost(configuration.AppConfig.ClientAddress, factory, new ModuleLogger(logger, typeof(ClientHost)), processId);
var operation = new CommunicationOperation(host, logger);
clientHost = host;
@ -204,9 +204,9 @@ namespace SafeExamBrowser.Client
private void UpdateClientControllerDependencies()
{
ClientController.AppConfig = configuration.AppConfig;
ClientController.Browser = browserController;
ClientController.ClientHost = clientHost;
ClientController.RuntimeInfo = configuration.RuntimeInfo;
ClientController.SessionId = configuration.SessionId;
ClientController.Settings = configuration.Settings;
}

View file

@ -17,13 +17,13 @@ namespace SafeExamBrowser.Client.Notifications
internal class AboutNotificationController : INotificationController
{
private INotificationButton notification;
private RuntimeInfo runtimeInfo;
private AppConfig appConfig;
private IUserInterfaceFactory uiFactory;
private IWindow window;
public AboutNotificationController(RuntimeInfo runtimeInfo, IUserInterfaceFactory uiFactory)
public AboutNotificationController(AppConfig appConfig, IUserInterfaceFactory uiFactory)
{
this.runtimeInfo = runtimeInfo;
this.appConfig = appConfig;
this.uiFactory = uiFactory;
}
@ -43,7 +43,7 @@ namespace SafeExamBrowser.Client.Notifications
{
if (window == null)
{
window = uiFactory.CreateAboutWindow(runtimeInfo);
window = uiFactory.CreateAboutWindow(appConfig);
window.Closing += () => window = null;
window.Show();

View file

@ -19,22 +19,22 @@ namespace SafeExamBrowser.Configuration
private const string BASE_ADDRESS = "net.pipe://localhost/safeexambrowser";
private bool firstSession = true;
private RuntimeInfo runtimeInfo;
private AppConfig appConfig;
public ISessionData CurrentSession { get; private set; }
public Settings CurrentSettings { get; private set; }
public string ReconfigurationFilePath { get; set; }
public RuntimeInfo RuntimeInfo
public AppConfig AppConfig
{
get
{
if (runtimeInfo == null)
if (appConfig == null)
{
InitializeRuntimeInfo();
InitializeAppConfig();
}
return runtimeInfo;
return appConfig;
}
}
@ -42,7 +42,7 @@ namespace SafeExamBrowser.Configuration
{
return new ClientConfiguration
{
RuntimeInfo = RuntimeInfo,
AppConfig = AppConfig,
SessionId = CurrentSession.Id,
Settings = CurrentSettings
};
@ -58,7 +58,7 @@ namespace SafeExamBrowser.Configuration
if (!firstSession)
{
UpdateRuntimeInfo();
UpdateAppConfig();
}
else
{
@ -96,7 +96,7 @@ namespace SafeExamBrowser.Configuration
CurrentSettings.Taskbar.AllowWirelessNetwork = true;
}
private void InitializeRuntimeInfo()
private void InitializeAppConfig()
{
var appDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(SafeExamBrowser));
var executable = Assembly.GetEntryAssembly();
@ -104,32 +104,32 @@ namespace SafeExamBrowser.Configuration
var logFolder = Path.Combine(appDataFolder, "Logs");
var logFilePrefix = startTime.ToString("yyyy-MM-dd\\_HH\\hmm\\mss\\s");
runtimeInfo = new RuntimeInfo();
runtimeInfo.ApplicationStartTime = startTime;
runtimeInfo.AppDataFolder = appDataFolder;
runtimeInfo.BrowserCachePath = Path.Combine(appDataFolder, "Cache");
runtimeInfo.BrowserLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Browser.txt");
runtimeInfo.ClientId = Guid.NewGuid();
runtimeInfo.ClientAddress = $"{BASE_ADDRESS}/client/{Guid.NewGuid()}";
runtimeInfo.ClientExecutablePath = Path.Combine(Path.GetDirectoryName(executable.Location), $"{nameof(SafeExamBrowser)}.Client.exe");
runtimeInfo.ClientLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Client.txt");
runtimeInfo.ConfigurationFileExtension = ".seb";
runtimeInfo.DefaultSettingsFileName = "SebClientSettings.seb";
runtimeInfo.DownloadDirectory = Path.Combine(appDataFolder, "Downloads");
runtimeInfo.ProgramCopyright = executable.GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright;
runtimeInfo.ProgramDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), nameof(SafeExamBrowser));
runtimeInfo.ProgramTitle = executable.GetCustomAttribute<AssemblyTitleAttribute>().Title;
runtimeInfo.ProgramVersion = executable.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
runtimeInfo.RuntimeId = Guid.NewGuid();
runtimeInfo.RuntimeAddress = $"{BASE_ADDRESS}/runtime/{Guid.NewGuid()}";
runtimeInfo.RuntimeLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Runtime.txt");
runtimeInfo.ServiceAddress = $"{BASE_ADDRESS}/service";
appConfig = new AppConfig();
appConfig.ApplicationStartTime = startTime;
appConfig.AppDataFolder = appDataFolder;
appConfig.BrowserCachePath = Path.Combine(appDataFolder, "Cache");
appConfig.BrowserLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Browser.txt");
appConfig.ClientId = Guid.NewGuid();
appConfig.ClientAddress = $"{BASE_ADDRESS}/client/{Guid.NewGuid()}";
appConfig.ClientExecutablePath = Path.Combine(Path.GetDirectoryName(executable.Location), $"{nameof(SafeExamBrowser)}.Client.exe");
appConfig.ClientLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Client.txt");
appConfig.ConfigurationFileExtension = ".seb";
appConfig.DefaultSettingsFileName = "SebClientSettings.seb";
appConfig.DownloadDirectory = Path.Combine(appDataFolder, "Downloads");
appConfig.ProgramCopyright = executable.GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright;
appConfig.ProgramDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), nameof(SafeExamBrowser));
appConfig.ProgramTitle = executable.GetCustomAttribute<AssemblyTitleAttribute>().Title;
appConfig.ProgramVersion = executable.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
appConfig.RuntimeId = Guid.NewGuid();
appConfig.RuntimeAddress = $"{BASE_ADDRESS}/runtime/{Guid.NewGuid()}";
appConfig.RuntimeLogFile = Path.Combine(logFolder, $"{logFilePrefix}_Runtime.txt");
appConfig.ServiceAddress = $"{BASE_ADDRESS}/service";
}
private void UpdateRuntimeInfo()
private void UpdateAppConfig()
{
RuntimeInfo.ClientId = Guid.NewGuid();
RuntimeInfo.ClientAddress = $"{BASE_ADDRESS}/client/{Guid.NewGuid()}";
AppConfig.ClientId = Guid.NewGuid();
AppConfig.ClientAddress = $"{BASE_ADDRESS}/client/{Guid.NewGuid()}";
}
}
}

View file

@ -19,6 +19,11 @@ namespace SafeExamBrowser.Contracts.Behaviour
/// </summary>
public interface IClientController
{
/// <summary>
/// The global configuration information to be used during application execution.
/// </summary>
AppConfig AppConfig { set; }
/// <summary>
/// The controller for the browser application.
/// </summary>
@ -29,11 +34,6 @@ namespace SafeExamBrowser.Contracts.Behaviour
/// </summary>
IClientHost ClientHost { set; }
/// <summary>
/// The runtime information to be used during application execution.
/// </summary>
RuntimeInfo RuntimeInfo { set; }
/// <summary>
/// The session identifier of the currently running session.
/// </summary>

View file

@ -9,7 +9,7 @@
namespace SafeExamBrowser.Contracts.Browser
{
/// <summary>
/// TODO
/// The event arguments used for all download events fired by the <see cref="IBrowserApplicationController"/>.
/// </summary>
public class DownloadEventArgs
{

View file

@ -12,10 +12,9 @@ namespace SafeExamBrowser.Contracts.Configuration
{
/// <summary>
/// Defines the fundamental, global configuration information for all application components.
/// TODO: Rename to Globals or GlobalConfiguration or alike!
/// </summary>
[Serializable]
public class RuntimeInfo
public class AppConfig
{
/// <summary>
/// The path of the application data folder.

View file

@ -16,6 +16,11 @@ namespace SafeExamBrowser.Contracts.Configuration
[Serializable]
public class ClientConfiguration
{
/// <summary>
/// The global application configuration.
/// </summary>
public AppConfig AppConfig { get; set; }
/// <summary>
/// The unique identifier for the current session.
/// </summary>
@ -25,10 +30,5 @@ namespace SafeExamBrowser.Contracts.Configuration
/// The application settings to be used by the client.
/// </summary>
public Settings.Settings Settings { get; set; }
/// <summary>
/// The information about the current runtime.
/// </summary>
public RuntimeInfo RuntimeInfo { get; set; }
}
}

View file

@ -15,6 +15,11 @@ namespace SafeExamBrowser.Contracts.Configuration
/// </summary>
public interface IConfigurationRepository
{
/// <summary>
/// The global configuration information for the currently running application instance.
/// </summary>
AppConfig AppConfig { get; }
/// <summary>
/// Retrieves the current session data, i.e. the last one which was initialized. If no session has been initialized yet, this
/// property will be <c>null</c>!
@ -32,11 +37,6 @@ namespace SafeExamBrowser.Contracts.Configuration
/// </summary>
string ReconfigurationFilePath { get; set; }
/// <summary>
/// The runtime information for the currently running application instance.
/// </summary>
RuntimeInfo RuntimeInfo { get; }
/// <summary>
/// Builds a configuration for the client component, given the currently loaded settings, session and runtime information.
/// </summary>

View file

@ -96,7 +96,7 @@
<Compile Include="Configuration\ClientConfiguration.cs" />
<Compile Include="Configuration\IResourceLoader.cs" />
<Compile Include="Configuration\LoadStatus.cs" />
<Compile Include="Configuration\RuntimeInfo.cs" />
<Compile Include="Configuration\AppConfig.cs" />
<Compile Include="Configuration\ISessionData.cs" />
<Compile Include="Configuration\Settings\ConfigurationMode.cs" />
<Compile Include="Behaviour\INotificationController.cs" />

View file

@ -25,7 +25,7 @@ namespace SafeExamBrowser.Contracts.UserInterface
/// <summary>
/// Creates a new about window displaying information about the currently running application version.
/// </summary>
IWindow CreateAboutWindow(RuntimeInfo runtimeInfo);
IWindow CreateAboutWindow(AppConfig appConfig);
/// <summary>
/// Creates a taskbar button, initialized with the given application information.
@ -66,12 +66,12 @@ namespace SafeExamBrowser.Contracts.UserInterface
/// Creates a new runtime window which runs on its own thread.
/// </summary>
/// <returns></returns>
IRuntimeWindow CreateRuntimeWindow(RuntimeInfo runtimeInfo);
IRuntimeWindow CreateRuntimeWindow(AppConfig appConfig);
/// <summary>
/// Creates a new splash screen which runs on its own thread.
/// </summary>
ISplashScreen CreateSplashScreen(RuntimeInfo runtimeInfo = null);
ISplashScreen CreateSplashScreen(AppConfig appConfig = null);
/// <summary>
/// Creates a system control which allows to change the wireless network connection of the computer.

View file

@ -16,8 +16,8 @@ namespace SafeExamBrowser.Contracts.UserInterface.Windows
public interface ISplashScreen : IProgressIndicator, IWindow
{
/// <summary>
/// The runtime information used to display version and copyright information. Can be updated during the execution of a procedure.
/// The global configuration used to display version and copyright information. Can be updated during the execution of a procedure.
/// </summary>
RuntimeInfo RuntimeInfo { set; }
AppConfig AppConfig { set; }
}
}

View file

@ -25,6 +25,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
{
private Action clientReady;
private Action terminated;
private AppConfig appConfig;
private Mock<IConfigurationRepository> configuration;
private Mock<IClientProxy> proxy;
private Mock<ILogger> logger;
@ -32,13 +33,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
private Mock<IProcessFactory> processFactory;
private Mock<IProxyFactory> proxyFactory;
private Mock<IRuntimeHost> runtimeHost;
private RuntimeInfo runtimeInfo;
private Mock<ISessionData> session;
private ClientOperation sut;
[TestInitialize]
public void Initialize()
{
appConfig = new AppConfig();
configuration = new Mock<IConfigurationRepository>();
clientReady = new Action(() => runtimeHost.Raise(h => h.ClientReady += null));
logger = new Mock<ILogger>();
@ -47,7 +48,6 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
proxy = new Mock<IClientProxy>();
proxyFactory = new Mock<IProxyFactory>();
runtimeHost = new Mock<IRuntimeHost>();
runtimeInfo = new RuntimeInfo();
session = new Mock<ISessionData>();
terminated = new Action(() =>
{
@ -56,7 +56,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
});
configuration.SetupGet(c => c.CurrentSession).Returns(session.Object);
configuration.SetupGet(c => c.RuntimeInfo).Returns(runtimeInfo);
configuration.SetupGet(c => c.AppConfig).Returns(appConfig);
proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny<string>())).Returns(proxy.Object);
sut = new ClientOperation(configuration.Object, logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, 0);

View file

@ -22,6 +22,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
public class ClientTerminationOperationTests
{
private Action clientReady;
private AppConfig appConfig;
private Mock<IConfigurationRepository> configuration;
private Mock<IClientProxy> proxy;
private Mock<ILogger> logger;
@ -29,13 +30,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
private Mock<IProcessFactory> processFactory;
private Mock<IProxyFactory> proxyFactory;
private Mock<IRuntimeHost> runtimeHost;
private RuntimeInfo runtimeInfo;
private Mock<ISessionData> session;
private ClientTerminationOperation sut;
[TestInitialize]
public void Initialize()
{
appConfig = new AppConfig();
configuration = new Mock<IConfigurationRepository>();
clientReady = new Action(() => runtimeHost.Raise(h => h.ClientReady += null));
logger = new Mock<ILogger>();
@ -44,11 +45,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
proxy = new Mock<IClientProxy>();
proxyFactory = new Mock<IProxyFactory>();
runtimeHost = new Mock<IRuntimeHost>();
runtimeInfo = new RuntimeInfo();
session = new Mock<ISessionData>();
configuration.SetupGet(c => c.CurrentSession).Returns(session.Object);
configuration.SetupGet(c => c.RuntimeInfo).Returns(runtimeInfo);
configuration.SetupGet(c => c.AppConfig).Returns(appConfig);
proxyFactory.Setup(f => f.CreateClientProxy(It.IsAny<string>())).Returns(proxy.Object);
sut = new ClientTerminationOperation(configuration.Object, logger.Object, processFactory.Object, proxyFactory.Object, runtimeHost.Object, 0);

View file

@ -29,13 +29,13 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
[TestClass]
public class ConfigurationOperationTests
{
private AppConfig appConfig;
private Mock<ILogger> logger;
private Mock<IMessageBox> messageBox;
private Mock<IPasswordDialog> passwordDialog;
private Mock<IConfigurationRepository> repository;
private Mock<IResourceLoader> resourceLoader;
private Mock<IRuntimeHost> runtimeHost;
private RuntimeInfo runtimeInfo;
private Settings settings;
private Mock<IText> text;
private Mock<IUserInterfaceFactory> uiFactory;
@ -44,22 +44,22 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
[TestInitialize]
public void Initialize()
{
appConfig = new AppConfig();
logger = new Mock<ILogger>();
messageBox = new Mock<IMessageBox>();
passwordDialog = new Mock<IPasswordDialog>();
repository = new Mock<IConfigurationRepository>();
resourceLoader = new Mock<IResourceLoader>();
runtimeHost = new Mock<IRuntimeHost>();
runtimeInfo = new RuntimeInfo();
settings = new Settings();
text = new Mock<IText>();
uiFactory = new Mock<IUserInterfaceFactory>();
repository.SetupGet(r => r.CurrentSettings).Returns(settings);
appConfig.AppDataFolder = @"C:\Not\Really\AppData";
appConfig.DefaultSettingsFileName = "SettingsDummy.txt";
appConfig.ProgramDataFolder = @"C:\Not\Really\ProgramData";
runtimeInfo.AppDataFolder = @"C:\Not\Really\AppData";
runtimeInfo.DefaultSettingsFileName = "SettingsDummy.txt";
runtimeInfo.ProgramDataFolder = @"C:\Not\Really\ProgramData";
repository.SetupGet(r => r.CurrentSettings).Returns(settings);
uiFactory.Setup(f => f.CreatePasswordDialog(It.IsAny<string>(), It.IsAny<string>())).Returns(passwordDialog.Object);
}
@ -70,12 +70,12 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
var url = @"http://www.safeexambrowser.org/whatever.seb";
var location = Path.GetDirectoryName(GetType().Assembly.Location);
runtimeInfo.ProgramDataFolder = location;
runtimeInfo.AppDataFolder = location;
appConfig.ProgramDataFolder = location;
appConfig.AppDataFolder = location;
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.Success);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut.Perform();
var resource = new Uri(url);
@ -88,12 +88,12 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
{
var location = Path.GetDirectoryName(GetType().Assembly.Location);
runtimeInfo.ProgramDataFolder = location;
runtimeInfo.AppDataFolder = $@"{location}\WRONG";
appConfig.ProgramDataFolder = location;
appConfig.AppDataFolder = $@"{location}\WRONG";
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.Success);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null);
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null);
sut.Perform();
var resource = new Uri(Path.Combine(location, "SettingsDummy.txt"));
@ -106,11 +106,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
{
var location = Path.GetDirectoryName(GetType().Assembly.Location);
runtimeInfo.AppDataFolder = location;
appConfig.AppDataFolder = location;
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.Success);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null);
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null);
sut.Perform();
var resource = new Uri(Path.Combine(location, "SettingsDummy.txt"));
@ -121,7 +121,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
[TestMethod]
public void MustFallbackToDefaultsAsLastPrio()
{
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null);
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null);
sut.Perform();
repository.Verify(r => r.LoadDefaultSettings(), Times.Once);
@ -130,11 +130,11 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
[TestMethod]
public void MustAbortIfWishedByUser()
{
runtimeInfo.ProgramDataFolder = Path.GetDirectoryName(GetType().Assembly.Location);
appConfig.ProgramDataFolder = Path.GetDirectoryName(GetType().Assembly.Location);
messageBox.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>())).Returns(MessageBoxResult.Yes);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.Success);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null);
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null);
var result = sut.Perform();
@ -147,7 +147,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
messageBox.Setup(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>())).Returns(MessageBoxResult.No);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.Success);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null);
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null);
var result = sut.Perform();
@ -160,7 +160,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
settings.ConfigurationMode = ConfigurationMode.Exam;
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.Success);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null);
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null);
sut.Perform();
messageBox.Verify(m => m.Show(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageBoxAction>(), It.IsAny<MessageBoxIcon>()), Times.Never);
@ -171,10 +171,10 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
{
repository.Setup(r => r.LoadDefaultSettings());
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null);
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null);
sut.Perform();
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new string[] { });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new string[] { });
sut.Perform();
repository.Verify(r => r.LoadDefaultSettings(), Times.Exactly(2));
@ -185,7 +185,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
{
var uri = @"an/invalid\uri.'*%yolo/()你好";
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", uri });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", uri });
sut.Perform();
}
@ -198,7 +198,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
passwordDialog.Setup(d => d.Show(null)).Returns(result);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.AdminPasswordNeeded);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut.Perform();
repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Exactly(5));
@ -213,7 +213,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
passwordDialog.Setup(d => d.Show(null)).Returns(result);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.SettingsPasswordNeeded);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut.Perform();
repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Exactly(5));
@ -230,7 +230,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.AdminPasswordNeeded);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), password, null)).Returns(LoadStatus.Success);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut.Perform();
repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Once);
@ -248,7 +248,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.SettingsPasswordNeeded);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, password)).Returns(LoadStatus.Success);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut.Perform();
repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Once);
@ -264,7 +264,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
passwordDialog.Setup(d => d.Show(null)).Returns(dialogResult);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.AdminPasswordNeeded);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
var result = sut.Perform();
@ -280,7 +280,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
passwordDialog.Setup(d => d.Show(null)).Returns(dialogResult);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.SettingsPasswordNeeded);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
var result = sut.Perform();
@ -302,7 +302,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, settingsPassword)).Returns(LoadStatus.AdminPasswordNeeded).Callback(adminCallback);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), adminPassword, settingsPassword)).Returns(LoadStatus.Success);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut.Perform();
repository.Verify(r => r.LoadSettings(It.IsAny<Uri>(), null, null), Times.Once);
@ -323,7 +323,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
session.SetupGet(r => r.ClientProxy).Returns(clientProxy.Object);
settings.KioskMode = KioskMode.DisableExplorerShell;
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut.Perform();
clientProxy.Verify(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>()), Times.Never);
@ -349,7 +349,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
session.SetupGet(r => r.ClientProxy).Returns(clientProxy.Object);
settings.KioskMode = KioskMode.CreateNewDesktop;
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut.Perform();
clientProxy.Verify(c => c.RequestPassword(It.IsAny<PasswordRequestPurpose>(), It.IsAny<Guid>()), Times.AtLeastOnce);
@ -375,7 +375,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
session.SetupGet(r => r.ClientProxy).Returns(clientProxy.Object);
settings.KioskMode = KioskMode.CreateNewDesktop;
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
var result = sut.Perform();
@ -390,7 +390,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
resourceLoader.Setup(r => r.IsHtmlResource(It.IsAny<Uri>())).Returns(false);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.InvalidData);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
var result = sut.Perform();
@ -405,7 +405,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
resourceLoader.Setup(r => r.IsHtmlResource(It.IsAny<Uri>())).Returns(true);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.InvalidData);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, new[] { "blubb.exe", url });
var result = sut.Perform();
@ -422,7 +422,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
repository.SetupGet(r => r.ReconfigurationFilePath).Returns(resource.AbsolutePath);
repository.Setup(r => r.LoadSettings(It.Is<Uri>(u => u.Equals(resource)), null, null)).Returns(LoadStatus.Success);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null);
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null);
var result = sut.Repeat();
@ -439,7 +439,7 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
repository.SetupGet(r => r.ReconfigurationFilePath).Returns(null as string);
repository.Setup(r => r.LoadSettings(It.IsAny<Uri>(), null, null)).Returns(LoadStatus.Success);
sut = new ConfigurationOperation(repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, runtimeInfo, text.Object, uiFactory.Object, null);
sut = new ConfigurationOperation(appConfig, repository.Object, logger.Object, messageBox.Object, resourceLoader.Object, runtimeHost.Object, text.Object, uiFactory.Object, null);
var result = sut.Repeat();

View file

@ -19,24 +19,24 @@ namespace SafeExamBrowser.Runtime.UnitTests.Behaviour.Operations
[TestClass]
public class SessionInitializationOperationTests
{
private SessionInitializationOperation sut;
private AppConfig appConfig;
private Mock<IConfigurationRepository> configuration;
private Mock<ILogger> logger;
private Mock<IRuntimeHost> runtimeHost;
private RuntimeInfo runtimeInfo;
private Mock<ISessionData> session;
private SessionInitializationOperation sut;
[TestInitialize]
public void Initialize()
{
appConfig = new AppConfig();
configuration = new Mock<IConfigurationRepository>();
logger = new Mock<ILogger>();
runtimeHost = new Mock<IRuntimeHost>();
runtimeInfo = new RuntimeInfo();
session = new Mock<ISessionData>();
configuration.SetupGet(c => c.CurrentSession).Returns(session.Object);
configuration.SetupGet(c => c.RuntimeInfo).Returns(runtimeInfo);
configuration.SetupGet(c => c.AppConfig).Returns(appConfig);
sut = new SessionInitializationOperation(configuration.Object, logger.Object, runtimeHost.Object);
}

View file

@ -87,9 +87,9 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
var clientReadyEvent = new AutoResetEvent(false);
var clientReadyEventHandler = new CommunicationEventHandler(() => clientReadyEvent.Set());
var clientExecutable = configuration.RuntimeInfo.ClientExecutablePath;
var clientLogFile = $"{'"' + configuration.RuntimeInfo.ClientLogFile + '"'}";
var hostUri = configuration.RuntimeInfo.RuntimeAddress;
var clientExecutable = configuration.AppConfig.ClientExecutablePath;
var clientLogFile = $"{'"' + configuration.AppConfig.ClientLogFile + '"'}";
var hostUri = configuration.AppConfig.RuntimeAddress;
var token = configuration.CurrentSession.StartupToken.ToString("D");
logger.Info("Starting new client process...");
@ -108,7 +108,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
}
logger.Info("Client has been successfully started and initialized. Creating communication proxy for client host...");
ClientProxy = proxyFactory.CreateClientProxy(configuration.RuntimeInfo.ClientAddress);
ClientProxy = proxyFactory.CreateClientProxy(configuration.AppConfig.ClientAddress);
if (!ClientProxy.Connect(configuration.CurrentSession.StartupToken))
{

View file

@ -24,12 +24,12 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
{
internal class ConfigurationOperation : IOperation
{
private IConfigurationRepository repository;
private IConfigurationRepository configuration;
private ILogger logger;
private IMessageBox messageBox;
private IResourceLoader resourceLoader;
private IRuntimeHost runtimeHost;
private RuntimeInfo runtimeInfo;
private AppConfig appConfig;
private IText text;
private IUserInterfaceFactory uiFactory;
private string[] commandLineArgs;
@ -37,22 +37,22 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
public IProgressIndicator ProgressIndicator { private get; set; }
public ConfigurationOperation(
IConfigurationRepository repository,
AppConfig appConfig,
IConfigurationRepository configuration,
ILogger logger,
IMessageBox messageBox,
IResourceLoader resourceLoader,
IRuntimeHost runtimeHost,
RuntimeInfo runtimeInfo,
IText text,
IUserInterfaceFactory uiFactory,
string[] commandLineArgs)
{
this.repository = repository;
this.appConfig = appConfig;
this.logger = logger;
this.messageBox = messageBox;
this.configuration = configuration;
this.resourceLoader = resourceLoader;
this.runtimeHost = runtimeHost;
this.runtimeInfo = runtimeInfo;
this.text = text;
this.uiFactory = uiFactory;
this.commandLineArgs = commandLineArgs;
@ -78,7 +78,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
}
logger.Info("No valid settings resource specified nor found in PROGRAMDATA or APPDATA - loading default settings...");
repository.LoadDefaultSettings();
configuration.LoadDefaultSettings();
return OperationResult.Success;
}
@ -88,7 +88,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
logger.Info("Initializing new application configuration...");
ProgressIndicator?.UpdateText(TextKey.ProgressIndicator_InitializeConfiguration);
var isValidUri = TryValidateSettingsUri(repository.ReconfigurationFilePath, out Uri uri);
var isValidUri = TryValidateSettingsUri(configuration.ReconfigurationFilePath, out Uri uri);
if (isValidUri)
{
@ -119,7 +119,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
for (int adminAttempts = 0, settingsAttempts = 0; adminAttempts < 5 && settingsAttempts < 5;)
{
status = repository.LoadSettings(uri, adminPassword, settingsPassword);
status = configuration.LoadSettings(uri, adminPassword, settingsPassword);
if (status == LoadStatus.AdminPasswordNeeded || status == LoadStatus.SettingsPasswordNeeded)
{
@ -152,8 +152,8 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
private bool TryGetPassword(PasswordRequestPurpose purpose, out string password)
{
var isStartup = repository.CurrentSession == null;
var isRunningOnDefaultDesktop = repository.CurrentSettings?.KioskMode == KioskMode.DisableExplorerShell;
var isStartup = configuration.CurrentSession == null;
var isRunningOnDefaultDesktop = configuration.CurrentSettings?.KioskMode == KioskMode.DisableExplorerShell;
if (isStartup || isRunningOnDefaultDesktop)
{
@ -200,7 +200,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
});
runtimeHost.PasswordReceived += responseEventHandler;
repository.CurrentSession.ClientProxy.RequestPassword(purpose, requestId);
configuration.CurrentSession.ClientProxy.RequestPassword(purpose, requestId);
responseEvent.WaitOne();
runtimeHost.PasswordReceived -= responseEventHandler;
@ -220,8 +220,8 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
{
if (resourceLoader.IsHtmlResource(uri))
{
repository.LoadDefaultSettings();
repository.CurrentSettings.Browser.StartUrl = uri.AbsoluteUri;
configuration.LoadDefaultSettings();
configuration.CurrentSettings.Browser.StartUrl = uri.AbsoluteUri;
logger.Info($"The specified URI '{uri.AbsoluteUri}' appears to point to a HTML resource, setting it as startup URL.");
status = LoadStatus.Success;
@ -236,8 +236,8 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
{
var path = string.Empty;
var isValidUri = false;
var programDataSettings = Path.Combine(runtimeInfo.ProgramDataFolder, runtimeInfo.DefaultSettingsFileName);
var appDataSettings = Path.Combine(runtimeInfo.AppDataFolder, runtimeInfo.DefaultSettingsFileName);
var programDataSettings = Path.Combine(appConfig.ProgramDataFolder, appConfig.DefaultSettingsFileName);
var appDataSettings = Path.Combine(appConfig.AppDataFolder, appConfig.DefaultSettingsFileName);
uri = null;
@ -277,7 +277,7 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
private void HandleClientConfiguration(ref OperationResult result)
{
if (result == OperationResult.Success && repository.CurrentSettings.ConfigurationMode == ConfigurationMode.ConfigureClient)
if (result == OperationResult.Success && configuration.CurrentSettings.ConfigurationMode == ConfigurationMode.ConfigureClient)
{
var abort = IsConfigurationSufficient();

View file

@ -57,8 +57,8 @@ namespace SafeExamBrowser.Runtime.Behaviour.Operations
configuration.InitializeSessionConfiguration();
runtimeHost.StartupToken = configuration.CurrentSession.StartupToken;
logger.Info($" -> Client-ID: {configuration.RuntimeInfo.ClientId}");
logger.Info($" -> Runtime-ID: {configuration.RuntimeInfo.RuntimeId} (as reference, does not change)");
logger.Info($" -> Client-ID: {configuration.AppConfig.ClientId}");
logger.Info($" -> Runtime-ID: {configuration.AppConfig.RuntimeId} (as reference, does not change)");
logger.Info($" -> Session-ID: {configuration.CurrentSession.Id}");
}
}

View file

@ -26,13 +26,13 @@ namespace SafeExamBrowser.Runtime.Behaviour
{
private bool sessionRunning;
private AppConfig appConfig;
private IConfigurationRepository configuration;
private ILogger logger;
private IMessageBox messageBox;
private IOperationSequence bootstrapSequence;
private IOperationSequence sessionSequence;
private IRuntimeHost runtimeHost;
private RuntimeInfo runtimeInfo;
private IRuntimeWindow runtimeWindow;
private IServiceProxy service;
private ISplashScreen splashScreen;
@ -40,23 +40,23 @@ namespace SafeExamBrowser.Runtime.Behaviour
private IUserInterfaceFactory uiFactory;
public RuntimeController(
AppConfig appConfig,
IConfigurationRepository configuration,
ILogger logger,
IMessageBox messageBox,
IOperationSequence bootstrapSequence,
IOperationSequence sessionSequence,
IRuntimeHost runtimeHost,
RuntimeInfo runtimeInfo,
IServiceProxy service,
Action shutdown,
IUserInterfaceFactory uiFactory)
{
this.appConfig = appConfig;
this.configuration = configuration;
this.bootstrapSequence = bootstrapSequence;
this.logger = logger;
this.messageBox = messageBox;
this.runtimeHost = runtimeHost;
this.runtimeInfo = runtimeInfo;
this.sessionSequence = sessionSequence;
this.service = service;
this.shutdown = shutdown;
@ -67,8 +67,8 @@ namespace SafeExamBrowser.Runtime.Behaviour
{
logger.Info("--- Initiating startup procedure ---");
runtimeWindow = uiFactory.CreateRuntimeWindow(runtimeInfo);
splashScreen = uiFactory.CreateSplashScreen(runtimeInfo);
runtimeWindow = uiFactory.CreateRuntimeWindow(appConfig);
splashScreen = uiFactory.CreateSplashScreen(appConfig);
bootstrapSequence.ProgressIndicator = splashScreen;
sessionSequence.ProgressIndicator = runtimeWindow;

View file

@ -28,8 +28,8 @@ namespace SafeExamBrowser.Runtime
{
internal class CompositionRoot
{
private AppConfig appConfig;
private ILogger logger;
private RuntimeInfo runtimeInfo;
private ISystemInfo systemInfo;
internal IRuntimeController RuntimeController { get; private set; }
@ -43,7 +43,7 @@ namespace SafeExamBrowser.Runtime
var nativeMethods = new NativeMethods();
logger = new Logger();
runtimeInfo = configuration.RuntimeInfo;
appConfig = configuration.AppConfig;
systemInfo = new SystemInfo();
InitializeLogging();
@ -55,8 +55,8 @@ namespace SafeExamBrowser.Runtime
var processFactory = new ProcessFactory(desktop, new ModuleLogger(logger, typeof(ProcessFactory)));
var proxyFactory = new ProxyFactory(new ProxyObjectFactory(), logger);
var resourceLoader = new ResourceLoader();
var runtimeHost = new RuntimeHost(runtimeInfo.RuntimeAddress, configuration, new HostObjectFactory(), new ModuleLogger(logger, typeof(RuntimeHost)));
var serviceProxy = new ServiceProxy(runtimeInfo.ServiceAddress, new ProxyObjectFactory(), new ModuleLogger(logger, typeof(ServiceProxy)));
var runtimeHost = new RuntimeHost(appConfig.RuntimeAddress, configuration, new HostObjectFactory(), new ModuleLogger(logger, typeof(RuntimeHost)));
var serviceProxy = new ServiceProxy(appConfig.ServiceAddress, new ProxyObjectFactory(), new ModuleLogger(logger, typeof(ServiceProxy)));
var bootstrapOperations = new Queue<IOperation>();
var sessionOperations = new Queue<IOperation>();
@ -64,7 +64,7 @@ namespace SafeExamBrowser.Runtime
bootstrapOperations.Enqueue(new I18nOperation(logger, text));
bootstrapOperations.Enqueue(new CommunicationOperation(runtimeHost, logger));
sessionOperations.Enqueue(new ConfigurationOperation(configuration, logger, messageBox, resourceLoader, runtimeHost, runtimeInfo, text, uiFactory, args));
sessionOperations.Enqueue(new ConfigurationOperation(appConfig, configuration, logger, messageBox, resourceLoader, runtimeHost, text, uiFactory, args));
sessionOperations.Enqueue(new SessionInitializationOperation(configuration, logger, runtimeHost));
sessionOperations.Enqueue(new ServiceOperation(configuration, logger, serviceProxy, text));
sessionOperations.Enqueue(new ClientTerminationOperation(configuration, logger, processFactory, proxyFactory, runtimeHost, TEN_SECONDS));
@ -74,19 +74,19 @@ namespace SafeExamBrowser.Runtime
var bootstrapSequence = new OperationSequence(logger, bootstrapOperations);
var sessionSequence = new OperationSequence(logger, sessionOperations);
RuntimeController = new RuntimeController(configuration, logger, messageBox, bootstrapSequence, sessionSequence, runtimeHost, runtimeInfo, serviceProxy, shutdown, uiFactory);
RuntimeController = new RuntimeController(appConfig, configuration, logger, messageBox, bootstrapSequence, sessionSequence, runtimeHost, serviceProxy, shutdown, uiFactory);
}
internal void LogStartupInformation()
{
logger.Log($"/* {runtimeInfo.ProgramTitle}, Version {runtimeInfo.ProgramVersion}");
logger.Log($"/* {runtimeInfo.ProgramCopyright}");
logger.Log($"/* {appConfig.ProgramTitle}, Version {appConfig.ProgramVersion}");
logger.Log($"/* {appConfig.ProgramCopyright}");
logger.Log($"/* ");
logger.Log($"/* Please visit https://www.github.com/SafeExamBrowser for more information.");
logger.Log(string.Empty);
logger.Log($"# Application started at {runtimeInfo.ApplicationStartTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}");
logger.Log($"# Application started at {appConfig.ApplicationStartTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}");
logger.Log($"# Running on {systemInfo.OperatingSystemInfo}");
logger.Log($"# Runtime-ID: {runtimeInfo.RuntimeId}");
logger.Log($"# Runtime-ID: {appConfig.RuntimeId}");
logger.Log(string.Empty);
}
@ -97,7 +97,7 @@ namespace SafeExamBrowser.Runtime
private void InitializeLogging()
{
var logFileWriter = new LogFileWriter(new DefaultLogFormatter(), runtimeInfo.RuntimeLogFile);
var logFileWriter = new LogFileWriter(new DefaultLogFormatter(), appConfig.RuntimeLogFile);
logFileWriter.Initialize();
logger.Subscribe(logFileWriter);

View file

@ -16,7 +16,7 @@ namespace SafeExamBrowser.UserInterface.Classic
{
public partial class AboutWindow : Window, IWindow
{
private RuntimeInfo runtimeInfo;
private AppConfig appConfig;
private IText text;
private WindowClosingEventHandler closing;
@ -26,9 +26,9 @@ namespace SafeExamBrowser.UserInterface.Classic
remove { closing -= value; }
}
public AboutWindow(RuntimeInfo runtimeInfo, IText text)
public AboutWindow(AppConfig appConfig, IText text)
{
this.runtimeInfo = runtimeInfo;
this.appConfig = appConfig;
this.text = text;
InitializeComponent();
@ -43,10 +43,10 @@ namespace SafeExamBrowser.UserInterface.Classic
private void InitializeAboutWindow()
{
Closing += (o, args) => closing?.Invoke();
VersionInfo.Inlines.Add(new Run($"{text.Get(TextKey.Version)} {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic });
VersionInfo.Inlines.Add(new Run($"{text.Get(TextKey.Version)} {appConfig.ProgramVersion}") { FontStyle = FontStyles.Italic });
VersionInfo.Inlines.Add(new LineBreak());
VersionInfo.Inlines.Add(new LineBreak());
VersionInfo.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 });
VersionInfo.Inlines.Add(new Run(appConfig.ProgramCopyright) { FontSize = 10 });
}
}
}

View file

@ -20,8 +20,8 @@ namespace SafeExamBrowser.UserInterface.Classic
public partial class RuntimeWindow : Window, IRuntimeWindow
{
private bool allowClose;
private AppConfig appConfig;
private ILogContentFormatter formatter;
private RuntimeInfo runtimeInfo;
private IText text;
private RuntimeWindowViewModel model;
private WindowClosingEventHandler closing;
@ -38,10 +38,10 @@ namespace SafeExamBrowser.UserInterface.Classic
remove { closing -= value; }
}
public RuntimeWindow(ILogContentFormatter formatter, RuntimeInfo runtimeInfo, IText text)
public RuntimeWindow(AppConfig appConfig, ILogContentFormatter formatter, IText text)
{
this.appConfig = appConfig;
this.formatter = formatter;
this.runtimeInfo = runtimeInfo;
this.text = text;
InitializeComponent();
@ -129,12 +129,12 @@ namespace SafeExamBrowser.UserInterface.Classic
private void InitializeRuntimeWindow()
{
Title = $"{runtimeInfo.ProgramTitle} - Version {runtimeInfo.ProgramVersion}";
Title = $"{appConfig.ProgramTitle} - Version {appConfig.ProgramVersion}";
InfoTextBlock.Inlines.Add(new Run($"Version {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic });
InfoTextBlock.Inlines.Add(new Run($"Version {appConfig.ProgramVersion}") { FontStyle = FontStyles.Italic });
InfoTextBlock.Inlines.Add(new LineBreak());
InfoTextBlock.Inlines.Add(new LineBreak());
InfoTextBlock.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 });
InfoTextBlock.Inlines.Add(new Run(appConfig.ProgramCopyright) { FontSize = 10 });
model = new RuntimeWindowViewModel();
AnimatedBorder.DataContext = model;

View file

@ -19,18 +19,18 @@ namespace SafeExamBrowser.UserInterface.Classic
{
private bool allowClose;
private ProgressIndicatorViewModel model = new ProgressIndicatorViewModel();
private RuntimeInfo runtimeInfo;
private AppConfig appConfig;
private IText text;
private WindowClosingEventHandler closing;
public RuntimeInfo RuntimeInfo
public AppConfig AppConfig
{
set
{
Dispatcher.Invoke(() =>
{
runtimeInfo = value;
UpdateRuntimeInfo();
appConfig = value;
UpdateAppInfo();
});
}
}
@ -41,9 +41,9 @@ namespace SafeExamBrowser.UserInterface.Classic
remove { closing -= value; }
}
public SplashScreen(IText text, RuntimeInfo runtimeInfo = null)
public SplashScreen(IText text, AppConfig appConfig = null)
{
this.runtimeInfo = runtimeInfo;
this.appConfig = appConfig;
this.text = text;
InitializeComponent();
@ -112,7 +112,7 @@ namespace SafeExamBrowser.UserInterface.Classic
private void InitializeSplashScreen()
{
UpdateRuntimeInfo();
UpdateAppInfo();
StatusTextBlock.DataContext = model;
ProgressBar.DataContext = model;
@ -123,14 +123,14 @@ namespace SafeExamBrowser.UserInterface.Classic
Closing += (o, args) => args.Cancel = !allowClose;
}
private void UpdateRuntimeInfo()
private void UpdateAppInfo()
{
if (runtimeInfo != null)
if (appConfig != null)
{
InfoTextBlock.Inlines.Add(new Run($"Version {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic });
InfoTextBlock.Inlines.Add(new Run($"Version {appConfig.ProgramVersion}") { FontStyle = FontStyles.Italic });
InfoTextBlock.Inlines.Add(new LineBreak());
InfoTextBlock.Inlines.Add(new LineBreak());
InfoTextBlock.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 });
InfoTextBlock.Inlines.Add(new Run(appConfig.ProgramCopyright) { FontSize = 10 });
}
}
}

View file

@ -29,9 +29,9 @@ namespace SafeExamBrowser.UserInterface.Classic
this.text = text;
}
public IWindow CreateAboutWindow(RuntimeInfo runtimeInfo)
public IWindow CreateAboutWindow(AppConfig appConfig)
{
return new AboutWindow(runtimeInfo, text);
return new AboutWindow(appConfig, text);
}
public IApplicationButton CreateApplicationButton(IApplicationInfo info)
@ -89,13 +89,13 @@ namespace SafeExamBrowser.UserInterface.Classic
return new PowerSupplyControl();
}
public IRuntimeWindow CreateRuntimeWindow(RuntimeInfo runtimeInfo)
public IRuntimeWindow CreateRuntimeWindow(AppConfig appConfig)
{
RuntimeWindow runtimeWindow = null;
var windowReadyEvent = new AutoResetEvent(false);
var runtimeWindowThread = new Thread(() =>
{
runtimeWindow = new RuntimeWindow(new RuntimeWindowLogFormatter(), runtimeInfo, text);
runtimeWindow = new RuntimeWindow(appConfig, new RuntimeWindowLogFormatter(), text);
runtimeWindow.Closed += (o, args) => runtimeWindow.Dispatcher.InvokeShutdown();
windowReadyEvent.Set();
@ -113,13 +113,13 @@ namespace SafeExamBrowser.UserInterface.Classic
return runtimeWindow;
}
public ISplashScreen CreateSplashScreen(RuntimeInfo runtimeInfo = null)
public ISplashScreen CreateSplashScreen(AppConfig appConfig = null)
{
SplashScreen splashScreen = null;
var splashReadyEvent = new AutoResetEvent(false);
var splashScreenThread = new Thread(() =>
{
splashScreen = new SplashScreen(text, runtimeInfo);
splashScreen = new SplashScreen(text, appConfig);
splashScreen.Closed += (o, args) => splashScreen.Dispatcher.InvokeShutdown();
splashScreen.Show();

View file

@ -16,7 +16,7 @@ namespace SafeExamBrowser.UserInterface.Windows10
{
public partial class AboutWindow : Window, IWindow
{
private RuntimeInfo runtimeInfo;
private AppConfig appConfig;
private IText text;
private WindowClosingEventHandler closing;
@ -26,9 +26,9 @@ namespace SafeExamBrowser.UserInterface.Windows10
remove { closing -= value; }
}
public AboutWindow(RuntimeInfo runtimeInfo, IText text)
public AboutWindow(AppConfig appConfig, IText text)
{
this.runtimeInfo = runtimeInfo;
this.appConfig = appConfig;
this.text = text;
InitializeComponent();
@ -43,10 +43,10 @@ namespace SafeExamBrowser.UserInterface.Windows10
private void InitializeAboutWindow()
{
Closing += (o, args) => closing?.Invoke();
VersionInfo.Inlines.Add(new Run($"{text.Get(TextKey.Version)} {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic });
VersionInfo.Inlines.Add(new Run($"{text.Get(TextKey.Version)} {appConfig.ProgramVersion}") { FontStyle = FontStyles.Italic });
VersionInfo.Inlines.Add(new LineBreak());
VersionInfo.Inlines.Add(new LineBreak());
VersionInfo.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 });
VersionInfo.Inlines.Add(new Run(appConfig.ProgramCopyright) { FontSize = 10 });
}
}
}

View file

@ -19,18 +19,18 @@ namespace SafeExamBrowser.UserInterface.Windows10
{
private bool allowClose;
private SplashScreenViewModel model = new SplashScreenViewModel();
private RuntimeInfo runtimeInfo;
private AppConfig appConfig;
private IText text;
private WindowClosingEventHandler closing;
public RuntimeInfo RuntimeInfo
public AppConfig AppConfig
{
set
{
Dispatcher.Invoke(() =>
{
runtimeInfo = value;
UpdateRuntimeInfo();
appConfig = value;
UpdateAppInfo();
});
}
}
@ -41,9 +41,9 @@ namespace SafeExamBrowser.UserInterface.Windows10
remove { closing -= value; }
}
public SplashScreen(IText text, RuntimeInfo runtimeInfo = null)
public SplashScreen(IText text, AppConfig appConfig = null)
{
this.runtimeInfo = runtimeInfo;
this.appConfig = appConfig;
this.text = text;
InitializeComponent();
@ -112,7 +112,7 @@ namespace SafeExamBrowser.UserInterface.Windows10
private void InitializeSplashScreen()
{
UpdateRuntimeInfo();
UpdateAppInfo();
StatusTextBlock.DataContext = model;
ProgressBar.DataContext = model;
@ -123,14 +123,14 @@ namespace SafeExamBrowser.UserInterface.Windows10
Closing += (o, args) => args.Cancel = !allowClose;
}
private void UpdateRuntimeInfo()
private void UpdateAppInfo()
{
if (runtimeInfo != null)
if (appConfig != null)
{
InfoTextBlock.Inlines.Add(new Run($"Version {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic });
InfoTextBlock.Inlines.Add(new Run($"Version {appConfig.ProgramVersion}") { FontStyle = FontStyles.Italic });
InfoTextBlock.Inlines.Add(new LineBreak());
InfoTextBlock.Inlines.Add(new LineBreak());
InfoTextBlock.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 });
InfoTextBlock.Inlines.Add(new Run(appConfig.ProgramCopyright) { FontSize = 10 });
}
}
}

View file

@ -28,9 +28,9 @@ namespace SafeExamBrowser.UserInterface.Windows10
this.text = text;
}
public IWindow CreateAboutWindow(RuntimeInfo runtimeInfo)
public IWindow CreateAboutWindow(AppConfig appConfig)
{
return new AboutWindow(runtimeInfo, text);
return new AboutWindow(appConfig, text);
}
public IApplicationButton CreateApplicationButton(IApplicationInfo info)
@ -92,19 +92,19 @@ namespace SafeExamBrowser.UserInterface.Windows10
return new PowerSupplyControl();
}
public IRuntimeWindow CreateRuntimeWindow(RuntimeInfo runtimeInfo)
public IRuntimeWindow CreateRuntimeWindow(AppConfig appConfig)
{
// TODO
throw new System.NotImplementedException();
}
public ISplashScreen CreateSplashScreen(RuntimeInfo runtimeInfo = null)
public ISplashScreen CreateSplashScreen(AppConfig appConfig = null)
{
SplashScreen splashScreen = null;
var splashReadyEvent = new AutoResetEvent(false);
var splashScreenThread = new Thread(() =>
{
splashScreen = new SplashScreen(text, runtimeInfo);
splashScreen = new SplashScreen(text, appConfig);
splashScreen.Closed += (o, args) => splashScreen.Dispatcher.InvokeShutdown();
splashScreen.Show();