internal static IMapper SetupMapper() { var profile = new AutomapperProfile(); var configuration = new MapperConfiguration(cfg => cfg.AddProfile(profile)); return(new Mapper(configuration)); }
public static Mapper CreateMapperProfile() { var myProfile = new AutomapperProfile(); var configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile)); return(new Mapper(configuration)); }
public async Task Controller_Add_ToDo_Test() { var mockRepo = new Mock <IToDoElementRepository>(); var myProfile = new AutomapperProfile(); var configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile)); var temp = new ToDoElementAdd() { Priority = 1, Tittle = "test" }; mockRepo.Setup(x => x.CreateElementAsync(It.IsAny <ToDoElement>())).ReturnsAsync(new ToDoElement { Tittle = temp.Tittle, Priority = temp.Priority }); var controller = new ToDoController(mockRepo.Object, configuration.CreateMapper()); IActionResult result = (await controller.Post(temp)); Assert.IsType <OkObjectResult>(result); var objectResponse = result as OkObjectResult; Assert.Equal(200, objectResponse.StatusCode); Assert.Equal(typeof(ToDoElementDTO), objectResponse.Value.GetType()); ToDoElementDTO resultCast = objectResponse.Value as ToDoElementDTO; Assert.Equal(temp.Tittle, resultCast.Tittle); Assert.Equal(temp.Priority, resultCast.Priority); }
public void UpdateWorkflow(Guid workflowId, DTO.WorkflowDetails details) { var workflow = UnitOfWork.Find <Workflow>(workflowId); workflow.Enable(details.IsActive); workflow.Xaml = AutomapperProfile.ConstructActivitySequenceXaml(details.Activities); UnitOfWork.Commit(); }
public Guid CreateWorkflow(Guid agencyId, string title, DTO.WorkflowDetails details) { var agency = UnitOfWork.Find <Agency>(agencyId); var workflow = agency.CreateWorkflow(title, AutomapperProfile.ConstructActivitySequenceXaml(details.Activities)); workflow.Enable(details.IsActive); UnitOfWork.Commit(); return(workflow.Id); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); UnityConfig.RegisterComponents(); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AutomapperProfile.run(); }
public static void InjectDependencies(IServiceCollection services, IConfiguration Configuration) { services.AddDbContext <UnitedAppContext>(opts => opts.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddScoped <IUnitOfWork, UnitOfWork>(); services.AddScoped <IUniversityService, UniversityService>(); services.AddScoped <ISpecialityService, SpecialityService>(); services.AddScoped <IUserApplicationService, UserApplicationService>(); services.AddScoped <IRegionService, RegionService>(); services.AddScoped <IProfessionalDirectionService, ProfessionalDirectionService>(); #region DI Mapper var myProfile = new AutomapperProfile(); var config = new MapperConfiguration(cfg => cfg.AddProfile(myProfile)); IMapper mapper = config.CreateMapper(); services.AddSingleton(mapper); #endregion }
public void Initialize() { AutomapperProfile automapperProfile = new AutomapperProfile(); MapperConfiguration configuration = new MapperConfiguration(cfg => cfg.AddProfile(automapperProfile)); _mapper = new Mapper(configuration); _statisticsSvcMock = new Mock <IGameStatisticsService>(); _notificationServiceMock = new Mock <INotificationService>(); _signalRHub = new Mock <IHubContext <GameHub> >(); var clients = new Mock <IHubClients>(); var client = new Mock <IClientProxy>(); clients.Setup(x => x.Client(It.IsAny <string>())).Returns(client.Object); _signalRHub.Setup(x => x.Clients).Returns(clients.Object); _logger = new Mock <ILogger <PeerToPeerGameController> >(); }