示例#1
0
        public void GetTest()
        {
            IAccount a1 = AccountGateway.Add("test1", "test1", "www.host.com", "*****@*****.**");

            IAccount actual = AccountGateway.Get(a1.Id);

            PrintAccount(actual);

            Assert.AreEqual(a1.Id, actual.Id);
        }
示例#2
0
        public void AddTest()
        {
            IAccount a = AccountGateway.Add("test1", "test1", "weibo.com", "*****@*****.**");
            IAccount b = AccountGateway.Add("test2", "test2", "weibo.com", "*****@*****.**", true);

            Process.Start(AccountGateway.AccountSettingPath);

            IList <IAccount> all = AccountGateway.GetAll();

            IAccount actual = null;

            foreach (IAccount account in all)
            {
                if (account.Id == a.Id || account.Id == b.Id)
                {
                    actual = account;
                }
                else
                {
                    actual = null;
                }

                if (actual != null)
                {
                    if (account.Id == a.Id)
                    {
                        Assert.IsFalse(actual.IsDefault);
                    }
                    else
                    {
                        Assert.IsTrue(actual.IsDefault);
                    }

                    Console.WriteLine("Found Account({0}) {1} default account", actual.Id == a.Id ? "a" : "b",
                                      actual.IsDefault ? "is" : "is not");

                    PrintAccount(account);
                }
            }

            IAccount actual2 = AccountGateway.GetDefault();

            Console.WriteLine("Default Account");
            PrintAccount(actual2);

            Assert.AreEqual(b.Id, actual2.Id);
        }
示例#3
0
        public void UpdateCollectionTest()
        {
            IAccount a1 = AccountGateway.Add("test1", "test1", "www.baidu.com", "*****@*****.**");
            IAccount a2 = AccountGateway.Add("test2", "test2", "www.google.com", "*****@*****.**", true);

            Process.Start(AccountGateway.AccountSettingPath);

            Thread.Sleep(1000);

            Console.WriteLine("Account(a1) Old Values:");
            PrintAccount(a1);

            Console.WriteLine("Account(a2) Old Values:");
            PrintAccount(a2);

            a1.UserName = "******";
            a1.Host     = "www.baidudu.com";

            a2.UserName = "******";
            a2.Host     = "www.googlegle.com";

            IList <IAccount> expect = new List <IAccount>()
            {
                a1, a2
            };

            IList <IAccount> actual = AccountGateway.Update(expect);

            Process.Start(AccountGateway.AccountSettingPath);

            a1 = actual.FirstOrDefault(a => a.Id == a1.Id);

            Assert.IsNotNull(a1);
            Console.WriteLine("Found Account(a1) New Values:");
            PrintAccount(a1);

            a2 = actual.FirstOrDefault(a => a.Id == a2.Id);

            Assert.IsNotNull(a2);
            Console.WriteLine("Found Account(a1) New Values:");
            PrintAccount(a2);
        }