public int Execute() { string result = JsonEditor.GetValue(Path, Key); System.Console.Write(result); return(0); }
public void Can_get_json_value() { // Arrange var sourceFile = TestData.GetFile("config1.json"); // Act var result1 = JsonEditor.GetValue(sourceFile, "nugetKey"); var result2 = JsonEditor.GetValue(sourceFile, "local:datastore:auth"); var result3 = JsonEditor.GetValue(sourceFile, "local:datastore:main"); var result4 = JsonEditor.GetValue(sourceFile, "invaild"); // Assert result1.ShouldNotBeNullOrEmpty(); result2.ShouldNotBeNullOrEmpty(); result3.ShouldNotBeNullOrEmpty(); result4.ShouldBeNullOrEmpty(); }
public void SetJsonValueUsingTwoLevelsOfElement() { string expectedValue = "new-value"; Args = CreateArgsArray( CommandNameArgument, GetArgEntry(Constants.ArgumentNameConfigFilename, _PathToSampleConfigFile), GetArgEntry(Constants.ArgumentNameLevel1, "ConnectionStrings"), GetArgEntry(Constants.ArgumentNameLevel2, "DefaultConnectionString"), GetArgEntry(Constants.ArgumentNameValue, expectedValue)); SystemUnderTest.Run(); var editor = new JsonEditor(_PathToSampleConfigFile); var actual = editor.GetValue( "ConnectionStrings", "DefaultConnectionString"); Assert.AreEqual <string>(expectedValue, actual, "Result was wrong."); }
public void SetJsonValueUsingOneLevelOfElement() { string expectedValue = "new-value"; Args = CreateArgsArray( CommandNameArgument, GetArgEntry(Constants.ArgumentNameConfigFilename, _PathToSampleConfigFile), GetArgEntry(Constants.ArgumentNameLevel1, "FirstLevel"), GetArgEntry(Constants.ArgumentNameAttributeName, "processPath"), GetArgEntry(Constants.ArgumentNameValue, expectedValue)); SystemUnderTest.Run(); var editor = new JsonEditor(_PathToSampleConfigFile); var actual = editor.GetValue( "FirstLevel"); Assert.AreEqual <string>(expectedValue, actual, "Result was wrong."); }
private void AddClaimsFromAuthMeService( HttpContext context, List <Claim> claims) { if (context.Request.Cookies.ContainsKey(SecurityConstants.Cookie_AppServiceAuthSession) == true) { var authMeJson = GetAuthMeInfo(context.Request); var jsonArray = JArray.Parse(authMeJson); var editor = new JsonEditor(jsonArray[0].ToString(), true); AddClaimIfExists(claims, editor, ClaimTypes.GivenName); AddClaimIfExists(claims, editor, ClaimTypes.Surname); if (AddClaimIfExists(claims, editor, ClaimTypes.Email) == false) { var temp = editor.GetValue("user_id"); if (temp.IsNullOrWhitespace() == false) { claims.Add(new Claim(ClaimTypes.Email, temp)); } } } }