public void GetCountryName_InvalidCountryID_ReturnsEmptyString() { int countryID = 0; PhoneNumbers phoneNumberConverter = new PhoneNumbers(); string actual = phoneNumberConverter.GetCountryName(countryID); Assert.IsEmpty(actual); }
public void GetCountryName_GermanCountryID_ReturnsGermany() { MockRepository mocks = new MockRepository(); IPhoneNumberDataRegistry registryDataProvider = mocks.Stub <IPhoneNumberDataRegistry>(); int countryID = 49; string expected = "Deutschland"; using (mocks.Record()) { registryDataProvider.GetCountryName(countryID); LastCall.Return(expected); } PhoneNumbers phoneNumberConverter = new PhoneNumbers(registryDataProvider); string actual = phoneNumberConverter.GetCountryName(countryID); Assert.AreEqual(expected, actual); }
public void GetCountryName_GermanCountryIDWithoutRegistryAccess_GetsCountryNameFromXML() { MockRepository mocks = new MockRepository(); IPhoneNumberDataXml xmlDataProvider = mocks.StrictMock <IPhoneNumberDataXml>(); IPhoneNumberDataRegistry registryDataProvider = mocks.Stub <IPhoneNumberDataRegistry>(); int countryID = 49; using (mocks.Record()) { // expect that GetCountryName is called xmlDataProvider.GetCountryName(countryID); LastCall.Return("Germany"); } PhoneNumbers phoneNumberConverter = new PhoneNumbers(xmlDataProvider, registryDataProvider); phoneNumberConverter.GetCountryName(countryID); mocks.VerifyAll(); }
public void GetCountryName_InvalidCountryID_ReturnsEmptyString() { int countryID = 0; PhoneNumbers phoneNumberConverter = new PhoneNumbers(); string actual = phoneNumberConverter.GetCountryName(countryID); Assert.IsEmpty(actual); }
public void GetCountryName_GermanCountryID_ReturnsGermany() { MockRepository mocks = new MockRepository(); IPhoneNumberDataRegistry registryDataProvider = mocks.Stub<IPhoneNumberDataRegistry>(); int countryID = 49; string expected = "Deutschland"; using (mocks.Record()) { registryDataProvider.GetCountryName(countryID); LastCall.Return(expected); } PhoneNumbers phoneNumberConverter = new PhoneNumbers(registryDataProvider); string actual = phoneNumberConverter.GetCountryName(countryID); Assert.AreEqual(expected, actual); }
public void GetCountryName_GermanCountryIDWithoutRegistryAccess_GetsCountryNameFromXML() { MockRepository mocks = new MockRepository(); IPhoneNumberDataXml xmlDataProvider = mocks.StrictMock<IPhoneNumberDataXml>(); IPhoneNumberDataRegistry registryDataProvider = mocks.Stub<IPhoneNumberDataRegistry>(); int countryID = 49; using (mocks.Record()) { // expect that GetCountryName is called xmlDataProvider.GetCountryName(countryID); LastCall.Return("Germany"); } PhoneNumbers phoneNumberConverter = new PhoneNumbers(xmlDataProvider, registryDataProvider); phoneNumberConverter.GetCountryName(countryID); mocks.VerifyAll(); }