/// <summary> /// 異常時実行 /// </summary> /// <param name="filePass">ファイルパス</param> /// <param name="errorCode">エラーコード</param> private void AssertFail(string filePass, ErrorCode errorCode) { try { Kadai.CalcScoreSum(filePass); } catch (KadaiException e) { Assert.AreEqual(e.ErrorCode, errorCode); } }
/// <summary> /// 異常時実行 /// </summary> /// <param name="filePass">ファイルパス</param> /// <param name="errorCode">エラーコード</param> private void AssertFail(string inputFilePass, string outputFilePass, ErrorCode errorCode) { try { Kadai.PrintMaxScore(inputFilePass, outputFilePass); } catch (KadaiException e) { Assert.AreEqual(e.ErrorCode, errorCode); } }
/// <summary> /// 正常時実行 /// </summary> /// <param name="fileName">ファイル名</param> /// <param name="ans">解答</param> private void AssertEquals(string fileName) { string inputFilePass = INPUT_PASS + fileName; string outputFilePass = OUTPUT_PASS + fileName; string expectFilePass = EXPECT_PASS + fileName; Kadai.PrintMaxScore(inputFilePass, outputFilePass); FileStream fs1 = new FileStream(expectFilePass, FileMode.Open); FileStream fs2 = new FileStream(outputFilePass, FileMode.Open); int byte1; int byte2; try { if (fs1.Length == fs2.Length) { byte1 = fs1.ReadByte(); byte2 = fs2.ReadByte(); if (byte1 != byte2) { Assert.Fail(); } while (byte1 != -1 || byte2 != -1) { byte1 = fs1.ReadByte(); byte2 = fs2.ReadByte(); if (byte1 != byte2) { Assert.Fail(); } } } } finally { fs1.Close(); fs2.Close(); } }
/// <summary> /// 正常時実行 /// </summary> /// <param name="fileName">ファイル名</param> /// <param name="ans">解答</param> private void AssertEquals(string fileName, int ans) { string filePass = PASS + fileName; Assert.AreEqual(Kadai.CalcScoreSum(filePass), ans); }