Ejemplo n.º 1
0
        public void CheckIfBrandExists()
        {
            DbContextOptions <NoodleContext> options =
                new DbContextOptionsBuilder <NoodleContext>()
                .UseInMemoryDatabase("CanCheckIfBrandExists")
                .Options;

            using (NoodleContext context = new NoodleContext(options))
            {
                //arrange
                Brand brand1 = new Brand();
                brand1.Name = "Nongshim";

                Brand brand2 = new Brand();
                brand2.Name = "Ottogi";

                Brand brand3 = new Brand();
                brand3.Name = "Samyang";

                BrandController bc = new BrandController(context);
                context.Brands.AddAsync(brand1);
                context.Brands.AddAsync(brand2);
                context.Brands.AddAsync(brand3);

                context.SaveChanges();

                //act
                var findBrand = bc.BrandExists("Nongshim");

                //assert
                Assert.True(findBrand);
            }
        }
Ejemplo n.º 2
0
        public async void CanUpdateBrand()
        {
            DbContextOptions <NoodleContext> options =
                new DbContextOptionsBuilder <NoodleContext>()
                .UseInMemoryDatabase("CanUpdateBrand")
                .Options;

            using (NoodleContext context = new NoodleContext(options))
            {
                //arrange
                Brand brand = new Brand
                {
                    Id   = 1,
                    Name = "BestestBrand"
                };

                BrandController bc = new BrandController(context);

                //act
                await context.Brands.AddAsync(brand);

                await context.SaveChangesAsync();

                //the seeded data at id# 1 is Nongshim, and this
                //test will change the brand name
                var updatedBrand = bc.Update(1, brand);

                //assert
                Assert.Equal("BestestBrand", brand.Name);
            }
        }
Ejemplo n.º 3
0
        public async void CanCreateNewBrand()
        {
            DbContextOptions <NoodleContext> options =
                new DbContextOptionsBuilder <NoodleContext>()
                .UseInMemoryDatabase("CanCreateNewBrand")
                .Options;

            using (NoodleContext context = new NoodleContext(options))
            {
                //arrange
                Brand brand = new Brand
                {
                    Name    = "Mi Goreng",
                    Country = "Indonesia"
                };
                BrandController bc = new BrandController(context);

                //act
                await context.AddAsync(brand);

                await context.SaveChangesAsync();

                var addedBrand = bc.Create(brand);

                var results = context.Brands.Where(x => x.Name == "Mi Goreng");

                //assert
                Assert.Equal(1, results.Count());
            }
        }
Ejemplo n.º 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            brandinfoinfo   sinfo = new brandinfoinfo();
            BrandController sCon  = new BrandController();
            string          fn    = @"D:\BrandLst.xlsx";

            FileStream fs = File.Open(fn, FileMode.Open, FileAccess.Read);

            IExcelDataReader ir = ExcelReaderFactory.CreateOpenXmlReader(fs);
            DataSet          ds = ir.AsDataSet();

            foreach (DataTable tobj in ds.Tables)
            {
                foreach (DataRow robj in tobj.Rows)
                {
                    //sinfo.BrandID = Convert.ToString(robj[0]);
                    sinfo.BrandName  = Convert.ToString(robj[0]);
                    sinfo.Model      = Convert.ToString(robj[0]);
                    sinfo.CategoryID = Convert.ToString(robj[1]);
                    sCon.InsertBrandByBrandID(sinfo);
                }
            }
            ir.Close();
            fs.Close();
        }
Ejemplo n.º 5
0
        public async void Task_Return_GetAllBrands()
        {
            var controller = new BrandController(context);
            var data       = await controller.Get();

            Assert.IsType <OkObjectResult>(data);
        }
Ejemplo n.º 6
0
 public FormAddNewModel()
 {
     InitializeComponent();
     _modelController = new ModelController();
     _brandController = new BrandController();
     AddBrandToList();
 }
Ejemplo n.º 7
0
 public FormCarAdd()
 {
     InitializeComponent();
     _cc = new CarController();
     _bc = new BrandController();
     _mc = new ModelController();
 }
Ejemplo n.º 8
0
        private void Limpiar()
        {
            BrandController branCont = new BrandController();

            grdcList.DataSource = branCont.getBrand();
            txtName.Text        = "";
        }
Ejemplo n.º 9
0
        public async Task ExceptionTest()
        {
            // Arrange
            IBrandRepository mockRepo = Substitute.For <IBrandRepository>();

            mockRepo
            .GetProductBrandsAsync()
            .ThrowsForAnyArgs(new Exception("Test Exception"));

            IDistributedCache   mockCache   = Substitute.For <IDistributedCache>();
            IOptions <Settings> appSettings = Substitute.For <IOptions <Settings> >();

            var mockLocalizer = new MockStringLocalizer <BrandController>();

            IBrandApi theApi     = new BrandApi(appSettings, mockRepo);
            var       controller = new BrandController(mockCache, theApi, mockLocalizer);

            //// Act
            var actionResult = await controller.Get();

            var objectResult = actionResult as Microsoft.AspNetCore.Mvc.ObjectResult;

            ////// Assert
            Assert.NotNull(objectResult);
            Assert.Equal(objectResult.StatusCode, (int)System.Net.HttpStatusCode.InternalServerError);
        }
        public void Task_ProductDisplay_Return_ViewResult()
        {
            var           controller = new BrandController(context);
            var           BrandId    = 1;
            IActionResult data       = controller.DisplayByBrand(BrandId);

            Assert.IsType <ViewResult>(data);
        }
Ejemplo n.º 11
0
        public async void Task_DeleteBrand_Return_NotFoundResult()
        {
            var controller = new BrandController(context);
            var id         = 10;
            var data       = await controller.Delete(id);

            Assert.IsType <NotFoundResult>(data);
        }
Ejemplo n.º 12
0
        public async void Task_DeleteBrand_Retun_OkResult()
        {
            var controller = new BrandController(context);
            int id         = 6;
            var data       = await controller.Delete(id);

            Assert.IsType <OkObjectResult>(data);
        }
        public async void Task_GetBrandById_BadResult()
        {
            var controller = new BrandController(context);
            int?id         = null;
            var data       = await controller.Get(id);

            Assert.IsType <BadRequestResult>(data);
        }
Ejemplo n.º 14
0
 public FormModelList()
 {
     InitializeComponent();
     _mc = new ModelController();
     _bc = new BrandController();
     FormBrandAdd.BranAdded  += BrandLoad;
     FormModelAdd.ModelAdded += ListLoad;
 }
Ejemplo n.º 15
0
 public FormCarUpdate(CarDTO dto)
 {
     InitializeComponent();
     _dto = dto;
     _cc  = new CarController();
     _bc  = new BrandController();
     _mc  = new ModelController();
 }
        public void Task_Index_Return_ViewResult()
        {
            var controller = new BrandController(context);

            IActionResult data = controller.Display();

            Assert.IsType <ViewResult>(data);
        }
        public void verifyBrandCount()
        {
            var c      = new BrandController();
            var result = Assert.IsType <Microsoft.AspNetCore.Mvc.ViewResult>(c.List());
            var model  = Assert.IsType <List <DigitalShoppingTakkala.Models.Brand> >(result.Model);

            Assert.Equal(2, model.Count());
        }
        public async void Task_GetBrandBy_Id_Return_NoResult()
        {
            var controller = new BrandController(context);
            var BrandId    = 6;
            var data       = await controller.Get(BrandId);

            Assert.IsType <NotFoundResult>(data);
        }
Ejemplo n.º 19
0
        public async void Task_DeleteBrand_Retun_BadRequestResult()
        {
            var controller = new BrandController(context);
            int?id         = null;
            var data       = await controller.Delete(id);

            Assert.IsType <BadRequestResult>(data);
        }
        public async void Task_GetBrandBy_Id_Return_OkResult()
        {
            var controller = new BrandController(context);
            var BrandId    = 1;
            var data       = await controller.Get(BrandId);

            Assert.IsType <OkObjectResult>(data);
        }
Ejemplo n.º 21
0
 public FormAddCar()
 {
     InitializeComponent();
     _carController   = new CarController();
     _brandController = new BrandController();
     _modelController = new ModelController();
     FormUtils.AddBrandToList(ref comboBoxBrand, ref _brandController);
 }
Ejemplo n.º 22
0
 public ActionResult Delete(int id)
 {
     if (BrandController.DeleteBrands(id))
     {
         return(RedirectToAction("Index"));
     }
     return(Content("<script language='javascript' type='text/javascript'>alert('Không thể xóa được');</script>"));
 }
Ejemplo n.º 23
0
 public ActionResult Edit(Brand brand)
 {
     if (BrandController.EditBrands(brand.ID, brand.brandName, brand.brandDescription, brand.brandHomePage))
     {
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Ejemplo n.º 24
0
 public void Init()
 {
     _brandRepositoryMock         = new Mock <IBrandRepository>();
     _interiorColorRepositoryMock = new Mock <IInteriorColorRepository>();
     _exteriorColorRepositoryMock = new Mock <IExteriorColorRepository>();
     _mapperMock = new Mock <IMapper>();
     _sut        = new BrandController(_brandRepositoryMock.Object, _exteriorColorRepositoryMock.Object,
                                       _interiorColorRepositoryMock.Object, _mapperMock.Object);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandController      brControl = new BrandController();
            List <brandinfoinfo> lsBran    = new List <brandinfoinfo>();

            lsBran = brControl.SelectAllBrandInfo();
            GridView1.DataSource = lsBran;
            GridView1.DataBind();
        }
Ejemplo n.º 26
0
 public FormClient()
 {
     InitializeComponent();
     _brandController = new BrandController();
     _modelController = new ModelController();
     _carController   = new CarController();
     btnBuy.Enabled   = false;
     Load            += FormClient_Load;
 }
Ejemplo n.º 27
0
        public FormCarListClient()
        {
            InitializeComponent();
            btnSearch.Image  = Image.FromFile(_filePath);
            _brandController = new BrandController();
            _modelController = new ModelController();
            FormUtils.AddBrandToList(ref comboBoxBrands, ref _brandController);

            FormUtils.AddCarsToListView(lvCarList);
        }
Ejemplo n.º 28
0
 private void spIdMarca_EditValueChanged(object sender, EventArgs e)
 {
     if (spIdMarca.Value > 0)
     {
         Brand           bran     = new Brand();
         BrandController branCont = new BrandController();
         bran         = branCont.getBrandXId((int)spIdMarca.Value);
         txtName.Text = "" + bran.NameBrand;
     }
 }
Ejemplo n.º 29
0
        public BrandController GetController()
        {
            var brandRepository = new BrandRepository();

            _controller = new BrandController(new BrandService(brandRepository), brandRepository);

            _controller.Request = new HttpRequestMessage();
            _controller.Request.SetConfiguration(new HttpConfiguration());

            return(_controller);
        }
Ejemplo n.º 30
0
        // GET: Admin/BrandAdmin
        public ActionResult Index(string SearchString)
        {
            List <Brand> brands = new List <Brand>();

            brands = BrandController.ViewBrands();
            if (!String.IsNullOrEmpty(SearchString))
            {
                brands = BrandController.SearchBrands(SearchString);
            }
            return(View(brands));
        }
Ejemplo n.º 31
0
 public static BrandController Fixture()
 {
     BrandController controller = new BrandController(new BrandRepository(), "", new LoginView());
     return controller;
 }