当前位置: 首页>>代码示例>>C#>>正文


C# Item.SetTransaction方法代码示例

本文整理汇总了C#中System.Item.SetTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# Item.SetTransaction方法的具体用法?C# Item.SetTransaction怎么用?C# Item.SetTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Item的用法示例。


在下文中一共展示了Item.SetTransaction方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Can_add_new_item

        public void Can_add_new_item()
        {
            var item = new Item
            {
                Value = 0.01M,
                Description = "Add Test",
                IsVerified = true,
            };
            item.SetTransaction(_transaction);
            item.SetSource(_account1);
            item.SetDestination(_account2);

            IItemRepository repository = new ItemRepository();
            repository.Add(item);

            using (ISession session = SessionFactory.OpenSession())
            {
                var fromDb = session.Get<Item>(item.Id);
                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(item, fromDb);
                Assert.AreEqual(item.Value, fromDb.Value);
                Assert.AreEqual(item.Description, fromDb.Description);
                Assert.AreEqual(item.Destination.Id, fromDb.Destination.Id);
                Assert.AreEqual(item.Source.Id, fromDb.Source.Id);
                Assert.AreEqual(item.IsVerified, fromDb.IsVerified);
                Assert.AreEqual(item.TransactionId.Id, fromDb.TransactionId.Id);

                Assert.IsTrue(IsInCollection(item, item.TransactionId.Items));
                Assert.IsTrue(IsInCollection(item, item.Source.ItemsSource));
                Assert.IsTrue(IsInCollection(item, item.Destination.ItemsDestination));
            }
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:32,代码来源:ItemRepositoryFixture.cs

示例2: Cannot_move_money_from_destination_only_account

 public void Cannot_move_money_from_destination_only_account()
 {
     var item = new Item
     {
         Value = 99.01M,
         Description = "Add Test",
         IsVerified = true,
     };
     item.SetTransaction(_transaction1);
     item.SetSource(_account3);
     item.SetDestination(_account1);
 }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:12,代码来源:ItemFixture.cs

示例3: Can_create_new_transaction

        public void Can_create_new_transaction()
        {
            var item = new Item
            {
                Value = 567.78M,
                Description = "Add Test",
                IsVerified = true,
            };

            var transaction = new Transaction {
                BusinessKey = 1,
                Date = new DateTime(2009, 11, 15),
                Description = "Test Transaction",
                IsVerified = true,

            };
            item.SetTransaction(transaction);

            Assert.IsNotNull(transaction);
            Assert.AreEqual(transaction.Id, Guid.Empty);
            Assert.AreEqual(transaction.ItemCount(), 1);
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:22,代码来源:TransactionFixture.cs

示例4: ImportItems

        private static void ImportItems(OleDbConnection dbConnection,
            Iesi.Collections.Generic.ISet<Item> items,
            IDictionary<string, Account> accounts,
            IDictionary<int, Transaction> transactions)
        {
            OleDbDataAdapter dataAdapter;
            DataSet dataSet = new DataSet();

            dataAdapter = new OleDbDataAdapter("SELECT * FROM [Items$]", dbConnection);
            dataAdapter.Fill(dataSet);

            foreach (DataRow row in dataSet.Tables[0].Rows)
            {
                Account source = accounts[row["Source"].ToString()];
                Account destination = accounts[row["Destination"].ToString()];

                int tranKey = Int32.Parse(row["TransactionKey"].ToString());
                Decimal value = Decimal.Parse(row["Value"].ToString());

                Transaction transaction = transactions[tranKey];

                Item item = new Item
                {
                    Description = row["Description"].ToString(),
                    Value = value,
                    IsVerified = bool.Parse(row["IsVerified"].ToString()),
                };
                item.SetTransaction(transaction);
                item.SetSource(source);
                item.SetDestination(destination);

                items.Add(item);
            }
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:34,代码来源:ImportExport.cs

示例5: ItemCountReturnsCorrectValues

        public void ItemCountReturnsCorrectValues()
        {
            var item = new Item
            {
                Value = 567.78M,
                Description = "Add Test",
                IsVerified = true,
            };

            var item2 = new Item
            {
                Value = 667.78M,
                Description = "Add Test 2",
                IsVerified = false,
            };
            var transaction = new Transaction
            {
                BusinessKey = 1,
                Date = new DateTime(2009, 11, 15),
                Description = "Test Transaction",
                IsVerified = true,

            };
            Assert.AreEqual(transaction.ItemCount(), 0);

            item.SetTransaction(transaction);
            Assert.AreEqual(transaction.ItemCount(), 1);

            item.SetTransaction(transaction);
            Assert.AreEqual(transaction.ItemCount(), 1);

            item2.SetTransaction(transaction);
            Assert.AreEqual(transaction.ItemCount(), 2);

            var transaction2 = new Transaction
            {
                BusinessKey = 1,
                Date = new DateTime(2009, 11, 16),
                Description = "Test Transaction2",
                IsVerified = true,

            };
            Assert.AreEqual(transaction2.ItemCount(), 0);
            item.SetTransaction(transaction2);
            Assert.AreEqual(transaction.ItemCount(), 1);
            Assert.AreEqual(transaction2.ItemCount(), 1);
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:47,代码来源:TransactionFixture.cs

示例6: CreateInitialData

        private void CreateInitialData()
        {
            _accountType1 = new AccountType
            {
                Name = "Asset",
                IsDestination = true,
                IsSource = true,
                IsValid = true,
            };
            _accountType2 = new AccountType
            {
                Name = "Expense",
                IsDestination = true,
                IsSource = true,
                IsValid = true,
            };
            _accountType3 = new AccountType
            {
                Name = "Income",
                IsDestination = false,
                IsSource = true,
                IsValid = true,
            };

            _accountType4 = new AccountType
            {
                Name = "Fail test",
                IsDestination = true,
                IsSource = false,
                IsValid = true,
            };

            _accountCategory = new AccountCategory
            {
                Name = "Other",
                Colour = "Orange",
                IsValid = true,
            };
            _account1 = new Account
            {
                Name = "Bank Account",
                IsValid = true
            };
            _account1.setType(_accountType1);
            _account1.setCategory(_accountCategory);

            _account2 = new Account
            {
                Name = "Food",
                IsValid = true
            };
            _account2.setType(_accountType2);
            _account2.setCategory(_accountCategory);

            _account3 = new Account
            {
                Name = "Pay",
                IsValid = true
            };
            _account3.setType(_accountType3);
            _account3.setCategory(_accountCategory);

            _account4 = new Account
            {
                Name = "Test",
                IsValid = true,
            };
            _account4.setType(_accountType4);
            _account4.setCategory(_accountCategory);

            DateTime tempDate = new DateTime(2009, 2, 5);
            _transaction = new Transaction
            {
                Date = tempDate,
                Description = "Some payment",
                IsVerified = false,
            };
            _item1 = new Item
            {
                Value = 123.0M,
                IsVerified = true,
                Description = "Payment 1",
            };
            _item1.SetTransaction(_transaction);
            _item1.SetSource(_account1);
            _item1.SetDestination(_account2);

            _item2 = new Item
            {
                Value = 456.0M,
                IsVerified = true,
                Description = "Payment 2",
            };
            _item2.SetTransaction(_transaction);
            _item2.SetSource(_account2);
            _item2.SetDestination(_account1);

            using (ISession session = SessionFactory.OpenSession())
            using (ITransaction transaction = session.BeginTransaction())
            {
//.........这里部分代码省略.........
开发者ID:mattwatson,项目名称:Akcounts,代码行数:101,代码来源:ItemRepositoryFixture.cs

示例7: Transaction_TransactionDate

 public void Transaction_TransactionDate()
 {
     var item = new Item
     {
         Value = 99.99M,
         Description = "Move Test",
         IsVerified = true,
     };
     item.SetTransaction(_transaction1);
     Assert.AreEqual(item.TransactionDate, "05 February 2009");
 }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:11,代码来源:ItemFixture.cs

示例8: Transaction_TVerfied

        public void Transaction_TVerfied()
        {
            var item = new Item
            {
                Value = 99.99M,
                Description = "Move Test",
                IsVerified = true,
            };
            item.SetTransaction(_transaction1);
            Assert.AreEqual(item.TVerified, false);

            item.TVerified = true;
            Assert.AreEqual(item.TVerified, true);
            Assert.AreEqual(_transaction1.IsVerified, true);
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:15,代码来源:ItemFixture.cs

示例9: Transaction_desc_works

        public void Transaction_desc_works()
        {
            var item = new Item
            {
                Value = 99.99M,
                Description = "Move Test",
                IsVerified = true,
            };
            Assert.AreEqual("Move Test", item.Description);
            Assert.AreEqual("Move Test", item.TransactionDesc);

            item.SetTransaction(_transaction1);
            Assert.AreEqual("Some payment", _transaction1.Description);
            Assert.AreEqual("Some payment: Move Test", item.TransactionDesc);

            _transaction1.Description = "";
            Assert.AreEqual("Move Test", item.TransactionDesc);
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:18,代码来源:ItemFixture.cs

示例10: TransactionUpdatedIfItemMoved

        public void TransactionUpdatedIfItemMoved()
        {
            var item = new Item
            {
                Value = 99.99M,
                Description = "Move Test",
                IsVerified = true,
            };
            item.SetTransaction(_transaction3);
            item.SetDestination(_account1);
            item.SetSource(_account2);
            Assert.AreEqual(item.TransactionId, _transaction3);
            Assert.AreNotEqual(item.TransactionId, _transaction2);
            Assert.AreEqual(1, _transaction3.ItemCount());
            Assert.AreEqual(0, _transaction2.ItemCount());

            item.SetTransaction(_transaction2);
            Assert.AreEqual(item.TransactionId, _transaction2);
            Assert.AreNotEqual(item.TransactionId, _transaction3);
            Assert.AreEqual(0, _transaction3.ItemCount());
            Assert.AreEqual(1, _transaction2.ItemCount());
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:22,代码来源:ItemFixture.cs

示例11: Can_create_new_item

        public void Can_create_new_item()
        {
            var item = new Item
            {
                Value = 0.01M,
                Description = "Add Test",
                IsVerified = true,
            };
            item.SetTransaction(_transaction1);
            item.SetSource(_account1);
            item.SetDestination(_account2);

            Assert.IsNotNull(item);
            Assert.AreEqual(item.Id, Guid.Empty);
            Assert.AreEqual(item.Source.Id, Guid.Empty);
            Assert.AreEqual(item.Source.Category.Id, Guid.Empty);
            Assert.AreEqual(item.Source.Type.Id, Guid.Empty);
            Assert.AreEqual(item.Destination.Id, Guid.Empty);
            Assert.AreEqual(item.Destination.Category.Id, Guid.Empty);
            Assert.AreEqual(item.Destination.Type.Id, Guid.Empty);
            Assert.AreEqual(item.TransactionId.Id, Guid.Empty);

            Assert.AreEqual(item.Description, "Add Test");
            Assert.AreEqual(item.Destination, _account2);
            Assert.AreEqual(item.IsVerified, true);
            Assert.AreEqual(item.Source, _account1);
            Assert.AreEqual(item.TransactionId, _transaction1);
            Assert.AreEqual(item.Value, 0.01M);
            Assert.AreEqual(item.Destination.Category, _account2.Category);
            Assert.AreEqual(item.Destination.Category.Colour, _account2.Category.Colour);
            Assert.AreEqual(item.Destination.Category.IsValid, _account2.Category.IsValid);
            Assert.AreEqual(item.Destination.Category.Name, _account2.Category.Name);
            Assert.AreEqual(item.Destination.IsValid, _account2.IsValid);
            Assert.AreEqual(item.Destination.Name, _account2.Name);
            Assert.AreEqual(item.Destination.Type, _account2.Type);
            Assert.AreEqual(item.Destination.Type.IsDestination, _account2.Type.IsDestination);
            Assert.AreEqual(item.Destination.Type.IsSource, _account2.Type.IsSource);
            Assert.AreEqual(item.Destination.Type.IsValid, _account2.Type.IsValid);
            Assert.AreEqual(item.Destination.Type.Name, _account2.Type.Name);
            Assert.AreEqual(item.Source.Category, _account1.Category);
            Assert.AreEqual(item.Source.Category.Colour, _account1.Category.Colour);
            Assert.AreEqual(item.Source.Category.IsValid, _account1.IsValid);
            Assert.AreEqual(item.Source.Category.Name, _account1.Category.Name);
            Assert.AreEqual(item.Source.IsValid, _account1.IsValid);
            Assert.AreEqual(item.Source.Name, _account1.Name);
            Assert.AreEqual(item.Source.Type, _account1.Type);
            Assert.AreEqual(item.Source.Type.IsDestination, _account1.Type.IsDestination);
            Assert.AreEqual(item.Source.Type.IsSource, _account1.Type.IsSource);
            Assert.AreEqual(item.Source.Type.IsValid, _account1.Type.IsValid);
            Assert.AreEqual(item.Source.Type.Name, _account1.Type.Name);
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:51,代码来源:ItemFixture.cs

示例12: Cannot_move_money_within_the_same_account_lazily

 public void Cannot_move_money_within_the_same_account_lazily()
 {
     var item = new Item
     {
         Value = 567.78M,
         Description = "Add Test",
         IsVerified = true,
     };
     item.SetTransaction(_transaction1);
     item.SetSourceLazy(_account1);
     item.SetDestinationLazy(_account1);
 }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:12,代码来源:ItemFixture.cs

示例13: Cannot_move_money_into_source_only_account_lazily

 public void Cannot_move_money_into_source_only_account_lazily()
 {
     var item = new Item
     {
         Value = 88.01M,
         Description = "Add Test",
         IsVerified = true,
     };
     item.SetTransaction(_transaction1);
     item.SetSourceLazy(_account1);
     item.SetDestinationLazy(_account4);
 }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:12,代码来源:ItemFixture.cs


注:本文中的System.Item.SetTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。