示例#1
0
        public void GetAllRecords()
        {
            List<BookDto> bookDtos = Reader.GetRecords<BookDto>().ToList();

            foreach (var bookDto in bookDtos)
            {
                Book book  = new Book();

                Mapper.Map(bookDto, book);

                Books.Add(book);
            }
        }
示例#2
0
        public void Test_MapToViewModel_Profile_TestMapping_Field()
        {
            Mapper.Initialize(m => m.AddProfile(new MapToViewModelProfile()));

            Book bookModel = new Book
            {
                Name = "Book1",
                Minutes = 320
            };

            Models.ViewModels.Book bookViewModel = new Models.ViewModels.Book();

            Mapper.Map(bookModel, bookViewModel);

            Assert.AreEqual(bookModel.Name, bookViewModel.Name);
            Assert.AreEqual("Book1", bookViewModel.Name);
            Assert.AreEqual("5h 20m", bookViewModel.RunningTime);
        }