Exemplo n.º 1
0
        protected Brand MapBrandByName(string brandName, bool createIfNotFound)
        {
            var brand = BrandApplicationService.FindBrand(brandName, true);

            if (brand == null)
            {
                Log.Debug("Brand not found when mapping: {0}", brandName);
                brand = new Brand {
                    BrandName = brandName, LastUpdated = DateTime.Now
                };
            }
            return(brand);
        }
        public void ShouldFindOneBrandByName()
        {
            var brand1 = BrandBuilder.BuildBrand("Brand1");
            var brand2 = BrandBuilder.BuildBrand("Brand2");

            using (var context = GetNewDataContext())
            {
                var brands = context.GetTable <Brand>();
                brands.InsertOnSubmit(brand1);
                brands.InsertOnSubmit(brand2);
                context.SubmitChanges();
            }

            var brand = _brandApplicationService.FindBrand("Brand1", false);

            brand.BrandName.ShouldEqual(brand1.BrandName);
        }