Exemplo n.º 1
0
        public void TestSerializeFourBooks()
        {
            //SETUP
            var books = DddEfTestData.CreateFourBooks();

            //ATTEMPT
            var jsonString = books.DefaultSerializeToJson();

            //VERIFY
        }
        public void TestProjectionMappingBookTitle()
        {
            //SETUP
            var wrappedMapper = AutoMapperHelpers.CreateWrapperMapper <Book, BookTitle>();

            //ATTEMPT
            var input = DddEfTestData.CreateFourBooks().AsQueryable();
            var list  = input.ProjectTo <BookTitle>(wrappedMapper.MapperReadConfig).ToList();

            //VERIFY
            list.First().Title.ShouldEqual("Refactoring");
        }
        public void TestDirectMappingBookTitle()
        {
            //SETUP
            var wrappedMapper = AutoMapperHelpers.CreateWrapperMapper <Book, BookTitle>();

            //ATTEMPT
            var input = DddEfTestData.CreateFourBooks().First();
            var data  = wrappedMapper.MapperSaveConfig.CreateMapper().Map <BookTitle>(input);

            //VERIFY
            data.Title.ShouldEqual("Refactoring");
        }
Exemplo n.º 4
0
        public void TestBuildCallNoParameters()
        {
            //SETUP 
            var method = typeof(Book).GetMethod(nameof(Book.RemovePromotion));
            var target = DddEfTestData.CreateFourBooks().Last();

            //ATTEMPT
            var action = BuildCall.CallMethodReturnVoid(method, typeof(Tests.Dtos.ChangePubDateDto), typeof(Book), new List<PropertyMatch>());
            action.Invoke(target);

            //VERIFY
            target.ActualPrice.ShouldEqual(target.OrgPrice);
        }
        public void TestProjectionMappingBookTitleAndCount()
        {
            //SETUP
            var genSerConfig = new BookTitleAndCountConfig();
            var mapperConfig = AutoMapperHelpers.CreateReadConfig <Book, BookTitleAndCount>(genSerConfig.AlterReadMapping);

            //ATTEMPT
            var input = DddEfTestData.CreateFourBooks().AsQueryable();
            var list  = input.ProjectTo <BookTitleAndCount>(mapperConfig).ToList();

            //VERIFY
            list.Last().Title.ShouldEqual("Quantum Networking");
            list.Last().ReviewsCount.ShouldEqual(2);
        }
        public void TestDirectMappingBookTitleAndCount()
        {
            //SETUP
            var genSerConfig = new BookTitleAndCountConfig();
            var mapperConfig = AutoMapperHelpers.CreateReadConfig <Book, BookTitleAndCount>(genSerConfig.AlterReadMapping);

            //ATTEMPT
            var input = DddEfTestData.CreateFourBooks().Last();
            var data  = mapperConfig.CreateMapper().Map <BookTitleAndCount>(input);

            //VERIFY
            data.Title.ShouldEqual("Quantum Networking");
            data.ReviewsCount.ShouldEqual(2);
        }
        public void TestDirectMappingToBookNotSetPrivateSetter()
        {
            //SETUP
            var wrappedMapper = AutoMapperHelpers.CreateWrapperMapper <BookTitle, Book>();
            var entity        = DddEfTestData.CreateFourBooks().First();

            //ATTEMPT
            var dto = new BookTitle {
                Title = "New Title"
            };
            var data = wrappedMapper.MapperSaveConfig.CreateMapper().Map(dto, entity);

            //VERIFY
            data.Title.ShouldEqual("Refactoring");
        }
Exemplo n.º 8
0
        public void TestResetAndSerializeFourBooks()
        {
            //SETUP
            var options = SqliteInMemory.CreateOptions <DddBookContext>();

            using (var context = new DddBookContext(options))
            {
                var books    = DddEfTestData.CreateFourBooks();
                var resetter = new DataResetter(context);
                resetter.ResetKeysEntityAndRelationships(books);

                //ATTEMPT
                var jsonString = books.DefaultSerializeToJson();

                //VERIFY
            }
        }
Exemplo n.º 9
0
        public void TestBookReadMappingsWithConfig()
        {
            //SETUP
            var maps = new MapperConfigurationExpression();

            //ATTEMPT
            var mapCreator = new CreateConfigGenerator(typeof(BookTitleAndCount), _bookInfo, new BookTitleAndCountConfig());

            mapCreator.Accessor.AddReadMappingToProfile(maps);

            //VERIFY
            var config = new MapperConfiguration(maps);
            var entity = DddEfTestData.CreateFourBooks().Last();
            var dto    = config.CreateMapper().Map <BookTitleAndCount>(entity);

            dto.Title.ShouldEqual("Quantum Networking");
            dto.ReviewsCount.ShouldEqual(2);
        }