Example #1
0
        public void CreateSystemAddressBook()
        {
            var addressBook = new SystemAddressBook("系统通讯簿");

            Assert.AreNotEqual(DateTime.MinValue, addressBook.CreateTime);

            this._addressBookService.Create(addressBook);
            Assert.Greater(addressBook.ID, 0);

            this.Evict(addressBook);

            var addressBook2 = this._addressBookService.GetAddressBook(addressBook.ID) as SystemAddressBook;

            Assert.AreEqual(addressBook.Name, addressBook2.Name);
            Assert.AreEqual(FormatTime(addressBook.CreateTime), FormatTime(addressBook2.CreateTime));

            var childAddressBook = new SystemAddressBook("系统子通讯簿");

            Assert.AreNotEqual(DateTime.MinValue, addressBook.CreateTime);

            childAddressBook.SetParent(addressBook);
            Assert.AreEqual(childAddressBook.Parent.ID, addressBook.ID);

            this._addressBookService.Create(childAddressBook);
            Assert.Greater(childAddressBook.ID, 0);

            this.Evict(childAddressBook);

            var childAddressBook2 = this._addressBookService.GetAddressBook(childAddressBook.ID) as SystemAddressBook;

            Assert.AreEqual(childAddressBook.Name, childAddressBook2.Name);
            Assert.AreEqual(childAddressBook.Parent.ID, childAddressBook2.Parent.ID);
            Assert.AreEqual(FormatTime(childAddressBook.CreateTime), FormatTime(childAddressBook2.CreateTime));
        }
Example #2
0
        public void GetSystemAddressBooks()
        {
            var account = this.CreateAccount();
            var radomId1 = Guid.NewGuid().ToString();
            var radomId2 = Guid.NewGuid().ToString();
            var radomId3 = Guid.NewGuid().ToString();
            var systemAddressBook1 = new SystemAddressBook("系统通讯簿1" + radomId1);
            var systemAddressBook2 = new SystemAddressBook("系统通讯簿2" + radomId2);
            var systemAddressBook3 = new SystemAddressBook("系统通讯簿3" + radomId3);

            this._addressBookService.Create(systemAddressBook1);
            this._addressBookService.Create(systemAddressBook2);
            this._addressBookService.Create(systemAddressBook3);

            this.Evict(systemAddressBook1);
            this.Evict(systemAddressBook2);
            this.Evict(systemAddressBook3);

            var addressBooks = this._addressBookService.GetAllSystemAddressBooks();

            Assert.AreEqual(3, addressBooks.Where(x => new List<string> { "系统通讯簿1" + radomId1, "系统通讯簿2" + radomId2, "系统通讯簿3" + radomId3 }.Contains(x.Name)).Count());
        }