public void GetAll_MethodFullCountryInfoAllCountriesIsCalled()
        {
            var stubBinding = new BasicHttpBinding();
            var stubEndpointAddress = new EndpointAddress("htt://stubEndPoint");
            var mockCountryInfoServiceSoapTypeClient =
                MockRepository.GenerateStub<CountryInfoServiceSoapTypeClient>(stubBinding, stubEndpointAddress);
            mockCountryInfoServiceSoapTypeClient.Stub(s => s.FullCountryInfoAllCountries()).Return(new tCountryInfo[0]);

            var countriesRepository = new CountriesRepository(mockCountryInfoServiceSoapTypeClient);
            countriesRepository.GetAll();

            mockCountryInfoServiceSoapTypeClient.AssertWasCalled(m => m.FullCountryInfoAllCountries());
        }
        public void GetAll_ReturnsACountriesList()
        {
            var stubCountryInfoServiceSoapTypeClient =
                MockRepository.GenerateStub<CountryInfoServiceSoapTypeClient>(new BasicHttpBinding(),
                                                                              new EndpointAddress("http://stubEndPoint"));
            stubCountryInfoServiceSoapTypeClient.Stub(s => s.FullCountryInfoAllCountries()).Return(new[]
                                                                                                       {
                                                                                                           new tCountryInfo
                                                                                                               {
                                                                                                                   sISOCode
                                                                                                                       =
                                                                                                                       "CountryCode",
                                                                                                                   sName
                                                                                                                       =
                                                                                                                       "CountryName",
                                                                                                                   sCountryFlag
                                                                                                                       =
                                                                                                                       "flag"
                                                                                                               },
                                                                                                           new tCountryInfo
                                                                                                               {
                                                                                                                   sISOCode
                                                                                                                       =
                                                                                                                       "CountryCode2",
                                                                                                                   sName
                                                                                                                       =
                                                                                                                       "CountryName2",
                                                                                                                   sCountryFlag
                                                                                                                       =
                                                                                                                       "flag2"
                                                                                                               }
                                                                                                       });

            var countriesRepository = new CountriesRepository(stubCountryInfoServiceSoapTypeClient);
            List<Country> countries = countriesRepository.GetAll();

            Assert.AreEqual("CountryCode", countries[0].Code);
            Assert.AreEqual("CountryCode2", countries[1].Code);
            Assert.AreEqual("CountryName", countries[0].Name);
            Assert.AreEqual("CountryName2", countries[1].Name);
            Assert.AreEqual("flag", countries[0].Flag);
            Assert.AreEqual("flag2", countries[1].Flag);
        }
        public void GetAll_WhenTheWebServiceIsNotAvailable_AnExceptionIsThrown()
        {
            var stubBinding = new BasicHttpBinding();
            var stubEndpointAddress = new EndpointAddress("http://stubEndPoint");
            var stubCountryInfoServiceSoapTypeClient =
                MockRepository.GenerateStub<CountryInfoServiceSoapTypeClient>(stubBinding, stubEndpointAddress);
            stubCountryInfoServiceSoapTypeClient.Stub(s => s.FullCountryInfoAllCountries()).Throw(new Exception());

            var countriesRepository = new CountriesRepository(stubCountryInfoServiceSoapTypeClient);

            try
            {
                countriesRepository.GetAll();
                Assert.Fail("An exception should has been thrown");
            }
            catch (Exception exception)
            {
                var errorMessage = string.Format("The web service located in {0} is not available.",
                                                 stubEndpointAddress.Uri);
                Assert.AreEqual(errorMessage, exception.Message);
            }
        }
        public void GetAll_ReturnsANotEmptyList()
        {
            var countriesRepository = new CountriesRepository();

            List<Country> countries = countriesRepository.GetAll();

            Assert.AreNotEqual(0, countries.Count);
        }