internal void ShowDialog(UIMode uiMode, UIProvider uiProvider) { var exception = new SerializableException(new ArgumentException("Argument exception preview.", new Exception("Inner exception for argument exception."))); var report = new Report(exception); var consoleOut = new StringWriter(); Console.SetOut(consoleOut); if (uiProvider == UIProvider.Console) { ConsoleUI.ShowDialog(uiMode, exception, report); this.consoleOutputTextBox.Text = consoleOut.ToString(); this.ShowDialog(); } else if (uiProvider == UIProvider.WinForms) { WinFormsUI.ShowDialog(uiMode, exception, report); this.Close(); } else if (uiProvider == UIProvider.WPF) { WPFUI.ShowDialog(uiMode, exception, report); this.Close(); } else if (uiProvider == UIProvider.Custom) { CustomUI.ShowDialog(uiMode, exception, report); this.Close(); } else { throw new ArgumentException("Parameter supplied for UIProvider argument is invalid."); } }
static void Main(string[] args) { MealsProvider mealsProvider = new MealsProvider(); UIProvider uiProvider = new UIProvider(); var defaultMeals = mealsProvider.GetDefaultMeals(); uiProvider.DisplayMainMenu(); var nextAction = uiProvider.ReadMainMenuInput(); switch (nextAction) { case Actions.ShowMeals: uiProvider.DisplayMeals(defaultMeals); break; case Actions.PlaceOrderForToday: break; case Actions.PlaceOrderForTomorrow: break; case Actions.ShowOrdersForToday: break; case Actions.Exit: break; case Actions.None: break; default: throw new ArgumentOutOfRangeException(); } }
public void ListenToCompletionDoesNotThrowInRelease() { var provider = Substitutes.GetFullyMockedServiceProvider(); using (var p = new UIProvider(provider)) { #if DEBUG Assert.ThrowsAny<InvalidOperationException>(() => { #endif p.ListenToCompletionState(); #if DEBUG }); #endif } }
public void DetermineTodaySales_VaryingCustomers() { // Arrange Weather Lists List <Weather> weatherListFirstCustomer = new List <Weather>(); weatherListFirstCustomer.Add(new Weather("slushy", 10, .80)); weatherListFirstCustomer.Add(new Weather("slimey", 10, .80)); weatherListFirstCustomer.Add(new Weather("gunky", 10, .80)); List <Weather> weatherListSecondCustomer = new List <Weather>(); weatherListSecondCustomer.Add(new Weather("slushy", 10, .80)); weatherListSecondCustomer.Add(new Weather("mucky", 10, .80)); weatherListSecondCustomer.Add(new Weather("slunky", 10, .80)); List <Weather> weatherListThirdCustomer = new List <Weather>(); weatherListThirdCustomer.Add(new Weather("slushy", 10, .80)); weatherListThirdCustomer.Add(new Weather("doofy", 10, .80)); weatherListThirdCustomer.Add(new Weather("funky", 10, .80)); // Arrange Customers UIProvider uIProvider = new UIProvider(); Day today = new Day(uIProvider, 1); Stand defaultStand = new Stand(); defaultStand.inventory.AddToInventory(1000, 1000, 1000, 1000); defaultStand.recipe.price = 0.35; today.weatherToday = new Weather("slushy", 60, 1); today.customers = new List <ICustomer>(); today.customers.Add(new Customer(0.50, weatherListFirstCustomer)); today.customers.Add(new Customer(1.05, weatherListSecondCustomer)); today.customers.Add(new Customer(0.40, weatherListThirdCustomer)); today.customers.Add(new Customer(20.00)); today.customers.Add(new Customer(20.00)); // Act double result = today.DetermineTodaySales(defaultStand); // Assert Assert.AreEqual(1.75, result); }
public void DetermineTodaySales_CustomersHaveUnpreferredWeather() { UIProvider uIProvider = new UIProvider(); Day today = new Day(uIProvider, 1); Stand defaultStand = new Stand(); today.weatherToday = new Weather("rainstorms", 60, 1); today.customers = new List <ICustomer>(); today.customers.Add(new Customer()); today.customers.Add(new Customer()); today.customers.Add(new Customer()); today.customers.Add(new Customer()); today.customers.Add(new Customer()); // Act double result = today.DetermineTodaySales(defaultStand); // Assert Assert.AreEqual(0, result); }
public void DetermineTodaySales_AllCustomersSame_PlentyInventory() { UIProvider uIProvider = new UIProvider(); Day today = new Day(uIProvider, 1); Stand defaultStand = new Stand(); today.weatherToday = new Weather(); defaultStand.inventory.AddToInventory(1000, 1000, 1000, 1000); today.customers = new List <ICustomer>(); today.customers.Add(new Customer()); today.customers.Add(new Customer()); today.customers.Add(new Customer()); today.customers.Add(new Customer()); today.customers.Add(new Customer()); // Act double result = today.DetermineTodaySales(defaultStand); // Assert Assert.AreEqual(2.50, result); }
internal void ShowDialog(UIMode uiMode, UIProvider uiProvider) { var exception = new SerializableException(new ArgumentException("Argument exception preview.", new Exception("Inner exception for argument exception."))); var report = new Report(exception); var consoleOut = new StringWriter(); Console.SetOut(consoleOut); if (uiProvider == UIProvider.Console) { ConsoleUI.ShowDialog(uiMode, exception, report); this.consoleOutputTextBox.Text = consoleOut.ToString(); this.ShowDialog(); } else if (uiProvider == UIProvider.WinForms) { WinFormsUI.ShowDialog(uiMode, exception, report); this.Close(); } else if (uiProvider == UIProvider.WPF) { WPFUI.ShowDialog(uiMode, exception, report); this.Close(); } else if (uiProvider == UIProvider.Custom) { CustomUI.ShowDialog(uiMode, exception, report); this.Close(); } else { throw new ArgumentException("Parameter supplied for UIProvider argument is invalid."); } }
/// <summary> /// Initalises the engine. /// </summary> private void InitaliseEngine() { LicenseManagement(); _heartbeatTimer = new System.Timers.Timer { Enabled = false, Interval = int.Parse(Properties.Resources.HeartbeatInterval) }; _heartbeatTimer.Elapsed += InternalHeartbeatTimerElapsed; _nagTimer = new System.Timers.Timer { Enabled = false }; _nagTimer.Elapsed += InternalNagTimerElapsed; _appFolder = (new FileInfo(Assembly.GetExecutingAssembly().Location)).Directory; _dataFolder = new DirectoryInfo(System.Windows.Forms.Application.UserAppDataPath); if (_dataFolder.Exists == false) { _dataFolder.Create(); _dataFolder.Refresh(); } //Read Provider Configuration if (ConfigurationManager.GetSection(ConfigurationSection.SectionName) is ConfigurationSection config) { if (config.Providers == null || config.Providers.Count == 0) { Trace.TraceError(Properties.Resources.NoProvidersFoundInConfigurationFile); throw new InvalidOperationException(Properties.Resources.NoProvidersFoundInConfigurationFile); } // The providers are created and initalised in a special order, // first is the // identity provider (work out who is using this application) _identityProvider = InitializeProvider(config, "IdentityProvider") as IdentityProvider; _identityProvider.DiscoverIdentity(); if (!_identityProvider.Principal.Identity.IsAuthenticated) { Trace.TraceError(Properties.Resources.IdentityCouldNotBeEstablished); throw new InvalidOperationException(Properties.Resources.IdentityCouldNotBeEstablished); } // Then comes the plugin provider _pluginsProvider = InitializeProvider(config, "PluginsProvider") as PluginsProvider; _pluginsProvider.DiscoverPlugins(); // then comes the TaskDescription and Task Activity providers _taskDescriptionsProvider = InitializeProvider(config, "TaskDescriptionsProvider") as TaskDescriptionsProvider; _taskActivitiesProvider = InitializeProvider(config, "TaskActivitiesProvider") as TaskActivitiesProvider; // The UI provider then gets created and initalised _uiProvider = InitializeProvider(config, "UIProvider") as UIProvider; // Finnaly the Users memory provider _userMemoryProvider = InitializeProvider(config, "UserMemoryProvider") as UserMemoryProvider; } else { Trace.TraceError(Properties.Resources.ConfigurationFileInvalid); throw new InvalidOperationException(Properties.Resources.ConfigurationFileInvalid); } Trace.TraceInformation("TaskClerkSDK:InitaliseEngine"); }
public Game(UIProvider uIProvider, int totalDays) { this.totalDays = totalDays; this.player = new Player(); this.uIProvider = uIProvider; }
public Game(UIProvider uIProvider) { this.totalDays = 7; this.player = new Player(); this.uIProvider = uIProvider; }