public async Task UpdateConfiguration_WithValidInputs_UpdatesAppConfig() { // Arrage _readerMoq.Setup(x => x.FetchJsonTFiles(It.IsAny <string>())).Returns(Task.FromResult(new[] { $@"{sourcePath}/settings.json" })); var configurations = new Configuration( "settings.json", new Dictionary <string, object> { ["dop"] = true, }); _readerMoq.Setup(x => x.ReadAndDeserializeConfig(It.IsAny <string>())).Returns(Task.FromResult(configurations)); var settingsJObject = JObject.FromObject(new { Name = "Test" }); _readerMoq.Setup(x => x.ReadAndDeserializeAppConfig(It.IsAny <string>())).Returns(Task.FromResult(settingsJObject)); _writerMoq.Setup(x => x.UpdateConfigurations(It.IsAny <IDictionary <string, object> >(), It.IsAny <JObject>())).Returns(Task.FromResult(settingsJObject)); _writerMoq.Setup(x => x.WriteConfigurationsToFile(It.IsAny <string>(), It.IsAny <JObject>())).Returns(Task.CompletedTask); // Act await _target.UpdateConfiguration(sourcePath); // Assert _loggerMoq.Verify(x => x.Log(LogLevel.Information, It.IsAny <EventId>(), It.Is <It.IsAnyType>((v, t) => true), It.IsAny <Exception>(), It.Is <Func <It.IsAnyType, Exception, string> >((v, t) => true)), Times.Once); _readerMoq.Verify(x => x.ReadAndDeserializeConfig(It.IsAny <string>()), Times.Once); _readerMoq.Verify(x => x.ReadAndDeserializeAppConfig(It.IsAny <string>()), Times.Once); }
static void Main(string[] args) { var jsonTUpdater = new ConfigurationUpdater(); var parseResult = new Parser(with => with.HelpWriter = null) .ParseArguments <JsonTCommand>(args); parseResult .WithParsed(opts => { jsonTUpdater.UpdateConfiguration(opts.SourcePath).GetAwaiter().GetResult(); }) .WithNotParsed(errs => HelpContent.DisplayHelp(parseResult)); }