Exemplo n.º 1
0
        public void GetCountryName_InvalidCountryID_ReturnsEmptyString()
        {
            int          countryID            = 0;
            PhoneNumbers phoneNumberConverter = new PhoneNumbers();
            string       actual = phoneNumberConverter.GetCountryName(countryID);

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

            Assert.IsEmpty(actual);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
        }