It may not be something that is even possible, but I thought I would ask anyway. Is there anyway for me to complete this method so that the second call is also missed using the parameter provided in the method I tested?
Stub Method:
public SupportDetails GetSupportDetails(string languageKey) { var result = FindSupportDetails(languageKey); return result ?? FindSupportDetails("en-us"); }
My Current test:
public void GetsUSDetails_IfLangKeyDoesNotExist() { var langKey = "it-it"; _repo.Stub(s => s.FindSupportDetails(langKey)) .Return(supportDetails.Where(sd => sd.LanguageKey == langKey) .SingleOrDefault()); ISupportRepository repo = _repo; var actual = repo.GetSupportDetails(langKey); Assert.AreEqual("en-us", actual.LanguageKey); }
and the supportDetails object used in the test:
supportDetails = new SupportDetails[] { new SupportDetails() { ContactSupportDetailsID = 1, LanguageKey = "en-us" }, new SupportDetails() { ContactSupportDetailsID = 2, LanguageKey = "en-gb" }, new SupportDetails() { ContactSupportDetailsID = 3, LanguageKey = "es-es" } };
source share