public void JsonSourceTest(JsonTest test) { var timestamp = DateTime.ParseExact( test.Timestamp, "yyyyMMdd'T'HHmmss'Z'", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal); var clock = new FakeClock(timestamp); var signer = UrlSigner .FromServiceAccountCredential(s_testCredential) .WithSigningVersion(SigningVersion.V4) .WithClock(clock); var actualUrl = signer.Sign(test.Bucket, test.Object, duration: TimeSpan.FromSeconds(test.Expiration), requestMethod: s_methods[test.Method], requestHeaders: test.Headers?.ToDictionary(kvp => kvp.Key, kvp => Enumerable.Repeat(kvp.Value, 1)), contentHeaders: null); // We almost always want the complete URL afterwards, which xUnit doesn't give us. if (test.ExpectedUrl != actualUrl) { FileLogger.Log($"{test.Description} failure"); FileLogger.Log($"Expected: {test.ExpectedUrl}"); FileLogger.Log($"Actual: {actualUrl}"); } Assert.Equal(test.ExpectedUrl, actualUrl); }
// 支付的回调方法 private void PayCallFunc(string content) { Debug.Log("BeCallFunc"); if (Application.platform == RuntimePlatform.Android) { if (content.Equals("success")) { str = "PayType : " + TCTForUnity.getUserInfo("PayType"); } else { str = content;// 错误信息 } } else if (Application.platform == RuntimePlatform.IPhonePlayer) { Debug.Log("daolezhifu"); Debug.Log(content); JsonStr jsonText = JsonTest.ReadJsonGet(content); string code = jsonText.code; Debug.Log(code); } else { // 写一些东西 } }
public static List <Vector2> GetPoints(Vector2 start, Vector2 end) { for (int i = 0; i < width; ++i) { for (int j = 0; j < height; ++j) { int id = JsonTest.getMe().GetStopPoint(i, j); // [i, j]; MapMgr.getMe().mRoadPointArr[i][j] = MapMgr.canThroughByID(id); } } List <APoint> _ret = Astar.SearchRoad(GetAPointByPosition(start, TILEDMAP_TYPE.START), GetAPointByPosition(end, TILEDMAP_TYPE.END), MapMgr.getMe().mRoadPointArr); List <Vector2> retex = new List <Vector2>(); foreach (var data in _ret) { Vector2 pos = GetVec2ByApoint(data); retex.Add(pos); } return(retex); }
// Start is called before the first frame update void Start() { StreamReader file = File.OpenText(Application.dataPath + "/StreamingAssets/JsonChallenge.json"); JsonTest json = JsonConvert.DeserializeObject <JsonTest>(file.ReadToEnd()); tableTittle.text = json.Title; tableTittle.color = Color.black; GameObject gameObjectRow; gameObjectRow = (GameObject)Instantiate(rowGrid); gameObjectRow.transform.SetParent(rowContainer.transform); foreach (string header in json.ColumnHeaders) { GameObject row = new GameObject(header); row.transform.SetParent(gameObjectRow.transform); row.AddComponent <Text>().text = header; row.GetComponent <Text>().color = Color.black; row.GetComponent <Text>().font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; } foreach (Dictionary <string, string> dictionary in json.Data) { gameObjectRow = (GameObject)Instantiate(rowGrid); gameObjectRow.transform.SetParent(rowContainer.transform); foreach (KeyValuePair <string, string> kvp in dictionary) { GameObject row = new GameObject(kvp.Value); row.transform.SetParent(gameObjectRow.transform); row.AddComponent <Text>().text = kvp.Value; row.GetComponent <Text>().font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; } } }
// 根据tiledmap坐标点获得地图坐标 public static Vector2 GetVec2ByApoint(APoint p) { float x = p.x * JsonTest.getMe().m_mapData.getgeziw() - 204; float y = (p.y) * JsonTest.getMe().m_mapData.getgezih() - 118; return(new Vector2(x, y)); }
public static void Main(string[] args) { // uncomment as wanted JsonTest.Run(); //JsonDemo.Run(); //Server.Start(); }
//회원가입 버튼 눌르면 동작 public void SignupBtClick() { IsSign = "회원가입"; //회원가입 정보가 하나라도 비어 있을경우 if (string.IsNullOrEmpty(input_id.text) || string.IsNullOrEmpty(input_pwd.text) || string.IsNullOrEmpty(input_pwdcheck.text) || string.IsNullOrEmpty(input_username.text) || string.IsNullOrEmpty(input_birthday.text) || string.IsNullOrEmpty(input_height.text) || string.IsNullOrEmpty(input_weight.text) || string.IsNullOrEmpty(input_phonenum.text) || string.IsNullOrEmpty(input_address.text) || gender == "") { checkempty.gameObject.SetActive(true); ResetValue(); //입력된 모든 값 초기화 } //이용약관 및 개인정보 수집 이용 동의 체크 else if (condition == "거절" || information == "거절") { checkagree.gameObject.SetActive(true); } //모든값이 다 들어가있으면 else { //입력된 값을 각 변수에 저장 id = input_id.text; pwd = input_pwd.text; pwdcheck = input_pwdcheck.text; username = input_username.text; birthday = input_birthday.text; height = input_height.text; weight = input_weight.text; phonenum = input_phonenum.text; address = input_address.text; email = input_email.text; if (pwd != pwdcheck) { pwdcheck_message.gameObject.SetActive(true); } else { //회원가입시 입력된 값을 json으로 변환하고 웹서버로 데이터 전송하는 부분 JsonTest json = new JsonTest(); json.id = input_id.text; json.pwd = input_pwd.text; json.username = input_username.text; json.birthday = input_birthday.text; json.height = input_height.text; json.weight = input_weight.text; json.phonenum = input_phonenum.text; json.address = input_address.text; json.email = input_email.text; json.gender = gender; json.date = string.Format("{0:u}", today); json.SaveToString(json); //json형식으로 변환 jsondata = json.SaveToString(json); StartCoroutine(SendData(jsondata)); //웹서버로 데이터 전송 pwdcheck_message.gameObject.SetActive(false); StartCoroutine(Waitfortime()); } } }
public static JsonTest getMe() { if (JsonTest.g_msglogin == null) { JsonTest.g_msglogin = new JsonTest(); } return(JsonTest.g_msglogin); }
public ActionResult PostAnswers(JsonTest test) { try { TestParticipation participation = db.TestParticipations.Where(p => p.AuthToken == test.token).FirstOrDefault(); Test realTest = db.Tests.Include(t => t.Sections.Select(s => s.Questions.Select(q => q.Options))) .FirstOrDefault(t => t.TestId == test.id); int numberOfQuestion = 0; int numberOfRightAnswers = 0; foreach (var section in test.sections.Values) { Section realSection = realTest.Sections.FirstOrDefault(s => s.SectionId == section.id); foreach (var question in section.questions.Values) { Question realQuestion = realSection.Questions.FirstOrDefault(q => q.QuestionId == question.id); string type = realQuestion.Type; bool allRight = true; foreach (var answer in question.answers.Values) { Option realOption = realQuestion.Options.FirstOrDefault(o => o.OptionId == answer.id); bool isWrongAnswer = realOption.IsRight != answer.isRight; if (isWrongAnswer) { allRight = false; } if (answer.isRight) { TestParticipationAnswer answerToAdd = new TestParticipationAnswer(participation, realQuestion, realOption, isWrongAnswer); db.TestParticipationAnswers.Add(answerToAdd); } } numberOfQuestion++; if (allRight) { numberOfRightAnswers++; } } } int result = 0; if (numberOfQuestion != 0) { result = 100 * numberOfRightAnswers / numberOfQuestion; } participation.SetComplete(result); db.SaveChanges(); return(Json(new { success = true, result = result })); } catch (Exception exc) { throw exc; return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
public void TestExecute() { Client client = new Client("http://echo.jsontest.com"); Request request = new Request("key/value", Method.GET); JsonTest response = client.Execute <JsonTest>(request); Assert.AreEqual(response.key, "value"); }
void JsonTester() { var instance = new JsonTest(); try { var json = UniExtensions.Serialization.JsonSerializer.Encode(instance); Debug.Log(json); Debug.Log(UniExtensions.Serialization.JsonPrettyPrint.Format(json)); } catch (System.Exception e) { Debug.LogError(e); } }
public void TestLegacySignature() { #pragma warning disable 0618 var expectedObj = new JsonTest { TestBool = true }; var actualJson = PlayFab.Json.JsonConvert.SerializeObject(expectedObj); JsonTest actualObj = PlayFab.Json.JsonConvert.DeserializeObject <JsonTest>(actualJson); PlayFab.Json.JsonConvert.DeserializeObject(actualJson); UUnitAssert.True(actualObj.TestBool); #pragma warning restore 0618 }
public MainForm() { InitializeComponent(); // Add version var version = Assembly.GetEntryAssembly().GetName().Version; Text += " v" + version; // Setup combo box comboBoxType.Items.Add("Temperature #1"); comboBoxType.Items.Add("Humidity #1"); comboBoxType.Items.Add("Temperature #2"); comboBoxType.Items.Add("Humidity #2"); comboBoxType.SelectedIndex = 0; // Setup graph zedGraphControl1.GraphPane.Title.Text = "Hive Sensor Data"; zedGraphControl1.GraphPane.YAxis.Title.Text = "Value"; zedGraphControl1.GraphPane.YAxis.Scale.Min = 0; zedGraphControl1.GraphPane.YAxis.Scale.Max = 100; zedGraphControl1.GraphPane.XAxis.Title.Text = "Time"; zedGraphControl1.GraphPane.XAxis.Type = AxisType.Date; zedGraphControl1.GraphPane.XAxis.Title.Text = "Time (HH:MM:SS)"; zedGraphControl1.GraphPane.XAxis.Scale.Format = "HH:mm:ss"; zedGraphControl1.GraphPane.XAxis.Scale.MajorUnit = DateUnit.Minute; zedGraphControl1.GraphPane.XAxis.Scale.MinorUnit = DateUnit.Minute; //zedGraphControl1.GraphPane.XAxis.Scale.Min = DateTime.Now.Subtract(new TimeSpan(0, 0, 10, 0, 0)).ToOADate(); //zedGraphControl1.GraphPane.XAxis.Scale.Max = DateTime.Now.ToOADate(); // Enable scrollbars if needed zedGraphControl1.IsShowHScrollBar = false; zedGraphControl1.IsShowVScrollBar = false; zedGraphControl1.IsAutoScrollRange = true; zedGraphControl1.IsShowPointValues = true; zedGraphControl1.AxisChange(); // Make sure the Graph gets redrawn zedGraphControl1.Invalidate(); // Set UI UpdateUI(); #if false // Tests JsonTest.DeserializeBeeJSON(_testJSON); JsonTest.DownloadAndDeserialiseJSON(_url); #endif }
//수정 후 입력된 값 들 변수에 넣음 //수정하기 버튼 누르면 동작하는 함수 public void ModiftyClick() { Signup.IsSign = "회원정보수정"; //바꾸든 안바꾸든 비밀번호 입력하는 부분 if (string.IsNullOrEmpty(input_pwd.text) || string.IsNullOrEmpty(input_pwdcheck.text)) { pwdinput_message.gameObject.SetActive(true); } else { //tmp에 넣어도 될거같은데 수정하기 귀찮; id = text_id.text; pwd = input_pwd.text; pwdcheck = input_pwdcheck.text; username = text_username.text; birthday = text_birthday.text; height = input_height.text; weight = input_weight.text; phonenum = input_phonenum.text; address = input_address.text; email = input_email.text; if (pwd != pwdcheck) { pwdcheck_message.gameObject.SetActive(true); } else { pwdcheck_message.gameObject.SetActive(false); JsonTest json = new JsonTest(); json.id = id; json.pwd = pwd; json.username = username; json.birthday = birthday; json.height = height; json.weight = weight; json.phonenum = phonenum; json.address = address; json.email = email; json.gender = gender; json.date = string.Format("{0:u}", today); json.SaveToString(json); //json형식으로 변환 jsonData = json.SaveToString(json); Debug.Log(jsonData); StartCoroutine(SendData(jsonData)); //웹서버로 데이터 전송 pwdcheck_message.gameObject.SetActive(false); StartCoroutine(Waitfortime()); sceneMg.SceneChangeToMain(); } } }
public bool TestWritingToDatabaseUsingAllFieldTypes(StreamWriter sw) { DateTime now = DateTime.UtcNow; JsonTest expected = new JsonTest() { fields = new JsonTestFields() { fieldName1 = new JsonStringField(), fieldName2 = new JsonNumericField(), fieldName3 = new JsonNumericField(), fieldName4 = new JsonDateTimeField() }, StringValue = "fieldValue1", IntegerValue = 3, DoubleValue = 3.14, TimestampValue = now }; List <Tuple <string, FieldTypes, string> > fieldConfigList = new List <Tuple <string, FieldTypes, string> > { new Tuple <string, FieldTypes, string>("fieldName1", FieldTypes.StringValue, "fieldValue1"), new Tuple <string, FieldTypes, string>("fieldName2", FieldTypes.IntegerValue, "3"), new Tuple <string, FieldTypes, string>("fieldName3", FieldTypes.DoubleValue, "3.14"), new Tuple <string, FieldTypes, string>("fieldName4", FieldTypes.TimestampValue, now.ToString("o")) }; string json = GenerateFieldsJson(fieldConfigList); WebClient webClient = new WebClient(); webClient.BaseAddress = "https://firestore.googleapis.com/v1beta1/projects/whatinoted-12345/databases/(default)/documents/test_collection/"; try { // ensure document doesn't already exist webClient.UploadString("test_document", "DELETE", ""); string result = webClient.UploadString("?documentId=test_document", json); // remove document after test webClient.UploadString("test_document", "DELETE", ""); JsonTest actual = JsonConvert.DeserializeObject <JsonTest>(result); return(actual.Equals(expected)); } catch { return(false); } }
// 根据地图坐标点获得tiledmap坐标 public static APoint GetAPointByPosition(Vector2 pos, TILEDMAP_TYPE type = TILEDMAP_TYPE.START) { float x = (pos.x + 204) / JsonTest.getMe().m_mapData.getgeziw(); float y = (pos.y + 118) / JsonTest.getMe().m_mapData.getgezih(); if (x < 0) { x = 0; } if (y < 0) { y = 0; } return(new APoint((int)x, (int)y, type)); }
public void init() { mRoadPointArr = new TILEDMAP_TYPE[width][]; for (int i = 0; i < width; ++i) { this.mRoadPointArr[i] = new TILEDMAP_TYPE[height]; } for (int i = 0; i < width; ++i) { for (int j = 0; j < height; ++j) { int id = JsonTest.getMe().GetStopPoint(i, j); // [i, j]; this.mRoadPointArr[i][j] = MapMgr.canThroughByID(id); } } }
static void Main(string[] args) { JsonTest.Test(); XmlTest.Test(); // TaskTest.Test(); //LinqTest.Test(); //DelegatesTest.Test(); //ExtensionMethodTest.Test(); //QueueStackTest.Test(); //CollectionTest.Test(); //ArrayTest.Test(); //GenericTypesMethodTest(); //GenericTypesClassTest(); }
public void JsonSourceTest(JsonTest test) { var timestamp = DateTime.ParseExact( test.Timestamp, "yyyyMMdd'T'HHmmss'Z'", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal); var clock = new FakeClock(timestamp); var signer = UrlSigner .FromServiceAccountCredential(s_testCredential) .WithSigningVersion(SigningVersion.V4) .WithClock(clock); var actualUrl = signer.Sign(test.Bucket, test.Object, duration: TimeSpan.FromSeconds(test.Expiration), requestMethod: s_methods[test.Method], requestHeaders: test.Headers?.ToDictionary(kvp => kvp.Key, kvp => (IEnumerable <string>)kvp.Value), contentHeaders: null); Assert.Equal(test.ExpectedUrl, actualUrl); }
static void Main(string[] args) { log.Debug("Unit Test App starting"); YamlTest yt = new YamlTest(); //yt.testBasicYamlOperation(); //yt.testYamlReadingFromFile(); //yt.testYamlInterpretationForDataSetPointList(); JsonTest jt = new JsonTest(); //jt.testJsonSerialisation(); // EyeDetectorTest et = new EyeDetectorTest(); // VisualDisplay vd = new VisualDisplay(); FileSystemVisualStore vd = new FileSystemVisualStore(UnitTestSettings.MEDIA_DIRECTORY_TEST_OUTPUT, "jpg", 200, 200); EyeDetectorTest et = new EyeDetectorTest(vd); et.setUp(); //et.PutEyesDetectionTest(); //et.PolyuEyesDetectionTest(); et.testStdDev(); et.BinocularDetectionTest(); et.tearDown(); // vd.Close(); XmlStructureTest xt = new XmlStructureTest(); //xt.testBasicStructure(); FileStreamCameraTest t1 = new FileStreamCameraTest(); //t1.SimpleFrameLoadingTest(); OpenCvExperimentTest t2 = new OpenCvExperimentTest(); //t2.BasicGrayUsageTest(); et = null; xt = null; t1 = null; t2 = null; }
static void Main( string[] args ) { log.Debug( "Unit Test App starting" ); YamlTest yt = new YamlTest(); //yt.testBasicYamlOperation(); //yt.testYamlReadingFromFile(); //yt.testYamlInterpretationForDataSetPointList(); JsonTest jt = new JsonTest(); //jt.testJsonSerialisation(); // EyeDetectorTest et = new EyeDetectorTest(); // VisualDisplay vd = new VisualDisplay(); FileSystemVisualStore vd = new FileSystemVisualStore( UnitTestSettings.MEDIA_DIRECTORY_TEST_OUTPUT, "jpg", 200, 200 ); EyeDetectorTest et = new EyeDetectorTest( vd ); et.setUp(); //et.PutEyesDetectionTest(); //et.PolyuEyesDetectionTest(); et.testStdDev(); et.BinocularDetectionTest(); et.tearDown(); // vd.Close(); XmlStructureTest xt = new XmlStructureTest(); //xt.testBasicStructure(); FileStreamCameraTest t1 = new FileStreamCameraTest(); //t1.SimpleFrameLoadingTest(); OpenCvExperimentTest t2 = new OpenCvExperimentTest(); //t2.BasicGrayUsageTest(); et = null; xt = null; t1 = null; t2 = null; }
public ActionResult Create(JsonTest test) { try { int currentAccountId = AppHelpers.GetCurrentUser().AccountId; Account currentAccount = db.Accounts.FirstOrDefault((a) => a.AccountId == currentAccountId); Test testToAdd = new Test(test.name, currentAccount); foreach (var section in test.sections.Values) { Section sectionToAdd = new Section(section.name); foreach (var question in section.questions.Values) { Question questionToAdd = new Question(question.text, question.type); foreach (var option in question.answers.Values) { Option optionToAdd = new Option(option.text, option.isRight); questionToAdd.Options.Add(optionToAdd); db.Options.Add(optionToAdd); } sectionToAdd.Questions.Add(questionToAdd); db.Questions.Add(questionToAdd); } testToAdd.Sections.Add(sectionToAdd); db.Sections.Add(sectionToAdd); } db.Tests.Add(testToAdd); db.SaveChanges(); return(Json(new { success = true })); } catch (Exception) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
void Loadjson(string _fileName) { JsonTest json = GameObject.Find("JsonData").GetComponent <JsonTest>(); // object에서 이미 jsondata로드한 item변수 가져옴 for (int i = 0; i < json.item.Length; i++) { if (_fileName.Equals(json.item[i].num)) //파일 이름이랑 num 태그 안에 있던 이름이랑 비교해고 같을 경우, { Debug.Log(_fileName + "체크 " + json.item[i].num + Lang_name + json.item[i].name + json.item[i].artist); AddStamp(_fileName); //일단 스탬프 파일입출력으로 추가시켜주고, Chktext.text = "\t" + Lang_name + json.item[i].name + "\n\n\t" + Lang_author + json.item[i].artist; // Text박스 수정 //화면을 터치했을때 사운드 플레이 동작 실시하기 위해서 변수 삽입 SoundTrackCount = true; // 음악 큐 str = Lang_hello + json.item[i].info; // TTS 실행할 문자열 //base.FieldString = str; //base.OnSpeakClick(); break; } else { Debug.Log(_fileName + "Json 인식실패 "); } } }
private IEnumerator SetUp() { var length = Microphone.devices.Length; if (!(m_source != null && length > 0)) // オーディオソースとマイクがある { Debug.LogError("AudioSourceかマイクが見つからない"); yield break; } var text = "Microphone List"; for (int i = 0; i < length; i++) { text += "\n" + (i + 1).ToString() + "." + Microphone.devices[i]; } setText.text = text; var devName = ""; var num = -1; setField.ActivateInputField(); while (true) { if (Input.GetKeyDown(KeyCode.Return)) { if (int.TryParse(setField.text, out num)) { if (0 <= num && num <= length) { devName = Microphone.devices[num - 1]; break; } else { Debug.LogError("リストの範囲外の数字が入力されている"); } } else { Debug.LogError("整数以外が入力されている"); } } yield return(null); } m_source.loop = true; // ループにする m_source.clip = Microphone.Start(devName, true, recordingSec, samplingFrequency); // clipをマイクに設定 while (!(Microphone.GetPosition(devName) > 0)) { } // きちんと値をとるために待つ Microphone.GetPosition(null); m_source.Play(); API = GetComponent <JsonTest>(); setText.gameObject.SetActive(false); setField.gameObject.SetActive(false); GetReady(); }
public static void Write() { JsonTest.Demo1(); }
/// <summary> /// 设置阻挡 zudang: true 是阻挡 false 可以行走 /// </summary> /// <param name="pos"></param> /// <param name="isStop"></param> public void SetStopPoint(Vector2 pos, bool isStop) { APoint _APoint = GetAPointByPosition(pos); JsonTest.getMe().SetStopPoint(_APoint.x, _APoint.x, isStop); }