public void Update_price_name_from_source_file()
        {
            Formalize("FarmaimpeksSmallPrice.xml");
            var price = TestPrice.Find(prices[1].Id);

            Assert.That(price.PriceName, Is.EqualTo("Прайс Опт ДП"));
        }
Example #2
0
        public void DeleteCostColumn()
        {
            TestPrice price;

            using (var scope = new TransactionScope(OnDispose.Rollback)) {
                price = CreateTestSupplierWithPrice();
                scope.VoteCommit();
            }
            var prices = FillPrices();
            var rows   = prices.Select(String.Format("PFirmCode = {0}", price.Supplier.Id));

            Assert.That(rows.Count(), Is.EqualTo(2));
            rows = prices.Select(String.Format("PFirmCode = {0} and PCostType = 1 and PIsParent = 0", price.Supplier.Id));
            Assert.That(rows.Count(), Is.EqualTo(1));
            rows[0].Delete();

            var changes = prices.GetChanges();

            With.Transaction((c, t) => {
                var mcmdDPrice = new MySqlCommand();
                var daPrice    = new MySqlDataAdapter();

                mcmdDPrice.CommandText = "usersettings.DeleteCost";
                mcmdDPrice.CommandType = CommandType.StoredProcedure;
                mcmdDPrice.Parameters.Clear();
                mcmdDPrice.Parameters.Add("?inCostCode", MySqlDbType.Int64, 0, "PCostCode");
                mcmdDPrice.Parameters["?inCostCode"].Direction = ParameterDirection.Input;

                mcmdDPrice.Connection = c;
                daPrice.DeleteCommand = mcmdDPrice;
                daPrice.TableMappings.Clear();
                daPrice.TableMappings.Add("Table", prices.TableName);

                daPrice.Update(changes);
                prices.AcceptChanges();
            });


            using (var scope = new TransactionScope(OnDispose.Rollback)) {
                var resprice = TestPrice.Find(price.Id);
                Assert.That(resprice.Costs.Count, Is.EqualTo(1));

                var cost = TestPriceCost.TryFind(costForDelete.Id);
                Assert.That(cost, Is.EqualTo(null));

                var item = TestPriceItem.TryFind(costForDelete.PriceItem.Id);
                Assert.That(item, Is.EqualTo(null));

                var source = TestPriceSource.TryFind(costForDelete.PriceItem.Source.Id);
                Assert.That(source, Is.EqualTo(null));

                var format = TestFormat.TryFind(costForDelete.PriceItem.Format.Id);
                Assert.That(format, Is.EqualTo(null));
            }
        }