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


C# Account.setCategory方法代码示例

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


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

示例1: Account_count_returns_the_correct_result

        public void Account_count_returns_the_correct_result()
        {
            Account account1;
            Account account2;

            account1 = new Account
            {
                Name = "Bank Account",
                IsValid = true,
            };

            account2 = new Account
            {
                Name = "Bank Account",
                IsValid = true,
            };

            var accountCategory = new AccountCategory
            {
                Name = "Other",
                Colour = "Orange",
                IsValid = true,
            };

            Assert.AreEqual(accountCategory.AccountCount(), 0);

            account1.setCategory(accountCategory);
            Assert.AreEqual(accountCategory.AccountCount(), 1);

            account2.setCategory(accountCategory);
            Assert.AreEqual(accountCategory.AccountCount(), 2);

            var accountCategory2 = new AccountCategory
            {
                Name = "New One",
                Colour = "Pink",
                IsValid = true,
            };

            account1.setCategory(accountCategory2);
            Assert.AreEqual(accountCategory.AccountCount(), 1);
            Assert.AreEqual(accountCategory2.AccountCount(), 1);
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:43,代码来源:AccountCategoryFixture.cs

示例2: Can_create_new_Account

        public void Can_create_new_Account()
        {
            var account = new Account
            {
                Name = "Bank Account",
                IsValid = true,
            };
            account.setType(_accountType1);
            account.setCategory(_accountCategory);

            Assert.IsNotNull(account);
            Assert.AreEqual(account.Id, Guid.Empty);
            Assert.AreEqual(account.Category.Id, Guid.Empty);
            Assert.AreEqual(account.Category.Colour, "Orange");
            Assert.AreEqual(account.Category.IsValid, true);
            Assert.AreEqual(account.Category.Name, "Other");
            Assert.AreEqual(account.IsValid, true);
            Assert.AreEqual(account.Name, "Bank Account");
            Assert.AreEqual(account.Type.Id, Guid.Empty);
            Assert.AreEqual(account.Type.IsDestination, true);
            Assert.AreEqual(account.Type.IsSource, true);
            Assert.AreEqual(account.Type.IsValid, true);
            Assert.AreEqual(account.Type.Name, "Asset");
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:24,代码来源:AccountFixture.cs

示例3: Can_add_new_account

        public void Can_add_new_account()
        {
            var account = new Account { Name = "Credit Card", IsValid = true };
            account.setType(_accountType1);
            account.setCategory(_accountCategory);

            IAccountRepository Arepository = new AccountRepository();

            Arepository.Add(account);

            using (ISession session = SessionFactory.OpenSession())
            {
                var fromDb = session.Get<Account>(account.Id);
                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(account, fromDb);
                Assert.AreEqual(account.Name, fromDb.Name);
                Assert.AreEqual(account.IsValid, fromDb.IsValid);
                Assert.AreEqual(account.Type.Name, fromDb.Type.Name);
                Assert.AreEqual(account.Category.Name, fromDb.Category.Name);

                Assert.IsTrue(IsInCollection(account, account.Category.Accounts));
                Assert.IsTrue(IsInCollection(account, account.Type.Accounts));
            }
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:24,代码来源:AccountRepositoryFixture.cs

示例4: Count_Destination_Items_returns_correct_result

        public void Count_Destination_Items_returns_correct_result()
        {
            var account = new Account
            {
                Name = "Test Account",
                IsValid = true,

            };
            account.setType(_accountType1);
            account.setCategory(_accountCategory);

            Assert.AreEqual(account.ItemsDestinationCount(), 0);

            _item.SetDestination(account);
            Assert.AreEqual(account.ItemsDestinationCount(), 1);

            _item.SetDestination(account);
            Assert.AreEqual(account.ItemsDestinationCount(), 1);

            _item2.SetDestination(account);
            Assert.AreEqual(account.ItemsDestinationCount(), 2);

            var account2 = new Account
            {
                Name = "Test Account",
                IsValid = true,

            };
            account2.setType(_accountType1);
            account2.setCategory(_accountCategory);

            Assert.AreEqual(account2.ItemsDestinationCount(), 0);
            _item.SetDestination(account2);
            Assert.AreEqual(account.ItemsDestinationCount(), 1);
            Assert.AreEqual(account2.ItemsDestinationCount(), 1);
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:36,代码来源:AccountFixture.cs

示例5: List_of_categories_updated_correctly

        public void List_of_categories_updated_correctly()
        {
            AccountCategory accountCategory1 = new AccountCategory
            {
                Name = "Other",
                Colour = "Orange",
                IsValid = true,
            };
            AccountCategory accountCategory2 = new AccountCategory
            {
                Name = "Other2",
                Colour = "Blue",
                IsValid = true,
            };

            var account = new Account
            {
                IsValid = true,
                Name = "Test Account",
            };

            Assert.AreEqual(0, accountCategory1.AccountCount());
            Assert.AreEqual(0, accountCategory2.AccountCount());
            account.setCategory(accountCategory1);

            Assert.AreEqual(1, accountCategory1.AccountCount());
            Assert.AreEqual(0, accountCategory2.AccountCount());

            account.setCategory(accountCategory2);

            Assert.AreEqual(0, accountCategory1.AccountCount());
            Assert.AreEqual(1, accountCategory2.AccountCount());
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:33,代码来源:AccountFixture.cs

示例6: ImportAccounts

        private static void ImportAccounts(OleDbConnection dbConnection,
            IDictionary<string, Account> accounts,
            IDictionary<string, AccountType> accountTypes,
            IDictionary<string, AccountCategory> accountCategories)
        {
            OleDbDataAdapter dataAdapter;
            DataSet dataSet = new DataSet();

            dataAdapter = new OleDbDataAdapter("SELECT * FROM [Accounts$]", dbConnection);

            dataAdapter.Fill(dataSet);

            foreach (DataRow row in dataSet.Tables[0].Rows)
            {
                Account account = new Account
                {
                    Name = row["Name"].ToString(),
                    IsValid = bool.Parse(row["IsValid"].ToString()),
                };
                account.setCategory(accountCategories[row["Category Name"].ToString()]);
                account.setType(accountTypes[row["Type Name"].ToString()]);

                accounts.Add(account.Name, account);
            }
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:25,代码来源:ImportExport.cs

示例7: Can_create_new_accountCategory

        public void Can_create_new_accountCategory()
        {
            Account account;

            account = new Account
            {
                Name = "Bank Account",
                IsValid = true,
            };

            var accountCategory = new AccountCategory {
                Name = "Other",
                Colour = "Orange",
                IsValid = true,
            };

            account.setCategory(accountCategory);

            Assert.AreEqual(accountCategory.Id, Guid.Empty);
            Assert.AreEqual(account.Category, accountCategory);
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:21,代码来源:AccountCategoryFixture.cs

示例8: 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

示例9: CreateInitialData

        private void CreateInitialData()
        {
            _accountCategory = new AccountCategory { Name = "Test", Colour = "Green", IsValid = true };
            _accountCategory2 = new AccountCategory { Name = "SomethingElse", Colour = "Green", IsValid = true };

            _accountType1 = new AccountType { Name = "Asset", IsDestination = true, IsSource = true, IsValid = true };
            _accountType2 = new AccountType { Name = "SourceOnly", IsDestination = false, IsSource = true, IsValid = true };
            _accountType3 = new AccountType { Name = "DestinationOnly", IsDestination = true, IsSource = false, IsValid = true };
            _account1 = new Account
            {
                Name = "Bank Account",
                IsValid = true,
            };
            _account1.setType(_accountType1);
            _account1.setCategory(_accountCategory);

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

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

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

            using (ISession session = SessionFactory.OpenSession())
            using (ITransaction transaction = session.BeginTransaction())
            {
                session.Save(_accountType1);
                session.Save(_accountType2);
                session.Save(_accountType3);
                session.Save(_accountCategory);
                session.Save(_accountCategory2);
                session.Save(_account1);
                session.Save(_account2);
                session.Save(_account3);
                session.Save(_account4);
                transaction.Commit();
            }
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:55,代码来源:AccountRepositoryFixture.cs

示例10: Change_account_category

        public void Change_account_category()
        {
            var account = new Account { Name = "Credit Card", IsValid = true };
            account.setType(_accountType1);
            account.setCategory(_accountCategory);
            account.setCategory(_accountCategory2);

            IAccountRepository Arepository = new AccountRepository();

            Arepository.Add(account);

            using (ISession session = SessionFactory.OpenSession())
            {
                var fromDb = session.Get<Account>(account.Id);

                Assert.IsTrue(IsInCollection(account, account.Category.Accounts));
                Assert.IsFalse(IsInCollection(account, _accountCategory.Accounts));

            }
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:20,代码来源:AccountRepositoryFixture.cs

示例11: Can_not_update_a_non_existing_account

 public void Can_not_update_a_non_existing_account()
 {
     var account = new Account
     {
         Name = "Test Account",
         IsValid = true,
     };
     account.setType(_accountType1);
     account.setCategory(_accountCategory);
     IAccountRepository repository = new AccountRepository();
     repository.Update(account);
 }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:12,代码来源:AccountRepositoryFixture.cs

示例12: TestFixtureSetUp

        public void TestFixtureSetUp()
        {
            _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 = "NotSource",
                IsDestination = true,
                IsSource = false,
                IsValid = true,
            };
            _accountType4 = new AccountType
            {
                Name = "NotDestination",
                IsDestination = false,
                IsSource = true,
                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 = "Not Source",
                IsValid = true,
            };
            _account3.setType(_accountType3);
            _account3.setCategory(_accountCategory);

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

            DateTime tempDate = new DateTime(2009, 2, 5);
            _transaction1 = new Transaction
            {
                Date = tempDate,
                Description = "Some payment",
                IsVerified = false,
            };

            _transaction2 = new Transaction
            {
                Date = tempDate,
                Description = "Some other payment",
                IsVerified = true,
            };

            _transaction3 = new Transaction
            {
                Date = tempDate,
                Description = "A further payment",
                IsVerified = true,
            };
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:90,代码来源:ItemFixture.cs

示例13: SourceUpdatedIfItemMovedLazily

        public void SourceUpdatedIfItemMovedLazily()
        {
            Account account1;
            Account account2;

            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);

            var item = new Item
            {
                Value = 99.99M,
                Description = "Move Test",
                IsVerified = true,
            };

            item.SetSourceLazy(account2);
            Assert.AreEqual(item.Source, account2);
            Assert.AreNotEqual(item.Source, account1);

            item.SetSourceLazy(account1);
            Assert.AreEqual(item.Source, account1);
            Assert.AreNotEqual(item.Source, account2);
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:36,代码来源:ItemFixture.cs

示例14: DestinationUpdatedIfItemMovedLazily

        public void DestinationUpdatedIfItemMovedLazily()
        {
            Account account1;
            Account account3;

            account1 = new Account
            {
                Name = "Bank Account",
                IsValid = true,
            };
            account1.setType(_accountType1);
            account1.setCategory(_accountCategory);

            account3 = new Account
            {
                Name = "Not Source",
                IsValid = true,
            };
            account3.setType(_accountType3);
            account3.setCategory(_accountCategory);

            var item = new Item
            {
                Value = 99.99M,
                Description = "Move Test",
                IsVerified = true,
            };

            item.SetDestinationLazy(account3);
            Assert.AreEqual(item.Destination, account3);
            Assert.AreNotEqual(item.Destination, account1);

            item.SetDestinationLazy(account1);
            Assert.AreEqual(item.Destination, account1);
            Assert.AreNotEqual(item.Destination, account3);
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:36,代码来源:ItemFixture.cs


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