Example #1
0
        public int Execute()
        {
            if (!File.Exists(SourceFile))
            {
                File.WriteAllText(SourceFile, "{}");
            }

            JsonEditor.SetProperty(SourceFile, Key, Value);
            return(0);
        }
Example #2
0
        public void Can_set_json_property(string[] keys)
        {
            // Arrange
            using var approver = ApprovalTests.Namers.ApprovalResults.ForScenario(string.Join("__", keys));
            var line = string.Concat(Enumerable.Repeat('-', 50));

            var sourceFile = Path.Combine(_currentWorkingDirectory, $"secrets-set-test({string.Join(" ", keys)}).json");

            // Act
            foreach (var item in keys)
            {
                JsonEditor.SetProperty(sourceFile, item, 123);

                System.Diagnostics.Debug.WriteLine($"arg: {item}");
                var result = File.ReadAllText(sourceFile);
                System.Diagnostics.Debug.WriteLine(result);
                System.Diagnostics.Debug.WriteLine(line);
                System.Diagnostics.Debug.WriteLine(string.Empty);
                System.Diagnostics.Debug.WriteLine(string.Empty);
            }

            // Assert
            Approvals.VerifyFile(sourceFile);
        }