コード例 #1
0
        public void Initialize()
        {
            // Since the repository returns Broker entities but the service returns BrokerDTO entities we need to initialize Automapper
            AutomapperBootstrapper.Initialize();

            // Initialize the data we're going to use in the tests
            _propertyListMock = PropertyMocks.GetPropertyListMock();

            // Get the DTO's by using the moked list
            _propertyListItemDtoMock = Mapper.Map <List <Property>, List <PropertyListItemDTO> >(_propertyListMock);
            _propertyDtoMock         = Mapper.Map <Property, PropertyDTO>(_propertyListMock.ElementAt(0));

            _propertyRepositoryMock = new Mock <IPropertyRepository>();

            // Initialize the mocked repository
            _propertyRepositoryMock.Setup(repository => repository.GetAll())
            .ReturnsAsync(_propertyListMock);
            _propertyRepositoryMock.Setup(repository => repository.Get(1))
            .ReturnsAsync(_propertyListMock.ElementAt(0));
            _propertyRepositoryMock.Setup(repository => repository.Get(9))
            .ReturnsAsync(null);

            // Use the mock to create an instance of the service
            _propertyServiceMock = new PropertyService(_propertyRepositoryMock.Object);
        }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: romanccoder/CinemaTickets
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            NinjectBootstrapper.Bootstrap();
            AutomapperBootstrapper.Bootstrap();
        }
コード例 #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize Automapper
            AutomapperBootstrapper.Initialize();
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the MainViewModel class.
 /// </summary>
 public InventoryViewModel()
 {
     AutomapperBootstrapper.Initialize();
     productService  = ServiceLocator.Current.GetInstance <IProductService>();
     brandService    = ServiceLocator.Current.GetInstance <IBrandService>();
     categoryService = ServiceLocator.Current.GetInstance <ICategoryService>();
     RefreshProducts();
     Brands     = new ObservableCollection <ObservableBrand>(brandService.GetAllBrands().Select(x => new ObservableBrand(x)));
     Categories = new ObservableCollection <ObservableCategory>(categoryService.GetAll().Select(x => new ObservableCategory(x)));
     if (IsInDesignMode)
     {
         // Code runs in Blend --> create design time data.
     }
     else
     {
     }
 }
コード例 #5
0
        public static ContainerBuilder Configure()
        {
            var builder = new ContainerBuilder();

            //Config
            builder.RegisterControllers(typeof(SaveLinksWeb).Assembly);

            //Core
            builder.Register(x => AutomapperBootstrapper.GetConfiguration()).SingleInstance().AutoActivate().AsSelf();
            builder.Register(x => x.Resolve <MapperConfiguration>().CreateMapper()).As <IMapper>();

            //Repositories
            builder.RegisterRepositories();

            //Services
            builder.RegisterServices();

            return(builder);
        }
コード例 #6
0
        public void Initialize()
        {
            // Since the repository returns Broker entities but the service returns BrokerDTO entities we need to initialize Automapper
            AutomapperBootstrapper.Initialize();

            // Initialize the data we're going to use in the tests
            _brokerDTOListMock = Mapper.Map <List <Broker>, List <BrokerDTO> >(BrokerMocks.GetBrokerListMock());

            _brokerServiceMock = new Mock <IBrokerService>();

            // Initialize the mocked service
            _brokerServiceMock.Setup(service => service.GetAll())
            .ReturnsAsync(_brokerDTOListMock);
            _brokerServiceMock.Setup(service => service.Get(1))
            .ReturnsAsync(_brokerDTOListMock.ElementAt(0));
            _brokerServiceMock.Setup(service => service.Get(9))
            .ReturnsAsync(null);

            // Use the mock to create an instance of the service
            _brokerControllerMock = new BrokersController(_brokerServiceMock.Object);
        }
コード例 #7
0
        public void Initialize()
        {
            // Since the repository returns Broker entities but the service returns BrokerDTO entities we need to initialize Automapper
            AutomapperBootstrapper.Initialize();

            // Initialize the data we're going to use in the tests
            _brokerListMock = BrokerMocks.GetBrokerListMock();

            // Get the list of DTO's by using the moked list
            _brokerListDtoMock = Mapper.Map <List <Broker>, List <BrokerDTO> >(_brokerListMock);

            _brokerRepositoryMock = new Mock <IBrokerRepository>();

            // Initialize the mocked repository
            _brokerRepositoryMock.Setup(repository => repository.GetAll())
            .ReturnsAsync(_brokerListMock);
            _brokerRepositoryMock.Setup(repository => repository.Get(1))
            .ReturnsAsync(_brokerListMock.ElementAt(0));
            _brokerRepositoryMock.Setup(repository => repository.Get(9))
            .ReturnsAsync(null);

            // Use the mock to create an instance of the service
            _brokerServiceMock = new BrokerService(_brokerRepositoryMock.Object);
        }
コード例 #8
0
 public static void ClassInit(TestContext context)
 {
     AutomapperBootstrapper.Initialize();
 }
コード例 #9
0
 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     AutomapperBootstrapper.Initialize();
 }