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); } }
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); } }
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()); } }
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(); }
public async void Task_Return_GetAllBrands() { var controller = new BrandController(context); var data = await controller.Get(); Assert.IsType <OkObjectResult>(data); }
public FormAddNewModel() { InitializeComponent(); _modelController = new ModelController(); _brandController = new BrandController(); AddBrandToList(); }
public FormCarAdd() { InitializeComponent(); _cc = new CarController(); _bc = new BrandController(); _mc = new ModelController(); }
private void Limpiar() { BrandController branCont = new BrandController(); grdcList.DataSource = branCont.getBrand(); txtName.Text = ""; }
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); }
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); }
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); }
public FormModelList() { InitializeComponent(); _mc = new ModelController(); _bc = new BrandController(); FormBrandAdd.BranAdded += BrandLoad; FormModelAdd.ModelAdded += ListLoad; }
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); }
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); }
public FormAddCar() { InitializeComponent(); _carController = new CarController(); _brandController = new BrandController(); _modelController = new ModelController(); FormUtils.AddBrandToList(ref comboBoxBrand, ref _brandController); }
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>")); }
public ActionResult Edit(Brand brand) { if (BrandController.EditBrands(brand.ID, brand.brandName, brand.brandDescription, brand.brandHomePage)) { return(RedirectToAction("Index")); } return(View()); }
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(); }
public FormClient() { InitializeComponent(); _brandController = new BrandController(); _modelController = new ModelController(); _carController = new CarController(); btnBuy.Enabled = false; Load += FormClient_Load; }
public FormCarListClient() { InitializeComponent(); btnSearch.Image = Image.FromFile(_filePath); _brandController = new BrandController(); _modelController = new ModelController(); FormUtils.AddBrandToList(ref comboBoxBrands, ref _brandController); FormUtils.AddCarsToListView(lvCarList); }
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; } }
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); }
// 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)); }
public static BrandController Fixture() { BrandController controller = new BrandController(new BrandRepository(), "", new LoginView()); return controller; }