コード例 #1
0
ファイル: Test.cs プロジェクト: sudeepcb/textbox
        public void TestSearchAuthor()
        {
            LibraryModel lm = new LibraryModel();
            Book         b1 = new Book();
            Book         b2 = new Book();

            b1.BookAuthors = new List <BookAuthors>();
            b2.BookAuthors = new List <BookAuthors>();

            BookAuthors ba1 = new BookAuthors();
            Author      a1  = new Author();

            a1.FirstName = "J. K.";
            a1.LastName  = "author ln1";
            ba1.Authors  = a1;

            BookAuthors ba2 = new BookAuthors();
            Author      a2  = new Author();

            a2.FirstName = "author fn2";
            a2.LastName  = "author ln2";
            ba2.Authors  = a2;

            b1.Title = "A";
            b2.Title = "B";

            b1.BookAuthors.Add(ba1);
            b2.BookAuthors.Add(ba2);

            lm.library = new List <Book>();
            List <Book> Expectedlib = new List <Book>();

            Expectedlib.Add(b1);

            lm.SearchAuthor("J. K.");

            Assert.NotNull(lm.library);
            Assert.IsType <List <Book> >(lm.library);
            Assert.True(Expectedlib.Any() == lm.library.Any());
        }