Beispiel #1
0
        public void GetCountryName_InvalidCountryID_ReturnsEmptyString()
        {
            int          countryID            = 0;
            PhoneNumbers phoneNumberConverter = new PhoneNumbers();
            string       actual = phoneNumberConverter.GetCountryName(countryID);

            Assert.IsEmpty(actual);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        public void GetCountryName_InvalidCountryID_ReturnsEmptyString()
        {
            int countryID = 0;
            PhoneNumbers phoneNumberConverter = new PhoneNumbers();
            string actual = phoneNumberConverter.GetCountryName(countryID);

            Assert.IsEmpty(actual);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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();
        }