[TestCase("TestDataLangs.xml", "en", "английский")] // верно ли задан атрибут? public void LangByKey_ValidXmlResponse_WorksCorrectly(string testDataFile, string key, string expect) { ITranslateAPI fakeYandexAPI = Substitute.For <ITranslateAPI>(); string responseLangs = File.ReadAllText(testDataFile); fakeYandexAPI.GetLangs(Arg.Any <string>(), Arg.Any <string>()).Returns(responseLangs); ITranslatorModel model = new TranslatorModel("api_key", "ui", fakeYandexAPI); var l = model.LangByKey(key); Assert.AreEqual(l.Value, expect); }
public void Translate_ValidXmlResponse_WorksCorrectly( string text, string sourceLang, string testDataFile, string testDetectDataFile, string testDataLangsFile, string expect) { ITranslateAPI fakeYandexAPI = Substitute.For <ITranslateAPI>(); string responseLangs = File.ReadAllText(testDataLangsFile); string responseTranslate = File.ReadAllText(testDataFile); string responseDetect = File.ReadAllText(testDetectDataFile); fakeYandexAPI.GetLangs(Arg.Any <string>(), Arg.Any <string>()).Returns(responseLangs); fakeYandexAPI.Detect(Arg.Any <string>(), text).Returns(responseDetect); fakeYandexAPI.Translate(Arg.Any <string>(), text, sourceLang).Returns(responseTranslate); ITranslatorModel model = new TranslatorModel("api_key", "ui", fakeYandexAPI); model.SetTargetLang(model.LangByKey(sourceLang.Split('-')[1])); string actual = model.Translate(text); Assert.AreEqual(expect, actual, "Model.Translate() works."); }