Ejemplo n.º 1
0
        public void TestListBloggersAutoMapperMapperConfigDto()
        {
            //SETUP
            var config = new MapperConfiguration(cfg => { cfg.CreateMap <Mapper, Mapper>(); });

            var options = SqliteInMemory.CreateOptions <CodeDataContext>();

            using (var context = new CodeDataContext(options))
            {
                context.Database.EnsureCreated();
                context.AddRange(SetupPosts());
                context.SaveChanges();
                var logs = new List <string>();
                SqliteInMemory.SetupLogging(context, logs);

                //ATTEMPT
                var dtos = context.Bloggers
                           .ProjectTo <ListBloggersDto>(config)
                           .ToList();

                //VERIFY
                dtos.Count.ShouldEqual(2);
                dtos.Select(x => x.Name).ShouldEqual(new[] { AdaName, SherlockName });
                dtos.Select(x => x.PostsCount).ShouldEqual(new[] { 2, 1 });

                foreach (var log in logs)
                {
                    _output.WriteLine(log);
                }
            }
        }
Ejemplo n.º 2
0
        public UserServicesTest()
        {
            _codedataContext = TestHelpers.GetCodeDataContext();
            AutoMapperConfig.Initialize();
            var mapper = AutoMapperConfig.GetMapper();

            _userServices = new UserServices(_codedataContext, mapper);
        }
Ejemplo n.º 3
0
        private UserServicesFake GetInMemoryPersonRepository()
        {
            DbContextOptions <CodeDataContext> options;
            var builder = new DbContextOptionsBuilder <CodeDataContext>();

            builder.UserServicesFake();
            options = builder.Options;
            var personDataContext = new CodeDataContext(options);

            personDataContext.Database.EnsureDeleted();
            personDataContext.Database.EnsureCreated();
            return(new UserServicesFake(CodeDataContext));
        }
Ejemplo n.º 4
0
        public UserControllerTest()
        {
            _codeDataContext = TestHelpers.GetCodeDataContext();
            AutoMapperConfig.Initialize();
            var mapper        = AutoMapperConfig.GetMapper();
            var userServices  = new UserServices(_codeDataContext, mapper);
            var storeServices = new StoreServices(_codeDataContext, mapper);
            var options       = Options.Create(new LocalizationOptions()); // you should not need any params here if using a StringLocalizer<T>
            var factory       = new ResourceManagerStringLocalizerFactory(options, NullLoggerFactory.Instance);

            var localizer   = new ResourcesServices <CommonResources>(factory);
            var httpContext = new DefaultHttpContext();
            var tempData    = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>())
            {
                ["Success"] = localizer.GetLocalizedHtmlString("msg_AddSuccess")
            };

            _userController = new UserController(userServices, storeServices, localizer)
            {
                TempData = tempData
            };
        }
Ejemplo n.º 5
0
 public UserServices(CodeDataContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Ejemplo n.º 6
0
 public ProductServices(CodeDataContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Ejemplo n.º 7
0
 public CategoryServices(CodeDataContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Ejemplo n.º 8
0
 public LoginServices(CodeDataContext context)
 {
     _context = context;
 }