コード例 #1
0
        public void SavePhoneBookTest()
        {
            PhoneBookCreator creator = new PhoneBookCreator();
            IPhoneBook       book    = creator.CreateNewPhoneBook();

            string filePath = "File.bin";

            book.CreatePhoneBookEntry("Gosho", "Goshov");

            Assert.IsFalse(File.Exists(filePath));

            creator.SavePhoneBook(filePath, book);

            Assert.IsTrue(File.Exists(filePath));

            IPhoneBook loadingBook = creator.LoadPhoneBook(filePath);

            Assert.IsNotEmpty(loadingBook.GetPhoneBookEntriesSortedByFirstName());

            Assert.IsTrue(loadingBook.GetPhoneBookEntriesSortedByFirstName().Count == 1);

            Assert.AreEqual("Gosho", loadingBook.GetPhoneBookEntriesSortedByFirstName()[0].FirstName);

            File.Delete(filePath);
        }