public void ProductRepositoryAddNewItemSaveItem() { //Arrange var unitOfWork = new MainBCUnitOfWork(); IProductRepository productRepository = new ProductRepository(unitOfWork); var book = new Book() { Id = IdentityGenerator.NewSequentialGuid(), ISBN = "ABC", Publisher = "Krasiss Press", Title = "The book title", UnitPrice = 40, Description = "Any book description", AmountInStock = 1 }; //Act productRepository.Add(book); productRepository.UnitOfWork.Commit(); //Assert var result = productRepository.Get(book.Id); Assert.IsNotNull(result); Assert.IsTrue(result.Id == book.Id); }
public Product Add(ProductRepository spiritRepository) { var product = new Product { Name = "yeee" }; var x = spiritRepository.Add(product); return x; }
private static void InsertProductList(List<Product> list) { var repo = new ProductRepository(); foreach (var item in list) { repo.Add(item); } }
public void IsAvailableTest() { Program.ClearInformation(); IRepository<Product> _productRepository = new ProductRepository(); Product product = new Product(1, "House", "MOPRa,1", "saled"); _productRepository.Add(product); bool actual = Realtor.IsAvailable(product); bool expected = false; Assert.AreEqual(expected, actual); Program.ClearInformation(); }
public void DealTest() { Program.ClearInformation(); IRepository<Product> _productRepository = new ProductRepository(); Product dealingProduct = new Product(1, "House", "MOPRa,1", "for sale"); _productRepository.Add(dealingProduct); Realtor.Deal(_productRepository, dealingProduct.id); Product expected = new Product(1, "House", "MOPRa,1", "saled"); Product actual = _productRepository.GetItem(dealingProduct.id); Assert.AreEqual(true, true); }
//[TestMethod] public void AddProduct() { // Arrange Product prd = new Product() { Type = 3, Name = "ccc", Price = 11, LinkUrl = "http://www.bb.com" }; ProductRepository repository = new ProductRepository(); repository.Add(prd); }
static void Main(string[] args) { List<Product> result; using (var db = new EfUnitOfWork(new InventoryContext())) { var repo = new ProductRepository(db); repo.Add(new Product { Name = "One"}); repo.Add(new Product { Name = "Two" }); repo.Add(new Product { Name = "Three" }); repo.Add(new Product { Name = "Four" }); db.Commit(); result = repo.All().ToList(); } foreach (var item in result) { System.Console.WriteLine(item.Name); } System.Console.ReadLine(); }
public void ProductRepositoryAddNewItemSaveItem() { //Arrange var unitOfWork = new MainBcUnitOfWork(); IProductRepository productRepository = new ProductRepository(unitOfWork); var book = new Book("The book title", "Any book description", "Krasis Press", "ABC"); book.ChangeUnitPrice(40); book.IncrementStock(1); book.GenerateNewIdentity(); //Act productRepository.Add(book); unitOfWork.Commit(); }
public IActionResult Add(Product product) { try { _productRepository.Add(product); return(RedirectToAction("Edit", new { id = product.ProductId })); } catch { return(View("AddOrEdit", new ProductAddOrEditViewModel() { AddsNew = true, ProductCategories = _categoryRepository.GetAllCategories(), Suppliers = _supplierRepository.GetAllSuppliers(), Product = product, })); } }
public void IsRepositoryAddsProduct() { Product productToInsert = new Product { Id = 3, inStock = true, Name = "Salt", Price = 17 }; Repo.Add(productToInsert); // If Product inserts successfully, //number of records will increase to 3 var result = Repo.GetProducts(); var numberOfRecords = result.Cast <Product>().ToList().Count; Assert.AreEqual(3, numberOfRecords); }
private void AddProduct() { Product productToAdd = new Product(); SaveDataToProduct(productToAdd, out string message); if (message != "") { MainWindow.ShowPopup(message); } else if (ProductRepository.Add(productToAdd)) { MainWindow.ShowPopup("Add success"); } else { MainWindow.ShowPopup("Add failed"); } }
private static void AddABucket(ProductRepository productRepository) { var bucket = new Product { Price = 15.78m, LocalizedPropertySets = new List <LocalizedProductPropertySet> { new LocalizedProductPropertySet { CultureCode = "de-de", Name = "Eimer", Description = "Ein Eimer dient zum Transport von Wasser" } } }; productRepository.Add(bucket); }
public int Add(ProductDto productModel, List <IFormFile> files) { if (files != null) { var file = files.FirstOrDefault(); var path = Path.Combine(_hostingEnvironment.ContentRootPath, "wwwroot\\" + file.FileName); using (FileStream filestream = File.Create(path)) { file.CopyTo(filestream); filestream.Flush(); productModel.ImagePath = "//" + file.FileName; } } var productEntity = Mapper.Map <ProductDto, Product>(productModel); var addProductResult = _repo.Add(productEntity); return(addProductResult); }
public void RepositoryUpdateTest() { Program.ClearInformation(); IRepository <Product> _productRepository = new ProductRepository(); Product product = new Product(1, "House", "MOPRa,1", "for sale"); _productRepository.Add(product); product.status = "saled"; _productRepository.Update(product); Product actual = _productRepository.GetItem(product.id); Product expected = new Product(1, "House", "MOPRa,1", "saled"); Assert.AreEqual(actual.id, product.id); Assert.AreEqual(actual.name, product.name); Assert.AreEqual(actual.status, product.status); Assert.AreEqual(actual.address, product.address); Program.ClearInformation(); }
public void UpdateInvalidIdProductCategoryRepository() { var p = new Product() { ProductId = 1, Name = "Testing product", Category = new ProductCategory() { ProductCategoryId = 1, Name = "Testing category" }, Price = 200.0, ImageUrl = "Test URL", Description = "This is a description" }; using (var context = new GamersUnitedContext(GetOption(System.Reflection.MethodBase.GetCurrentMethod().Name))) { context.Database.EnsureDeleted(); var repo = new ProductRepository(context, mockProductCategoryRepo.Object); var np = repo.Add(p); Assert.Equal(1, context.Product.Count()); var tmp = new Product() { ProductId = 1, Name = "Testing monkey", Category = new ProductCategory() { Name = "monkey category" }, Price = 100.0, ImageUrl = "Test monkey", Description = "This is a monkey" }; Assert.Throws <ArgumentOutOfRangeException>(() => { repo.Update(np.ProductId++, tmp); }); } }
public void Test_Add_CheckAdditionOfNewProduct_WhenAdded() { //Arrange Product newProduct = new Product(); var mockSet = new Mock <IDbSet <Product> >(); var mockContext = new Mock <BookSaleEntities>(); mockContext.Setup(m => m.Products).Returns(mockSet.Object); //Act var testClass = new ProductRepository(mockContext.Object); testClass.Add(newProduct); //Assert mockSet.Verify(m => m.Add(It.IsAny <Product>()), Times.Once()); }
public void IsRepositoryAddMethods() { // // TODO: Add test logic here // Product productInsert = new Product { ProdId = 3, ProductName = "Shirt", ProductPrice = 250.50, Instock = true }; repo.Add(productInsert); var result = repo.GetProducts(); var numberofResult = result.Count; Assert.AreEqual(3, numberofResult); }
public void ProductRepositoryAddTest() { //Arrange Product product = new Product { Id = Guid.NewGuid(), Name = "HUAWEI", Description = "HUAWEI HONOR", Price = 8888.88m, DeliveryPrice = 8.88m }; //Action using (ProductRepository productRepository = new ProductRepository()) { //Assert Assert.AreEqual(1, productRepository.Add(product)); } }
public void AddNewProduct(Product product) { // Validation if (product.Name.Trim() == string.Empty || product.ProductCategory == null || product.Manufacturer == null) { throw new Exception("Can't add product!!!"); } var newProduct = new Models.Inventory.Product { Name = product.Name, ManufacturerID = product.Manufacturer.ManufacturerID, ProductCategoryID = product.ProductCategory.ProductCategoryID, ProductNumber = product.ProductNumber, UnitMeasureCode = "PC" }; _productRepository.Add(newProduct); _context.CommitChanges(); }
public void AddTest() { DataContext dataContext = new DataContext { Products = new List <Product>() }; ProductRepository productRepository = new ProductRepository(dataContext); productRepository.Add(new Product { Id = 1, AllowedFromDate = new DateTime(2000, 1, 1), Author = "21Studios", IsLocked = false, Name = "Game 1", Price = 20.4f }); Assert.IsNotNull(productRepository.Get(1)); }
public void CanAddNewProduct() { var product = new Product { Name = "Apple", Category = "Fruites" }; var repo = new ProductRepository(); repo.Add(product); // use session to try to load the product using (var session = _sessionFactory.OpenSession()) { var fromDb = session.Get <Product>(product.Id); Assert.IsNotNull(fromDb); Assert.AreNotSame(product, fromDb); Assert.AreEqual(product.Name, fromDb.Name); Assert.AreEqual(product.Category, fromDb.Category); } }
public void CanAddNewProduct() { var product = new Product { Name = "Apple", Category = "Fruits", }; var repository = new ProductRepository(); repository.Add(product); using var session = _sessionFactory.OpenSession(); var actual = session.Get <Product>(product.Id); Assert.IsNotNull(actual); Assert.AreNotSame(product, actual); Assert.AreEqual(product.Name, actual.Name); Assert.AreEqual(product.Category, actual.Category); }
private void AgregarProducto(object sender, RoutedEventArgs e) { var categoria = new CategoriaRepository().GetOne(1); var product = new Product { ProductName = "aaaaa", CategoryID = 1, UnitPrice = 50, UnitsInStock = 300 }; var productRepository = new ProductRepository(); productRepository.Add(product); var newProductCreated = new ProductCreated(product.ProductID, product.ProductName, product.UnitPrice, product.UnitsInStock, categoria.CategoryName); Publisher.Publish(Channels.ChannelNewProduct, newProductCreated); }
public void Can_add_new_product() { var product = new Product { Name = "Apple", Category = "Fruit" }; IProductRepository repository = new ProductRepository(); repository.Add(product); // use session to try to load the product using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get <Product>(product.Id); // Test that the product was successfully inserted Assert.IsNotNull(fromDb); Assert.AreNotSame(product, fromDb); Assert.AreEqual(product.Name, fromDb.Name); Assert.AreEqual(product.Category, fromDb.Category); } }
public void TestMethod1() { var context = new EntityFrameworkRepositoryContext(); var pro = new ProductRepository(context); var entity = new Product() { Name = "TEST", Description = "TEST Description", UnitPrice = 15.00M, IsNew = true, ImageUrl = "www.tujia.com" }; pro.Add(entity); //context.Commit(); // int x = 0; }
public void Add_SingleItem_ItemAddedSuccessfully() { using (var context = new DataContext(GetDbContextOptions("Add_SingleItem_ItemAddedSuccessfully"))) { // Arrange var repo = new ProductRepository(context); var itemToAdd = new Product { ProductId = 124, ProductName = "Phone", UnitPrice = 999, IsActive = true }; // Act repo.Add(itemToAdd); // Assert var item = repo.GetProduct(123).Result; Assert.NotNull(item); Assert.Equal(124, item.ProductId); Assert.Equal("Phone", item.ProductName); } }
public HomeModule() { rep = new ProductRepository(); Get("/", _ => "Hello aaaa"); Get("/test/{name}", args => new Product() { Id = 123, Name = args.name }); Get("/list/", _ => rep.FindAll()); Post("/add", args => { var model = this.Bind <Product>(); model.Created = DateTime.Now; int id = rep.Add(model); return(rep.FindByID(id)); }); }
public void RemoveTest() { Produto item = new Produto() { Referencia = "112233", Nome = "Produto02", Grupo = grupo, SubGrupo = subGrupo, Unidade = unidade, Fabricante = fabricante }; IProductRepository target = new ProductRepository(); target.Add(item); target.Remove(item); // use session to try to load the product using (ISession session = NHibernateHelper.OpenSession()) { var fromDb = session.Get <Produto>(item.Id); Assert.IsNull(fromDb); Assert.AreNotSame(item, fromDb); } }
static void Main(string[] args) { AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); IProductRepository products = new ProductRepository(); products.Add(new Product(7, "Proxying Proxies", "P. Atternborough", Category.Book)); IEnumerable <Product> books = products .GetAll() .Where(p => p.Category == Category.Book); foreach (Product product in books) { Console.WriteLine(product); } Console.WriteLine("Done..."); Console.ReadLine(); }
public void AddNewProductTest() { var product = new Product { Name = "Apple", Category = "Fruits", Discontinued = false }; IProductRepository repository = new ProductRepository(); repository.Add(product); // use session to try to load the product using (ISession session = NHibernateHelper.OpenSession()) { var fromDb = session.Get <Product>(product.Id); // Test that the product was successfully inserted Assert.IsNotNull(fromDb); Assert.AreNotSame(product, fromDb); Assert.AreEqual(product.Name, fromDb.Name); Assert.AreEqual(product.Category, fromDb.Category); } }
public void ProductRepositoryAddAddsProduct() { ProductRepository repository = new ProductRepository(); Product product = new Product(); repository.Add(product); Assert.IsTrue(repository.SequenceEqual(new Product[] { product })); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <ProductRepository> _repository = test.CreateVariable <ProductRepository>(); TestVariable <Product> _product = test.CreateVariable <Product>(); test.Arrange(_repository, Expr(() => new ProductRepository())); test.Arrange(_product, Expr(() => new Product())); test.Act(Expr(_repository, _product, (r, p) => r.Add(p))); test.Assert.IsTrue(Expr(_repository, _product, (r, p) => r.SequenceEqual(new[] { p }))); test.Execute(); }
public void adding_the_product_should_succeed() { //Arrange IProductRepository productRepository = new ProductRepository(); var fixture = new Fixture(); var product = fixture.Create <Product>(); //Act productRepository.Add(product); //Assert var expectedProduct = productRepository.Get(product.Id); expectedProduct.ShouldBeEquivalentTo(product); var products = productRepository.GetAll(); products.Should().NotBeEmpty(); products.Should().Contain(p => p.Id == product.Id); }
public ResultWrapper <ProductReadDto> AddElement(ProductWriteDto finishWriteDto) { ResultWrapper <ProductReadDto> resultWrapper; Finish finish = _finishService.GetOriginalEntity(finishWriteDto.FinishId); List <IError> errors = Dimension.Valid(finishWriteDto.MinHeightInMillimeters, finishWriteDto.MinWeightInMillimeters, finishWriteDto.MinDepthInMillimeters, finishWriteDto.MaxHeightInMillimeters, finishWriteDto.MaxWeightInMillimeters, finishWriteDto.MaxDepthInMillimeters); if (finish == null || errors.Count > 0) { if (finish == null) { resultWrapper = CreateResultWrapper(null); } else { resultWrapper = new ResultWrapper <ProductReadDto>(); } resultWrapper.AddError(errors); return(resultWrapper); } Dimension dimension = new Dimension(finishWriteDto.MinHeightInMillimeters, finishWriteDto.MinWeightInMillimeters, finishWriteDto.MinDepthInMillimeters, finishWriteDto.MaxHeightInMillimeters, finishWriteDto.MaxWeightInMillimeters, finishWriteDto.MaxDepthInMillimeters); ProductWritePoco productWritePoco = new ProductWritePoco() { Dimension = dimension, Finish = finish, Name = finishWriteDto.Name }; Product product = _productRepository.Add(productWritePoco); return(CreateResultWrapper(_productRepository.GetById(product.Id))); }
public void CreateProduct() { _product = new ProductRepository(); var newproduct = new Product(); newproduct.CreatedDate = DateTime.Now; newproduct.Description = "this ia a new product"; newproduct.Height = 20; newproduct.ManufacturedCountryID = 237; newproduct.ModifiedDate = DateTime.Now; newproduct.Name = "Iphone 8"; newproduct.Price = 10000000; newproduct.ProductTypeID = 3; newproduct.StatusID = 1; newproduct.ThumbailCode = "ABC"; newproduct.ThumbailLink = "https://cdn2.tgdd.vn/Products/Images/42/88622/iphone-8-1-200x200.jpg"; newproduct.StoreID = 3; newproduct.Weight = 35; newproduct.Quantity = 50; Assert.IsNotNull(_product.Add(newproduct)); }
private void btnAddFood_Click(object sender, EventArgs e) { try { Product pd = new Product(); pd.ProductName = txtFoodName.Text; pd.ProductPrice = Convert.ToDecimal(txtFoodPriceMasked.Text); ProductRepository pr = new ProductRepository(); pr.Add(pd); MessageBox.Show("Lütfen Yeni Kayıt Oluşturduğunuz Ürün İçin Gerekli Ana Malzemeleri Giriniz."); } catch { MessageBox.Show("Lütfen Bilgileri Doğru Giriniz!"); } cmbSelectFood.Items.Clear(); foreach (var item in db.Products) { cmbSelectFood.Items.Add(item.ProductName); } }
public void ProductShouldAddSuccessfullyToRepo() { var products = Moq.Mock.Of <IEntitySet <Product> >(); var mockFactory = new Mock <IDbContextScopeFactory>(); var mockScope = new Mock <IDbContextScope>(); bool saved = false; mockScope.Setup(e => e.SaveChangesAsync()).Callback(() => { saved = true; }); mockFactory.Setup(e => e.CreateWithTransaction(System.Data.IsolationLevel.Unspecified)).Returns(mockScope.Object); var repo = new ProductRepository(products, mockFactory.Object); var testProduct = new Product { ProductId = "test1234" }; repo.Add(testProduct); Assert.IsTrue(saved); }
private static bool makeProductsTable() { string folder = "Files"; string fileName = "Products.txt"; string route = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, folder, fileName); try { StreamReader file = new StreamReader(route); string line = file.ReadLine(); List <Product> productList = new List <Product>(); while (line != null) { string[] values = line.Split('#'); Client client = new Client(Convert.ToInt64(values[3])); Product product = new Product(values[0], values[1], Convert.ToInt32(values[2]), client); productList.Add(product); line = file.ReadLine(); } IRepository <Product> productRepository = new ProductRepository(); foreach (var p in productList) { productRepository.Add(p); } return(true); } catch (Exception ex) { return(false); } }
public ActionResult Create([Bind(Include = "ProductID,Name,Description,Price,UnitsInStock,ProductImage,StatusID,CategoryID,Notes,ReferenceURL")] Product product, HttpPostedFileBase ProductImage) { if (ModelState.IsValid) { #region Simple File Upload string image = "noImage.png"; if (ProductImage != null) { image = ProductImage.FileName; string picExt = image.Substring(image.LastIndexOf(".")); string[] goodPicExts = new string[] { ".jpg", ".jpeg", ".png", ".gif" }; if (goodPicExts.Contains(picExt.ToLower())) { image = Guid.NewGuid() + picExt; ProductImage.SaveAs(Server.MapPath("~/Content/images/product/" + image)); } else { image = "noImage.png"; } product.ProductImage = image; } #endregion //db.Products.Add(product); //db.SaveChanges(); repo.Add(product); return(RedirectToAction("Index")); } ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", product.CategoryID); ViewBag.StatusID = new SelectList(db.Statuses, "StatusID", "StatusName", product.StatusID); return(View(product)); }
public void RepositoryGetTest() { Program.ClearInformation(); IRepository<Product> _productRepository = new ProductRepository(); Product[] product = new Product[2]; product[0] = new Product(1, "House", "MOPRa,1", "for sale"); product[1] = new Product(2, "House", "MOPRa,2", "for sale"); _productRepository.Add(product[0]); _productRepository.Add(product[1]); IEnumerable<Product> productRepository = _productRepository.GetItems(); for (int i = 1; i <= 2; i++) { Product actual = productRepository.Single(x => x.id == i); Assert.AreEqual(actual.id, product[i - 1].id); Assert.AreEqual(actual.name, product[i - 1].name); Assert.AreEqual(actual.status, product[i - 1].status); Assert.AreEqual(actual.address, product[i - 1].address); } Program.ClearInformation(); }
public static void AutoFilling() { Product[] product = new Product[10]; Client[] client = new Client[10]; Manager[] manager = new Manager[10]; product[0] = new Product(1, "House", "Moskovskaya, 320", "for sale"); product[1] = new Product(2, "Office", "MOPRa, 30", "for sale"); product[2] = new Product(3, "House", "Belorusskaya, 10", "for sale"); product[3] = new Product(4, "Bar", "MOPRa, 3", "for sale"); product[4] = new Product(5, "House", "Leningradskaya, 35", "for sale"); product[5] = new Product(6, "Cafe", "Molodogvardeiskaya, 70", "for sale"); product[6] = new Product(7, "House", "Moskovskaya, 30", "for sale"); product[7] = new Product(8, "Club", "Zelenaya, 11", "for sale"); product[8] = new Product(9, "House", "Lugivaja, 11", "for sale"); product[9] = new Product(10, "Pizzeria", "Pionerskaya, 4", "for sale"); client[0] = new Client(1, "Fedor Dvinyatin"); client[1] = new Client(2, "Alexei Volkov"); client[2] = new Client(3, "Ivan Ivanov"); client[3] = new Client(4, "Petr Bojko"); client[4] = new Client(5, "Egor Valedinsky"); client[5] = new Client(6, "Alexander Evtuh"); client[6] = new Client(7, "Alexei Lohnitsky"); client[7] = new Client(8, "Mokin Alexander"); client[8] = new Client(9, "Pavlovets Sergey"); client[9] = new Client(10, "Igor Pujko"); manager[0] = new Manager(1, "Viktor Oniskevich"); manager[1] = new Manager(2, "Petr Glinskij"); manager[2] = new Manager(3, "Fedor Yakubuk"); manager[3] = new Manager(4, "Vasily Sapon"); manager[4] = new Manager(5, "Igor Ivanovskiy"); manager[5] = new Manager(6, "Alexander Dubrovsky"); manager[6] = new Manager(7, "Olga Golub"); manager[7] = new Manager(8, "Egor Pirozhkov"); manager[8] = new Manager(9, "Boris Zhukovich"); manager[9] = new Manager(10, "Igor Stepanchuk"); IRepository<Client> _clientRepository = new ClientRepository(); IRepository<Product> _productRepository = new ProductRepository(); IRepository<Manager> _managerRepository = new ManagerRepository(); IEnumerable<Client> clientRepository = _clientRepository.GetItems(); IEnumerable<Product> productRepository = _productRepository.GetItems(); IEnumerable<Manager> managerRepository = _managerRepository.GetItems(); foreach (var item in clientRepository) { _clientRepository.Remove(item); } foreach (var item in productRepository) { _productRepository.Remove(item); } foreach (var item in managerRepository) { _managerRepository.Remove(item); } for (int i = 0; i <= 9; i++) { _clientRepository.Add(client[i]); _productRepository.Add(product[i]); _managerRepository.Add(manager[i]); } }
public void RepositoryUpdateTest() { Program.ClearInformation(); IRepository<Product> _productRepository = new ProductRepository(); Product product = new Product(1, "House", "MOPRa,1", "for sale"); _productRepository.Add(product); product.status = "saled"; _productRepository.Update(product); Product actual = _productRepository.GetItem(product.id); Product expected = new Product(1, "House", "MOPRa,1", "saled"); Assert.AreEqual(actual.id, product.id); Assert.AreEqual(actual.name, product.name); Assert.AreEqual(actual.status, product.status); Assert.AreEqual(actual.address, product.address); Program.ClearInformation(); }
public void RepositoryRemoveTest() { Program.ClearInformation(); IRepository<Product> _productRepository = new ProductRepository(); Product product = new Product(1, "House", "MOPRa,1", "for sale"); _productRepository.Add(product); _productRepository.Remove(product.id); Product actual = _productRepository.GetItem(product.id); Product expected = null; Assert.AreEqual(expected, actual); Program.ClearInformation(); }
public void EditProductJustDocument() { var inizio = DateTime.Now; IDocumentRepository docRep = new DocumentRepository(); IProductRepository prodRep = new ProductRepository(); PapiroService p = new PapiroService(); p.DocumentRepository = docRep; p.CostDetailRepository = new CostDetailRepository(); p.TaskExecutorRepository = new TaskExecutorRepository(); p.ArticleRepository = new ArticleRepository(); Document doc = docRep.GetEstimateEcommerce("000001"); doc.EstimateNumber = "0"; DocumentProduct dp = docRep.GetDocumentProductsByCodProduct("").FirstOrDefault(); //work with product Product prod = p.InitProduct("SuppRigidi", new ProductTaskNameRepository(), new FormatsNameRepository(), new TypeOfTaskRepository()); //------passaggio del prodotto inizializzato all'ecommerce o alla view prod.CodProduct = prodRep.GetNewCode(prod); prod.ProductParts.FirstOrDefault().Format = "15x21"; prod.ProductParts.FirstOrDefault().SubjectNumber = 1; var art = prod.ProductParts.FirstOrDefault().ProductPartPrintableArticles.FirstOrDefault(); #region Printable Article IArticleRepository artRep = new ArticleRepository(); var artFormList = artRep.GetAll().OfType<RigidPrintableArticle>().FirstOrDefault(); art.TypeOfMaterial = artFormList.TypeOfMaterial; art.NameOfMaterial = artFormList.NameOfMaterial; art.Weight = artFormList.Weight; art.Color = artFormList.Color; #endregion //------ritorno del prodotto modificato!!!! //rigenero prodRep.Add(prod); prodRep.Save(); #region ViewModel ProductViewModel pv = new ProductViewModel(); pv.Product = prod; // prod.ProductCodeRigen(); pv.Quantity = 10; #endregion p.EditOrCreateAllCost(dp.CodDocumentProduct); var fine = DateTime.Now.Subtract(inizio).TotalSeconds; Assert.IsTrue(fine < 4); }