Beispiel #1
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     AutofacConfig.RegisterComponents();
     AutomapperConfig.Init();
 }
Beispiel #2
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     AutomapperConfig.Init();
     Application.Run(new frmMain());
 }
Beispiel #3
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     AutomapperConfig.Init();
 }
Beispiel #4
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     ModelBinders.Binders.Add(typeof(DateTime), new DateTimeBinder());
     ModelBinders.Binders.Add(typeof(DateTime?), new DateTimeBinder());
     WebApiConfig.Register(GlobalConfiguration.Configuration);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     FluentValidationModelValidatorProvider.Configure();
     //Database.SetInitializer(new DatabaseInitializer());
     AutomapperConfig.Init();
 }
        public async Task GetShouldReturnConvertedIpAdress()
        {
            // Arrange
            AutomapperConfig.Init();

            var ipAddress = IPAddress.Loopback;

            var modelList = new List <DatabaseEvent>
            {
                new DatabaseEvent
                {
                    //Id = 1,

                    //UserId = Guid.NewGuid(),
                    //UserAgent = "UserAgent",
                    //UserLanguage = "UserLanguage",
                    UserHostAddress  = ipAddress.GetAddressBytes(),
                    UserProxyAddress = ipAddress.GetAddressBytes(),

                    //Time = DateTimeOffset.UtcNow,

                    //Referer = "Referer",

                    //Flight = 1,
                    //Destination = 1
                }
            };

            var fakeSql = Substitute.For <IDatabase>();

            fakeSql.QueryAsync <DatabaseEvent>("SELECT * FROM Events")
            .Returns(Task.FromResult <IEnumerable <DatabaseEvent> >(modelList));

            var controller = new EventsController(fakeSql);

            // Act
            var result = await controller.Get();

            // Assert
            var viewResult = Assert.IsType <OkNegotiatedContentResult <IEnumerable <EmberEvent> > >(result);

            Assert.NotNull(viewResult);
            Assert.True(viewResult.Content.All(a => a.UserHostAddress == ipAddress.ToString()));
            Assert.True(viewResult.Content.All(a => a.UserProxyAddress == ipAddress.ToString()));
        }
        public async Task GetByIdShouldReturnOkResult()
        {
            // Arrange
            AutomapperConfig.Init();

            var fakeSql = Substitute.For <IDatabase>();

            fakeSql.ReadAsync <DatabaseEvent>(1)
            .Returns(Task.FromResult(new DatabaseEvent()));

            var controller = new EventsController(fakeSql);

            // Act
            var result = await controller.Get(1);

            // Assert
            var viewResult = Assert.IsType <OkNegotiatedContentResult <EmberEvent> >(result);

            Assert.NotNull(viewResult);
        }
Beispiel #7
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <CameraBazaarDbContext>(options =>
                                                          options.UseSqlServer(Configuration.GetConnectionString(CameraBazaarConstants.DefaultConnection)));

            services.AddScoped <CameraBazaarDbContext>();

            services.AddIdentity <User, IdentityRole>()
            .AddEntityFrameworkStores <CameraBazaarDbContext>()
            .AddDefaultTokenProviders();

            //services.AddAuthentication().AddFacebook(facebookOptions =>
            //{
            //	facebookOptions.AppId = Configuration["Authentication:Facebook:AppId"];
            //	facebookOptions.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
            //});

            services.Configure <IdentityOptions>(opt =>
            {
                opt.Password.RequireUppercase       = false;
                opt.Password.RequireNonAlphanumeric = false;
                opt.Password.RequireLowercase       = false;
                opt.Password.RequiredLength         = CameraBazaarConstants.User.PasswordMinLength;

                opt.User.RequireUniqueEmail = true;
            });

            services.AddTransient <ICameraService, CameraService>();

            services.AddTransient <IUserService, UserService>();

            services.AddAutoMapper(cfg => AutomapperConfig.Init(cfg));

            services.AddMvc(opt =>
            {
                opt.Filters.Add(new LogFilterAttribute());
                opt.Filters.Add(new TimerFilterAttribute());
            });
        }