Example #1
0
        public void Setup()
        {
            //add currency
            var britishCurrency = new Entities.Currencies.Currency
            {
                Name = "British Pound",
                Code = "GBP",
                Format = "£0.00"
            };
            _currencyService.Add(britishCurrency);

            var taxRate = new TaxRate
            {
                Name = "VAT",
                Code = "S",
                Percentage = 20m
            };
            _taxRateManager.Add(taxRate);

            var uk = new Country
            {
                Name = "United Kingdom",
                ISOTwoLetterCode = "GB"
            };
            _countryService.AddCountry(uk);
        }
        public void CountryController_AddPost_ReturnsRedirectToIndex()
        {
            var country = new Country() { Name = "Great Britain", ISOTwoLetterCode = "GB" };

            var result = _countryController.Add_POST(country);

            result.RouteValues["action"].Should().Be("Index");
        }
        public void RegionController_Add_ModelShouldHavePassedCountrySet()
        {
            var country = new Country();
            
            var result = _regionController.Add(country);

            result.Model.As<Region>().Country.Should().Be(country);
        }
        public void RegionController_Add_ShouldReturnPartialViewResult()
        {
            var country = new Country();
            
            var result = _regionController.Add(country);

            result.Should().BeOfType<PartialViewResult>();
        }
        public void RegionController_Add_ShouldReturnANewRegionAsAModel()
        {
            var country = new Country();
            
            var result = _regionController.Add(country);

            result.Model.Should().BeOfType<Region>();
        }
Example #6
0
        public void CountryService_AddCountry_ShouldAddCountryToSession()
        {
            var country = new Country { Name = "UK", ISOTwoLetterCode = "GB" };

            _countryService.AddCountry(country);

            Session.QueryOver<Country>().List().Should().HaveCount(1);
        }
        public void CountryController_AddPost_CallsAddCountryWithPassedValue()
        {
            var country = new Country() { Name = "Great Britain", ISOTwoLetterCode = "GB" };

            _countryController.Add_POST(country);

            A.CallTo(() => _countryService.AddCountry(country)).MustHaveHappened();
        }
Example #8
0
 public void AddCountry(Country country)
 {
     //_session.Transact(
     //    session =>
     //    session.Save(new Country {ISOTwoLetterCode = countryCode, Name = CountryIsoCodeAndNames[countryCode]}));
     _session.Transact(
        session =>
        session.Save(country));
 }
Example #9
0
        public void CountryService_Delete_ShouldRemoveCountryFromSession()
        {
            var country = new Country {Name = "UK", ISOTwoLetterCode = "GB"};
            Session.Transact(session => session.Save(country));

            _countryService.Delete(country);
            Session.Evict(country);

            Session.QueryOver<Country>().RowCount().Should().Be(0);
        }
Example #10
0
        public void CountryService_Save_ShouldUpdateCountry()
        {
            var country = new Country {Name = "UK", ISOTwoLetterCode = "GB"};
            Session.Transact(session => session.Save(country));
            country.Name = "United Kingdom";

            _countryService.Save(country);
            Session.Evict(country);

            Session.QueryOver<Country>().SingleOrDefault().Name.Should().Be("United Kingdom");
        }
Example #11
0
        public string ProcessCountries(NopCommerceDataReader dataReader, 
            NopImportContext nopImportContext)
        {
            var countryDatas = dataReader.GetCountryData();
            _session.Transact(session =>
            {
                foreach (CountryData countryData in countryDatas)
                {
                    var country = new Country
                    {
                        Name = countryData.Name,
                        ISOTwoLetterCode = countryData.IsoCode
                    };
                    session.Save(country);
                    nopImportContext.AddEntry(countryData.Id, country);
                }
            });

            return string.Format("{0} countries processed", countryDatas.Count);
        }
        public void CountryController_EditPost_ShouldCallSaveCountry()
        {
            var country = new Country();

            _countryController.Edit_POST(country);

            A.CallTo(() => _countryService.Save(country)).MustHaveHappened();
        }
        public void CountryController_DeletePOST_ShouldRedirectToIndex()
        {
            var country = new Country();

            var result = _countryController.Delete_POST(country);

            result.RouteValues["action"].Should().Be("Index");
        }
        public void CountryController_DeletePOST_ShouldCallCountryServiceDeleteOnPassedCountry()
        {
            var country = new Country();

            _countryController.Delete_POST(country);

            A.CallTo(() => _countryService.Delete(country)).MustHaveHappened();
        }
        public void CountryController_Delete_ShouldUsePassedCountryAsModel()
        {
            var country = new Country();

            var delete = _countryController.Delete(country);
            
            delete.Model.Should().Be(country);
        }
        public void CountryController_EditPost_RedirectsToIndex()
        {
            var country = new Country();

            var result = _countryController.Edit_POST(country);

            result.RouteValues["action"].Should().Be("Index");
        }
Example #17
0
 public void Save(Country country)
 {
     _session.Transact(session => session.SaveOrUpdate(country));
 }
Example #18
0
 public void Delete(Country country)
 {
     _session.Transact(session => session.Delete(country));
 }
        public void CountryController_Edit_ReturnsPassedCountryAsModel()
        {
            var country = new Country();

            var result = _countryController.Edit(country);

            result.Model.Should().Be(country);
        }