Ejemplo n.º 1
0
        public void RegisterLocalDateTimeToDateTimeConverter_Should_Register_Converters()
        {
            MapperConfig.RegisterLocalDateTimeToDateTimeConverter();

            AssertLocalDateTimeConvertersAreRegistered();

            AutoMappingUtils.Reset();
        }
Ejemplo n.º 2
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     MapperConfig.Configure();
 }
Ejemplo n.º 3
0
 protected void Application_Start()
 {
     MapperConfig.ConfigureMapper();
     AutofacConfig.ConfigureContainer();
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
 }
Ejemplo n.º 4
0
        public TaskController(ITaskService taskService, IPersonService personService, IStatusService statusService)
        {
            this.taskService   = taskService;
            this.personService = personService;
            this.statusService = statusService;

            mapper = MapperConfig.GetMapperResult();
        }
Ejemplo n.º 5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(
                                                             Configuration.GetConnectionString("DefaultConnection")));

            services.AddControllersWithViews();

            services.AddSingleton(provider => MapperConfig.Initialize());
            services.AddScoped <IUserService, UserService>();
            services.AddScoped <IMemoCardService, MemoCardService>();
            services.AddScoped <ITokenService, TokenService>();

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.Events = new JwtBearerEvents
                {
                    OnTokenValidated = async context =>
                    {
                        var id = context
                                 .Principal
                                 .Claims
                                 .First(claim => claim.Type == nameof(User.Id))
                                 .Value;

                        var service = context
                                      .HttpContext
                                      .RequestServices
                                      .GetRequiredService <IUserService>();

                        var user = await service.GetUser(Guid.Parse(id));

                        if (user == null)
                        {
                            context.Fail("Unauthorized");
                        }

                        context.HttpContext.Items.Add(nameof(User), user);     // Can be used by actions
                    }
                };
                var key           = Encoding.ASCII.GetBytes(Configuration.GetValue <string>("Secret"));
                options.SaveToken = true;
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer           = true,
                    ValidateAudience         = true,
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,
                    ValidIssuer      = nameof(MemoCards),
                    ValidAudience    = nameof(MemoCards),
                    IssuerSigningKey = new SymmetricSecurityKey(key)
                };
            });

            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/build"; });
        }
Ejemplo n.º 6
0
        public async Task TryCheckAllTransactionsTest(string accountRs)
        {
            var walletRepository = new FakeWalletRepository();

            walletRepository.NxtAccount             = accountRs;
            walletRepository.IsReadOnlyAccount      = true;
            walletRepository.NqtBalance             = 0;
            walletRepository.SecretPhrase           = string.Empty;
            walletRepository.LastLedgerEntryBlockId = 2680262203532249785UL;
            walletRepository.NxtServer            = "http://localhost:7876/nxt";
            walletRepository.SleepTime            = 10000;
            walletRepository.BackupCompleted      = true;
            walletRepository.NotificationsEnabled = false;

            var mapper                  = MapperConfig.Setup(walletRepository).CreateMapper();
            var serviceFactory          = new NxtLib.ServiceFactory(walletRepository.NxtServer);
            var nxtServer               = new NxtServer(walletRepository, mapper, serviceFactory);
            var accountLedgerRepository = new FakeAccountLedgerRepository();
            var contactRepository       = new FakeContactRepository();

            var runner = new AccountLedgerRunner(walletRepository, nxtServer, accountLedgerRepository);

            _addedLedgerEntries.Clear();
            Messenger.Default.Register <LedgerEntryMessage>(this, (message) =>
            {
                if (message.Action == LedgerEntryMessageAction.Added)
                {
                    _addedLedgerEntries.Add(message.LedgerEntry);
                }
            });
            var cancellationSource = new CancellationTokenSource();

            try
            {
                await runner.TryCheckAllLedgerEntries(cancellationSource.Token);
            }
            catch (Exception e)
            {
                throw new Exception($"Exception with account: {accountRs}", e);
            }

            var previousBalance = 0L;

            for (int i = _addedLedgerEntries.Count - 1; i >= 0; i--)
            {
                var addedLedgerEntry  = _addedLedgerEntries[i];
                var calculatedBalance = previousBalance;
                calculatedBalance += addedLedgerEntry.NqtAmount;
                calculatedBalance += (addedLedgerEntry.UserIsSender) ? addedLedgerEntry.NqtFee : 0;

                if (addedLedgerEntry.NqtBalance != calculatedBalance)
                {
                    throw new Exception($"Wrong balance for account: {accountRs}, expected: {calculatedBalance} but got: {addedLedgerEntry.NqtBalance} on height: {addedLedgerEntry.Height}");
                }
                previousBalance = calculatedBalance;
            }
        }
Ejemplo n.º 7
0
        public DaySummaryControllerTest()
        {
            MapperConfig mapperConfig = new MapperConfig();

            _mapper = mapperConfig.MapperConfiguration();
            _daySummaryServiceMock = new Mock <IDaySummaryService>();

            _daySummaryController = new DaySummaryController(_mapper, _daySummaryServiceMock.Object);
        }
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     InjeccaoDependenciaConfig.Inicializar();
     MapperConfig.Inicializar();
 }
Ejemplo n.º 9
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     System.Web.Optimization.BundleTable.EnableOptimizations = true;
     MapperConfig.Main();
 }
        internal static TinyIoCContainer GetContainer()
        {
            var container = new TinyIoCContainer();

            container.Register <IAPIService, APIService>();

            container.Register <IMapper, Mapper>(new Mapper(new MapperConfiguration(MapperConfig.MapperConfiguration())));
            return(container);
        }
Ejemplo n.º 11
0
        public CreateAdvertServiceTests()
        {
            _advertRepository     = new Mock <IGenericRepository <Advert> >();
            _advertTypeRepository = new Mock <IGenericRepository <AdvertType> >();
            _findPhotosById       = new Mock <IFindPhotosByIdService>();
            _photoService         = new Mock <IPhotoService>();

            MapperConfig.Register();
        }
Ejemplo n.º 12
0
 public static void RegisterDependencies(IUnityContainer container)
 {
     container.RegisterType <IUnitOfWork, UnitOfWork>();
     if (!container.IsRegistered <IMapper>())
     {
         MapperConfig.RegisterMapping();
         container.RegisterType <IMapper, Mapper>();
     }
 }
Ejemplo n.º 13
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     ControllerBuilder.Current.SetControllerFactory(new NInjectControllerFactory());
     MapperConfig.RegisterMappings();
 }
Ejemplo n.º 14
0
        private void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            DbConfig.Initialize();
            MapperConfig.RegisterMappings();
        }
Ejemplo n.º 15
0
        public async Task GetGoalsAsync_GivenUserToken_ShouldReturnUsersGoalsOrderAlphabetically()
        {
            // Arrange.
            MapperConfig.Initialise();

            var objects   = CreateTestObjects();
            var guid      = Guid.NewGuid();
            var userToken = new Token();

            objects.TestObject.ControllerContext = new HttpControllerContext
            {
                Request = new HttpRequestMessage()
            };
            objects.TestObject.ControllerContext.Request.Headers.Add("auth", guid.ToString());

            objects.Tokens.GetExistingValidTokenByGuidAsync(guid).Returns(userToken);
            objects.Users.GetUserAsync(userToken).Returns(new User {
                Id = 123
            });

            var goals = new List <Goal>
            {
                new Goal
                {
                    Id                    = 10,
                    UserId                = 123,
                    Name                  = "Some Goal",
                    PeriodInHours         = 24,
                    FrequencyWithinPeriod = 1
                },
                new Goal
                {
                    Id                    = 11,
                    UserId                = 123,
                    Name                  = "Another Goal",
                    PeriodInHours         = 48,
                    FrequencyWithinPeriod = 1
                }
            };

            objects.Goals.GetGoalsAsync(123).Returns(goals);

            // Act.
            var result = await objects.TestObject.GetGoalsAsync();

            // Assert.
            var okResult = result as OkNegotiatedContentResult <string>;

            var goalDatas = new List <GoalData>
            {
                Mapper.Map <GoalData>(goals[1]),
                Mapper.Map <GoalData>(goals[0])
            };

            Assert.NotNull(okResult);
            Assert.AreEqual(JsonConvert.SerializeObject(goalDatas), okResult.Content);
        }
Ejemplo n.º 16
0
 protected void Application_Start()
 {
     MapperConfig.Initialize();
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     //BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
Ejemplo n.º 17
0
        internal static void TaBort(object selectedItem)
        {
            BusinessManager bm     = new BusinessManager();
            var             mapper = MapperConfig.GetMapper();

            var selectedProgramToRemove = (Kompetens)selectedItem;

            bm.TaBortKompetensFrånAlumn(mapper.Map <Kompetens, KompetensDTO>(selectedProgramToRemove), GLOBALSWPF.AktuellAlumn);
        }
Ejemplo n.º 18
0
 public UserBusinessService(IUserService userService, IMemoryCache cache,
                            IRoleService roleService, IEmailService emailService)
 {
     this.userService  = userService;
     this.roleService  = roleService;
     this.emailService = emailService;
     this.cache        = cache;
     this.mapper       = MapperConfig.MapperInitialize();
 }
Ejemplo n.º 19
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     //Class for create the mapping
     MapperConfig.Initialise();
 }
Ejemplo n.º 20
0
        public ViewModels.Warehouse.WDashboardGathering WDashboardGathering(int gatheringType)
        {
            IMapperConfig mapperConfig = MapperConfig.Init()
                                         .CreateMap <DataModels.Warehouse.WDashboardGathering, ViewModels.Warehouse.WDashboardGathering>()
                                         .CreateMap <DataModels.Warehouse.WDGatherPerformanceSummary, ViewModels.Warehouse.WDGatherPerformanceSummary>()
                                         .CreateMap <DataModels.Warehouse.WDGatheringTrend, ViewModels.Warehouse.WDGatheringTrend>();

            return(_dataService.GetWDashboardGatheringInfo(gatheringType).Map <DataModels.Warehouse.WDashboardGathering, ViewModels.Warehouse.WDashboardGathering>(mapperConfig));
        }
Ejemplo n.º 21
0
 public void Start()
 {
     AreaRegistration.RegisterAllAreas();
     WebApiConfig.Register(GlobalConfiguration.Configuration);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     MapperConfig.RegisterProfiles();
 }
Ejemplo n.º 22
0
        public void CreateQuiz(QuizDTO quizDto)
        {
            ValidatorBlogModels.ValidateQuizModel(quizDto);
            var mapper  = MapperConfig.GetConfigFromDTO().CreateMapper();
            var quizNew = mapper.Map <Quiz>(quizDto);

            DataBase.Quizes.Create(quizNew);
            DataBase.Save();
        }
Ejemplo n.º 23
0
        public BookControllerTest()
        {
            MapperConfig.RegisterMappings();

            var repository = new BookRepository();
            var service    = new BookService(repository);

            _bookController = new BookController(service);
        }
Ejemplo n.º 24
0
 protected void Application_Start()
 {
     Database.SetInitializer(new MigrateDatabaseToLatestVersion <ApplicationDbContext, Configuration>());
     MapperConfig.ConfigureMappings();
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
Ejemplo n.º 25
0
        public void SetUp()
        {
            #region Initial fake data of constructor

            _configContext = new ConfigContext
            {
                McpDb              = "Data Source=10.37.36.195;Initial Catalog=MCPDev;uid=gary;pwd=Unsoul418!;",
                UploadPath         = "C:/AppOs",
                ImageEndPoint      = "http://*****:*****@$ "{AppContext.BaseDirectory.Substring(0, AppContext.BaseDirectory.IndexOf(" Wistron.AppStore.Web "))}\{@" Wistron.AppStore.Web \ Wistron.AppStore.Web \ wwwroot\unittest "}";
Ejemplo n.º 26
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            MapperConfig.RegisterMappings();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            ViewEnginesConfig.RegisterViewEngines(ViewEngines.Engines);
        }
Ejemplo n.º 27
0
        public OrderbookControllerTest()
        {
            MapperConfig mapperConfig = new MapperConfig();

            _mapper = mapperConfig.MapperConfiguration();

            _orderbookService = new Mock <IOrderbookService>();

            _orderbookController = new OrderbookController(_orderbookService.Object, _mapper);
        }
Ejemplo n.º 28
0
        public ViewModels.Warehouse.WDashboardOrder WDashboardOrder()
        {
            IMapperConfig mapperConfig = MapperConfig.Init()
                                         .CreateMap <DataModels.Warehouse.WDashboardOrder, ViewModels.Warehouse.WDashboardOrder>()
                                         .CreateMap <DataModels.Warehouse.WDWidgetData, ViewModels.Warehouse.WDWidgetData>()
                                         .CreateMap <DataModels.Warehouse.WDGatheringDifference, ViewModels.Warehouse.WDGatheringDifference>()
                                         .CreateMap <DataModels.Warehouse.OrderTrend, ViewModels.Warehouse.OrderTrend>();

            return(_dataService.GetWDashboardOrderInfo().Map <DataModels.Warehouse.WDashboardOrder, ViewModels.Warehouse.WDashboardOrder>(mapperConfig));
        }
Ejemplo n.º 29
0
 protected void Application_Start()
 {
     FluentValidationModelValidatorProvider.Configure();
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     MapperConfig.RegisterMapping();
     var container = new WindsorContainer().Install(new AdminInstaller());
 }
Ejemplo n.º 30
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
            //Database.SetInitializer<LMSContext>(null);
            MapperConfig.Configure();
            Startup.Start();
        }