public void RegisterLocalDateTimeToDateTimeConverter_Should_Register_Converters() { MapperConfig.RegisterLocalDateTimeToDateTimeConverter(); AssertLocalDateTimeConvertersAreRegistered(); AutoMappingUtils.Reset(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); MapperConfig.Configure(); }
protected void Application_Start() { MapperConfig.ConfigureMapper(); AutofacConfig.ConfigureContainer(); BundleConfig.RegisterBundles(BundleTable.Bundles); AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); }
public TaskController(ITaskService taskService, IPersonService personService, IStatusService statusService) { this.taskService = taskService; this.personService = personService; this.statusService = statusService; mapper = MapperConfig.GetMapperResult(); }
// 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"; }); }
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; } }
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(); }
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); }
public CreateAdvertServiceTests() { _advertRepository = new Mock <IGenericRepository <Advert> >(); _advertTypeRepository = new Mock <IGenericRepository <AdvertType> >(); _findPhotosById = new Mock <IFindPhotosByIdService>(); _photoService = new Mock <IPhotoService>(); MapperConfig.Register(); }
public static void RegisterDependencies(IUnityContainer container) { container.RegisterType <IUnitOfWork, UnitOfWork>(); if (!container.IsRegistered <IMapper>()) { MapperConfig.RegisterMapping(); container.RegisterType <IMapper, Mapper>(); } }
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(); }
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(); }
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); }
protected void Application_Start() { MapperConfig.Initialize(); AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); //BundleConfig.RegisterBundles(BundleTable.Bundles); }
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); }
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(); }
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(); }
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)); }
public void Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); MapperConfig.RegisterProfiles(); }
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(); }
public BookControllerTest() { MapperConfig.RegisterMappings(); var repository = new BookRepository(); var service = new BookService(repository); _bookController = new BookController(service); }
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); }
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 "}";
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); MapperConfig.RegisterMappings(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); ViewEnginesConfig.RegisterViewEngines(ViewEngines.Engines); }
public OrderbookControllerTest() { MapperConfig mapperConfig = new MapperConfig(); _mapper = mapperConfig.MapperConfiguration(); _orderbookService = new Mock <IOrderbookService>(); _orderbookController = new OrderbookController(_orderbookService.Object, _mapper); }
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)); }
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()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); //Database.SetInitializer<LMSContext>(null); MapperConfig.Configure(); Startup.Start(); }