public void SentenceTypeTimeTest() { var expectedSentenceTypeTimeList = new List <double>() { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 5.0, 10.0 }; BeforeTest(); var type = TP.GetType(); MethodInfo loader = type.GetMethod("GetSentenceTypeTime"); for (int i = 0; i < TEST_SENTENCE_NUM; ++i) { var value = (double)loader.Invoke(TP, new object[] { i }); double diff = value - expectedSentenceTypeTimeList[i]; bool isApproximatelyEqual = Math.Abs(diff) < EPS; Assert.IsTrue(isApproximatelyEqual); } }
private void BeforeTest() { TP = new TypingPerformance(); var type = TP.GetType(); Assert.IsNotNull(TP); // テストデータを挿入 for (int i = 0; i < TEST_SENTENCE_NUM; ++i) { TP.AddOriginSentence(testSentenceOriginList[i]); TP.AddTypedSentenceList(testSentenceTypeList[i]); TP.AddTypeJudgeList(testJudgeList[i]); TP.AddTypeTimeList(testTypeTimeList[i]); } // 正しく挿入されてるかチェック var prop1 = type.GetProperty("OriginSentenceList"); var value1 = (List <string>)prop1.GetValue(TP); for (int i = 0; i < TEST_SENTENCE_NUM; ++i) { Assert.IsTrue(value1[i].Equals(testSentenceOriginList[i])); } var prop2 = type.GetProperty("TypedSentenceList"); var value2 = (List <string>)prop2.GetValue(TP); for (int i = 0; i < TEST_SENTENCE_NUM; ++i) { Assert.IsTrue(value2[i].Equals(testSentenceTypeList[i])); } var prop3 = type.GetProperty("TypeJudgeList"); var value3 = (List <List <int> >)prop3.GetValue(TP); for (int i = 0; i < TEST_SENTENCE_NUM; ++i) { for (int j = 0; j < testJudgeList[i].Count(); ++j) { Assert.IsTrue(value3[i][j] == testJudgeList[i][j]); } } var prop4 = type.GetProperty("TypeTimeList"); var value4 = (List <List <double> >)prop4.GetValue(TP); for (int i = 0; i < TEST_SENTENCE_NUM; ++i) { for (int j = 0; j < testTypeTimeList[i].Count(); ++j) { Assert.IsTrue(value4[i][j] == testTypeTimeList[i][j]); } } }