public void CreateTest() { var r = GetRandom.Object <GoodsData>(); var o = GoodFactory.Create(r.ID, r.Name, r.Code, r.Description, r.Price, r.Type, r.ImgData, r.ImgName, r.ValidFrom, r.ValidTo); Assert.AreEqual(r.Name, o.Data.Name); Assert.AreEqual(r.ID, o.Data.ID); Assert.AreEqual(r.Description, o.Data.Description); Assert.AreEqual(r.Code, o.Data.Code); Assert.AreEqual(r.Price, o.Data.Price); Assert.AreEqual(r.Type, o.Data.Type); Assert.AreEqual(r.ImgData, o.Data.ImgData); Assert.AreEqual(r.ImgName, o.Data.ImgName); Assert.AreEqual(r.ValidFrom, o.Data.ValidFrom); Assert.AreEqual(r.ValidTo, o.Data.ValidTo); }
public async Task <IActionResult> Create([Bind(properties)] GoodView c, IFormFile file) { if (!ModelState.IsValid) { return(View(c)); } var(imgData, imgName) = FileHelper.ParseImageToBytes(file); c.ID = Guid.NewGuid().ToString(); c.Code = GetRandom.Code(); await changeCodeIfInUse(c.Code, c); await validateId(c.ID, ModelState); var o = GoodFactory.Create(c.ID, c.Name, c.Code, c.Description, c.Price, c.Type, imgData, imgName); await repository.AddObject(o); return(RedirectToAction("Index")); }
public void CreateWithNullTest() { var o = GoodFactory.Create(null); Assert.IsNotNull(o); }
protected override Good createObject(GoodsData r) => GoodFactory.Create(r);