Ejemplo n.º 1
0
        public void GetCountryNameByNumber_PhoneNumberInDresdenGermanyWithoutRegistryAccess_GetsCountryNameFromXML()
        {
            MockRepository           mocks                = new MockRepository();
            IPhoneNumberDataXml      xmlDataProvider      = mocks.StrictMock <IPhoneNumberDataXml>();
            IPhoneNumberDataRegistry registryDataProvider = mocks.Stub <IPhoneNumberDataRegistry>();

            string number = "+493511234567";

            using (mocks.Record())
            {
                xmlDataProvider.GetCountryCode("4935");
                LastCall.Return("49");
                xmlDataProvider.GetAreaCode("+493511234567");
                LastCall.Return("+49351");
                xmlDataProvider.GetCountryID("+49351");
                LastCall.Return("49");
                xmlDataProvider.GetCountryName(49);
                LastCall.Return("Germany");
            }

            PhoneNumbers phoneNumberConverter = new PhoneNumbers(xmlDataProvider, registryDataProvider);

            phoneNumberConverter.GetCountryNameByNumber(number);

            mocks.VerifyAll();
        }
Ejemplo n.º 2
0
        public void GetCountryNameByNumber_PhoneNumberInDresdenGermany_ReturnsGermany()
        {
            MockRepository           mocks                = new MockRepository();
            IPhoneNumberDataXml      xmlDataProvider      = mocks.Stub <IPhoneNumberDataXml>();
            IPhoneNumberDataRegistry registryDataProvider = mocks.Stub <IPhoneNumberDataRegistry>();

            string number   = "+493511234567";
            string expected = "Deutschland";

            using (mocks.Record())
            {
                xmlDataProvider.GetCountryCode("4935");
                LastCall.Return("49");
                xmlDataProvider.GetAreaCode("+493511234567");
                LastCall.Return("+49351");
                xmlDataProvider.GetCountryID("+49351");
                LastCall.Return("49");

                registryDataProvider.GetCountryName(49);
                LastCall.Return(expected);
            }

            PhoneNumbers phoneNumberConverter = new PhoneNumbers(xmlDataProvider, registryDataProvider);
            string       actual = phoneNumberConverter.GetCountryNameByNumber(number);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
0
        public void GetCountryNameByNumber_InvalidNumber_ReturnsEmptyString()
        {
            string       number = "abcd";
            PhoneNumbers phoneNumberConverter = new PhoneNumbers();
            string       actual = phoneNumberConverter.GetCountryNameByNumber(number);

            Assert.IsEmpty(actual);
        }
Ejemplo n.º 4
0
        public void GetCountryNameByNumber_PhoneNumberInDresdenGermany_ReturnsGermany()
        {
            MockRepository mocks = new MockRepository();
            IPhoneNumberDataXml xmlDataProvider = mocks.Stub<IPhoneNumberDataXml>();
            IPhoneNumberDataRegistry registryDataProvider = mocks.Stub<IPhoneNumberDataRegistry>();

            string number = "+493511234567";
            string expected = "Deutschland";

            using (mocks.Record())
            {
                xmlDataProvider.GetCountryCode("4935");
                LastCall.Return("49");
                xmlDataProvider.GetAreaCode("+493511234567");
                LastCall.Return("+49351");
                xmlDataProvider.GetCountryID("+49351");
                LastCall.Return("49");

                registryDataProvider.GetCountryName(49);
                LastCall.Return(expected);
            }

            PhoneNumbers phoneNumberConverter = new PhoneNumbers(xmlDataProvider, registryDataProvider);
            string actual = phoneNumberConverter.GetCountryNameByNumber(number);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 5
0
        public void GetCountryNameByNumber_PhoneNumberInDresdenGermanyWithoutRegistryAccess_GetsCountryNameFromXML()
        {
            MockRepository mocks = new MockRepository();
            IPhoneNumberDataXml xmlDataProvider = mocks.StrictMock<IPhoneNumberDataXml>();
            IPhoneNumberDataRegistry registryDataProvider = mocks.Stub<IPhoneNumberDataRegistry>();

            string number = "+493511234567";

            using (mocks.Record())
            {
                xmlDataProvider.GetCountryCode("4935");
                LastCall.Return("49");
                xmlDataProvider.GetAreaCode("+493511234567");
                LastCall.Return("+49351");
                xmlDataProvider.GetCountryID("+49351");
                LastCall.Return("49");
                xmlDataProvider.GetCountryName(49);
                LastCall.Return("Germany");
            }

            PhoneNumbers phoneNumberConverter = new PhoneNumbers(xmlDataProvider, registryDataProvider);
            phoneNumberConverter.GetCountryNameByNumber(number);

            mocks.VerifyAll();
        }
Ejemplo n.º 6
0
        public void GetCountryNameByNumber_InvalidNumber_ReturnsEmptyString()
        {
            string number = "abcd";
            PhoneNumbers phoneNumberConverter = new PhoneNumbers();
            string actual = phoneNumberConverter.GetCountryNameByNumber(number);

            Assert.IsEmpty(actual);
        }