public static async Task <SettingsContainer> CaptureSettings(FileSettings settingsIn, OutputDestination?outputDestination = null, OutputFormat?outputFormat = null, string outputFileName = null) { var logger = Substitute.For <IConfigureLogger>(); var fileSettings = Substitute.For <IFileSettingsCache>(); SettingsContainer settingsOut = null; var engine = Substitute.For <ILocalEngine>(); await engine.Run(Arg.Do <SettingsContainer>(x => settingsOut = x), false); fileSettings.GetSettings().Returns(settingsIn); var command = new InspectCommand(engine, logger, fileSettings); if (outputDestination.HasValue) { command.OutputDestination = outputDestination.Value; } if (outputFormat.HasValue) { command.OutputFormat = outputFormat.Value; } if (!string.IsNullOrWhiteSpace(outputFileName)) { command.OutputFileName = outputFileName; } await command.OnExecute(); return(settingsOut); }
/// <inheritdoc/> protected override void OnPropertyChanged(PropertyChangedEventArgs eventArgs) { if (InspectCommand != null) // Method is called in constructor before commands are set. { InspectCommand.RaiseCanExecuteChanged(); BackCommand.RaiseCanExecuteChanged(); RefreshCommand.RaiseCanExecuteChanged(); CopyValueCommand.RaiseCanExecuteChanged(); } base.OnPropertyChanged(eventArgs); }
public void InspectCommand_InspectSpaceWithContainer_NotifiesContainer() { var container = new ValuablesContainer { ObjectLayer = ObjectLayer.LowerObject }; _layer[0, 0].Put(container); var command = new InspectCommand(_map, new XYZ(0, 0, 0), this); command.Go(); Assert.AreEqual(container, _containers.First()); }
public void InspectCommand_InspectSpaceWithValuable_NotifiesValuable() { var valuable = new ValuableFacilityObject { ObjectLayer = ObjectLayer.LowerObject }; _layer[0, 0].Put(valuable); var command = new InspectCommand(_map, new XYZ(0, 0, 0), this); command.Go(); Assert.AreEqual(valuable, _valuables.First()); }
private InspectCommand SetUpInspect(Board boards, Player oponent) { InspectCommand inspect = new InspectCommand(); List <Unit> allUnits = new List <Unit>(); allUnits.AddRange(GetUnits()); allUnits.AddRange(oponent.GetUnits()); Coord selPos = boards.SelectUnit(allUnits); Cursor = selPos; inspect.SetUp(selPos, boards, allUnits); return(inspect); }
public async Task LogLevelIsNormalByDefault() { var engine = Substitute.For <ILocalEngine>(); var logger = Substitute.For <IConfigureLogger>(); var fileSettings = Substitute.For <IFileSettingsCache>(); fileSettings.GetSettings().Returns(FileSettings.Empty()); var command = new InspectCommand(engine, logger, fileSettings); await command.OnExecute(); logger .Received(1) .Initialise(LogLevel.Normal, LogDestination.Console, Arg.Any <string>()); }
public async Task ShouldCallEngineAndSucceed() { var engine = Substitute.For <ILocalEngine>(); var logger = Substitute.For <IConfigureLogger>(); var fileSettings = Substitute.For <IFileSettingsCache>(); fileSettings.GetSettings().Returns(FileSettings.Empty()); var command = new InspectCommand(engine, logger, fileSettings); var status = await command.OnExecute(); Assert.That(status, Is.EqualTo(0)); await engine .Received(1) .Run(Arg.Any <SettingsContainer>(), false); }
public async Task <SettingsContainer> CaptureSettings(FileSettings settingsIn) { var logger = Substitute.For <IConfigureLogLevel>(); var fileSettings = Substitute.For <IFileSettingsCache>(); SettingsContainer settingsOut = null; var engine = Substitute.For <ILocalEngine>(); await engine.Run(Arg.Do <SettingsContainer>(x => settingsOut = x), false); fileSettings.Get().Returns(settingsIn); var command = new InspectCommand(engine, logger, fileSettings); await command.OnExecute(); return(settingsOut); }
public async Task ShouldSetLogLevelFromCommand() { var engine = Substitute.For <ILocalEngine>(); var logger = Substitute.For <IConfigureLogger>(); var fileSettings = Substitute.For <IFileSettingsCache>(); fileSettings.Get().Returns(FileSettings.Empty()); var command = new InspectCommand(engine, logger, fileSettings); command.Verbosity = LogLevel.Minimal; await command.OnExecute(); logger .Received(1) .Initialise(LogLevel.Minimal, null); }
public async Task LogToFileBySettingLogDestination() { var engine = Substitute.For <ILocalEngine>(); var logger = Substitute.For <IConfigureLogger>(); var fileSettings = Substitute.For <IFileSettingsCache>(); var settings = FileSettings.Empty(); fileSettings.GetSettings().Returns(settings); var command = new InspectCommand(engine, logger, fileSettings); command.LogDestination = LogDestination.File; await command.OnExecute(); logger .Received(1) .Initialise(LogLevel.Normal, LogDestination.File, "nukeeper.log"); }
public async Task ShouldSetLogLevelFromFile() { var engine = Substitute.For <ILocalEngine>(); var logger = Substitute.For <IConfigureLogger>(); var fileSettings = Substitute.For <IFileSettingsCache>(); var settings = new FileSettings { Verbosity = LogLevel.Detailed }; fileSettings.GetSettings().Returns(settings); var command = new InspectCommand(engine, logger, fileSettings); await command.OnExecute(); logger .Received(1) .Initialise(LogLevel.Detailed, LogDestination.Console, Arg.Any <string>()); }
public async Task CommandLineLogLevelOverridesFile() { var engine = Substitute.For <ILocalEngine>(); var logger = Substitute.For <IConfigureLogger>(); var fileSettings = Substitute.For <IFileSettingsCache>(); var settings = new FileSettings { Verbosity = LogLevel.Detailed }; fileSettings.Get().Returns(settings); var command = new InspectCommand(engine, logger, fileSettings); command.Verbosity = LogLevel.Minimal; await command.OnExecute(); logger .Received(1) .Initialise(LogLevel.Minimal, null); }
/// <summary> /// Initializes a new instance of the <see cref="SelectorWindowViewModel"/> class. /// </summary> public SelectorWindowViewModel() { _inspectionService = ServiceLocator.Resolve <InspectionService>(); _updateCheckService = ServiceLocator.Resolve <UpdateCheckService>(); UpdateInformation = _updateCheckService.UpdateInformation; _managedApplicationsService = new ManagedApplicationsService(); ManagedApplicationsInfo = _managedApplicationsService.ManagerApplicationsInfo; ManagedApplicationsInfo.ManagedApplicationInfos.CurrentChanged += (s, e) => InspectCommand.RaiseCanExecuteChanged(); ManagedApplicationsInfo.ManagedApplicationInfos.CollectionChanged += (s, e) => { if (ManagedApplicationsInfo.ManagedApplicationInfos.CurrentItem == null) { ManagedApplicationsInfo.ManagedApplicationInfos.MoveCurrentToFirst(); } }; RefreshCommand = new Command <object>(RefreshApplicationList); InspectCommand = new Command <object>(_ => Inspect(), _ => ManagedApplicationsInfo.ManagedApplicationInfos.CurrentItem != null); ExitCommand = new Command <object>(o => Application.Current.Shutdown()); AboutCommand = new Command <object>(o => new AboutWindow().ShowDialog()); VisitWebpageCommand = new Command <object>(VisitWebPage); }