Exemplo n.º 1
0
        public void Configuration(IAppBuilder app)
        {
            AutoMapperConfiguration.Config();

            app.CreatePerOwinContext(PulseContext.Create);
            app.CreatePerOwinContext <PulseUserManager>(PulseUserManager.Create);
            ConfigureOAuth(app);

            var config = new HttpConfiguration();


            config.MapHttpAttributeRoutes();

            config.EnableCors();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            config.DependencyResolver = new NinjectResolver(NinjectConfiguration.CreateKernel());

            var json = config.Formatters.JsonFormatter;

            json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
            config.Formatters.Remove(config.Formatters.XmlFormatter);

            app.UseCors(CorsOptions.AllowAll);

            app.UseWebApi(config);
        }
Exemplo n.º 2
0
        public void TestUpdateAsync()
        {
            AutoMapperConfiguration.Config();

            var countryRepository = new Mock <IRepository <Country> >();
            var mockService       = new Mock <IUnitOfWork>();

            var dbSet = new FakeDbSet <Country>();

            dbSet.AddRange(FakeCountries.FakeDataCountries());

            countryRepository.Setup(x => x.FindByAsync(1))
            .Returns(dbSet.FindAsync(new CancellationToken(false), 1));

            var countryDto = FakeCountries.FakeDataCountriesDto(hasKiosks: false).FirstOrDefault();

            mockService.Setup(x => x.Countries).Returns(countryRepository.Object);

            mockService.Setup(x => x.CommitAsync()).Returns(Task.FromResult(0)).Verifiable();

            //var countryService = new CountryService(mockService.Object);

            //var subsites = countryService.UpdateAsync(countryDto).Result;

            //mockService.Verify(x => x.CommitAsync(), Times.Once);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Application_Start
        /// </summary>
        protected void Application_Start()
        {
            //MVC相关
            AreaRegistration.RegisterAllAreas();

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ////DI 构造函数注入
            //new IocInitializeConstructor().Initialize();
            //属性注入
            new IocInitializeProperties().Initialize();

            //数据库基础数据初始化
            DbInitService.Init();

            //定时任务
            new EmailJobScheduler().Start();


            //AutoMapper
            AutoMapperConfiguration.Config();
            AutoMapperConfiguration.ConfigExt();
        }
Exemplo n.º 4
0
 protected BaseTest()
 {
     _mockService = new Mock <TService>();
     _httpRouteValueDictionary = InitHttpRouteValueDictionary();
     _url = GetUrl();
     AutoMapperConfiguration.Config();
     _fakeDataMethodDic = new FakeDataDto().FakeDataMethodDic;
 }
Exemplo n.º 5
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     AutoMapperConfiguration.Config();
 }
Exemplo n.º 6
0
 public BaseTest()
 {
     AutoMapperConfiguration.Config();
     _mockUnitOfWork = new Mock <IUnitOfWork>();
     _mockRepository = new Mock <IRepository <TEntity> >();
     _dbSet          = new FakeDbSet <IEntity>();
     //_mockUnitOfWork.Setup(x => x.Countries).Returns(_mockRepository.Object);
     //mockService.Setup(x => x.Countries.FindAll(null)).Returns(dbSet);
 }
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();

            AutoMapperConfiguration.Config();
        }
Exemplo n.º 8
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            AutoMapperConfiguration configuration = new AutoMapperConfiguration();

            configuration.Config();

            DependencyConfiguration.Configure();
        }
Exemplo n.º 9
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AutoMapperConfiguration.Config();
            MenuCacheHelper menuCacheHelper = new MenuCacheHelper();

            menuCacheHelper.LoadMenu();
            BundleTable.EnableOptimizations = false;
        }
Exemplo n.º 10
0
        public void Test()
        {
            AutoMapperConfiguration.Config();

            var instance = GetMockedContainer();

            var services = instance.Get <ICountryService>();

            var countryDto = FakeCountries.FakeDataCountriesDto(hasKiosks: false).FirstOrDefault();

            var result = AsyncHelper.RunSync(() => services.CreateAsync(countryDto));

            Assert.IsNotNull(result);
        }
Exemplo n.º 11
0
        public static void Main(string[] args)
        {
            AutoMapperConfiguration.Config();
            NinjectConfiguration.Config();
#if DEBUG
            Process process = ResolverFactory.GetService <Process>();
            process.Start();
            Console.ReadKey();
#else
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] { new SelfHostService() };
            ServiceBase.Run(ServicesToRun);
#endif
        }
Exemplo n.º 12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddDbContext <YClientsContext>(option =>
            {
                option.UseSqlServer(Configuration.GetConnectionString("YClient"));
            });
            services.AddScoped <DbContext, YClientsContext>();
            services.AddScoped(typeof(IRepository <,>), typeof(DbRepository <,>));
            services.AddScoped(typeof(IService <, ,>), typeof(Service <, ,>));
            services.AddTransient <IMapper>(config => AutoMapperConfiguration.Config());
            services.AddTransient <IEncrypter, Hashing>();
        }
Exemplo n.º 13
0
        public void TestCreateAsync()
        {
            AutoMapperConfiguration.Config();

            var countryRepository = new Mock <IRepository <Country> >();
            var mockService       = new Mock <IUnitOfWork>();

            var countryDto = FakeCountries.FakeDataCountriesDto(hasKiosks: false).FirstOrDefault();

            mockService.Setup(x => x.Countries).Returns(countryRepository.Object);
            mockService.Setup(x => x.CommitAsync()).Returns(Task.FromResult(0)).Verifiable();
            //var countryService = new CountryService(mockService.Object);
            //var subsites = countryService.CreateAsync(countryDto).Result;
            //mockService.Verify(x => x.CommitAsync(), Times.Once);
        }
Exemplo n.º 14
0
        public static void Main(string[] args)
        {
            AutoMapperConfiguration.Config();
            NinjectConfiguration.Config();
#if DEBUG
            using (Microsoft.Owin.Hosting.WebApp.Start <SignalRConfiguration>(SettingsConfigurationSignalR.DOMAIN_SERVER))
            {
                Console.WriteLine("OwinServer Started....");
                Console.ReadKey();
            }
#else
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] { new SelfHostService() };
            ServiceBase.Run(ServicesToRun);
#endif
        }
Exemplo n.º 15
0
        public void TestFindAllAsync()
        {
            AutoMapperConfiguration.Config();

            var dbSet = new FakeDbSet <Country>();

            dbSet.AddRange(FakeCountries.FakeDataCountries());

            var countryRepository = new Mock <IRepository <Country> >();
            var mockService       = new Mock <IUnitOfWork>();

            mockService.Setup(x => x.Countries).Returns(countryRepository.Object);
            mockService.Setup(x => x.Countries.FindAll(null)).Returns(dbSet);

            //var countryService = new CountryService(mockService.Object);
            //var subsites = countryService.FindAllAsync().Result;
        }
Exemplo n.º 16
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

            if (env.IsDevelopment())
            {
                // For more details on using the user secret store see https://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets <Startup>();
            }

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
            AutoMapperConfiguration.Config();
        }
Exemplo n.º 17
0
 public override void Load()
 {
     this.Bind(typeof(IRepository <>)).To(typeof(DbRepository <>)).WithConstructorArgument("context", new YClientsContext());
     this.Bind <IMapper>().ToMethod(context => AutoMapperConfiguration.Config());
     this.Bind <IEncrypter>().To <Hashing>();
 }
Exemplo n.º 18
0
 public Startup(IConfiguration configuration)
 {
     Configuration = configuration;
     AutoMapperConfiguration.Config();
 }