public void コンストラクタテスト() { var shomon = new Shomon("これはペンです。", "This is a pen."); Assert.AreEqual("これはペンです。", shomon.Mondaibun); Assert.AreEqual("This is a pen.", shomon.CorrectAnswers.First().Text); Assert.Null(shomon.MondaiWords); }
public void CorrectAnswersが設定されていない場合のエラー() { { var shomon = new Shomon(); shomon.Id = "id0"; shomon.MondaiWords = new [] { new MondaiWord("a"), new MondaiWord("b"), }; Assert.Throws<MondaiDocumentException>(() => { shomon.Validate(); }); } }
public void 正解判定テスト() { { var shomon = new Shomon("これはペンです。", "This is a pen."); Assert.False(shomon.正解判定(new [] { "a", "b", }.Select(x => new MondaiWord(x)).ToArray())); Assert.True(shomon.正解判定(new [] { "This", "is", "a", "pen", ".", }.Select(x => new MondaiWord(x)).ToArray())); } { var shomon = new Shomon("これはペンです。", "Is this a pen?"); Assert.True(shomon.正解判定(new [] { "Is", "this", "a", "pen", "?", }.Select(x => new MondaiWord(x)).ToArray())); } { var shomon = new Shomon("aaa", "Is Mr. White a doctor? No, he isn't. He isn't a doctor."); Assert.True(shomon.正解判定(new [] { "Is", "Mr.", "White", "a", "doctor", "?", "No", ",", "he", "isn't", ".", "He", "isn't", "a", "doctor", ".", }.Select(x => new MondaiWord(x)).ToArray())); } }
public void 発音記号の妥当性検証() { { var shomon = new Shomon("ball", "abc"); shomon.Id = "id"; shomon.MondaiWords = ChumonCreator.GetMondaiWords("abc"); shomon.Validate(); } { var shomon = new Shomon("ball", "b"); shomon.Id = "id"; shomon.MondaiWords = ChumonCreator.GetMondaiWords("b"); shomon.Validate(); } { var shomon = new Shomon("ball", "bˈ"); shomon.Id = "id"; shomon.MondaiWords = ChumonCreator.GetMondaiWords("bˈ"); shomon.Validate(); } { var shomon = new Shomon("ball", "bˈɔ"); shomon.Id = "id"; shomon.MondaiWords = ChumonCreator.GetMondaiWords("bˈɔ"); shomon.Validate(); } { var shomon = new Shomon("ball", "bˈɔː"); shomon.Id = "id"; shomon.MondaiWords = ChumonCreator.GetMondaiWords("bˈɔː"); shomon.Validate(); } { var shomon = new Shomon("ball", "bˈɔːl"); shomon.Id = "id"; shomon.MondaiWords = ChumonCreator.GetMondaiWords("bˈɔːl"); shomon.Validate(); } }