Exemplo n.º 1
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));
            }
        }
        public void SetUp()
        {
            TestHelper.RecreateDirectories();
            priceProcessor = factory.CreateChannel();

            supplier = TestSupplier.Create();

            var price = supplier.Prices[0];

            price.SetFormat(PriceFormatType.NativeDbf);
            priceItem = price.Costs[0].PriceItem;
            source    = priceItem.Source;
            priceItem.Format.Save();
        }
Exemplo n.º 3
0
        public void Setup()
        {
            TestHelper.RecreateDirectories();

            supplier                     = TestSupplier.Create();
            priceItem                    = supplier.Prices[0].Costs[0].PriceItem;
            source                       = priceItem.Source;
            source.SourceType            = PriceSourceType.Http;
            source.PricePath             = "www.ru";
            source.PriceMask             = "index.html";
            source.ExtrMask              = "index.html";
            priceItem.Format.PriceFormat = PriceFormatType.NativeDbf;
            priceItem.Format.Save();

            handler = new T();

            handler.CreateDirectoryPath();
        }