Example #1
0
        protected IDataServices SetupDataServices()
        {
            var executor     = _testBase.SetupSqlQueryExecutor();
            var dataServices = new DataServiceImplementation(executor);

            return(dataServices);
        }
 public void SetUp()
 {
     try
     {
         SqlExecutor  = SetupSqlQueryExecutor();
         DataServices = new DataServiceImplementation(SqlExecutor);
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
Example #3
0
        /// <summary>
        ///  This method register global services provided to to the module.
        /// </summary>
        protected override void ConfigureContainer()
        {
            logger.Debug("Configure Prism Container");
            base.ConfigureContainer();
            try
            {
                Container.RegisterType <IRegionNavigationContentLoader, ScopedRegionNavigationContentLoader>(new ContainerControlledLifetimeManager());

                /*
                 * IUnityContainer unityContainer, IDataServices dataServices, IDialogService dialog, ISqlExecutor executor)
                 */

                string   connParams = ConnectionString;
                object[] dbParams   = new object[1];
                dbParams[0] = connParams;
                InjectionConstructor injectionConstructorDb = new InjectionConstructor(dbParams);
                Container.RegisterType <ISqlExecutor, OleDbExecutor>(new ContainerControlledLifetimeManager(), injectionConstructorDb);
                object[] values = new object[1];
                values[0] = Container.Resolve <ISqlExecutor>();
                InjectionConstructor injectionConstructor = new InjectionConstructor(values);
                logger.Debug("Registering types in the dependency injection...");
                Container.RegisterType <IDataServices, DataServiceImplementation>(new ContainerControlledLifetimeManager(), injectionConstructor);


                var           currentValue = new object[3];
                ISqlExecutor  sqlExecutor  = new OleDbExecutor();
                IDataServices dataServices = new DataServiceImplementation(sqlExecutor);
                currentValue[0] = Container.Resolve <IUnityContainer>();
                currentValue[1] = Container.Resolve <IDataServices>();
                currentValue[2] = Container.Resolve <ISqlExecutor>();
                var requestControllerInjected = new object[1];
                requestControllerInjected[0] = Container;



                InjectionConstructor injectionContainer     = new InjectionConstructor(requestControllerInjected);
                InjectionConstructor injectionIntoViewModel = new InjectionConstructor(currentValue);

                Container.RegisterType <RequestController>(new ContainerControlledLifetimeManager(), injectionContainer);
                Container.RegisterType <TestMainWindowViewModel>(injectionIntoViewModel);
                // The dal service is used to access to the database
                logger.Debug("Resolving configuration container");
            }
            catch (Exception e)
            {
                logger.Error("Error during the container configuration. KarveWin cannot start! Reason:" + e.Message);
                MessageBox.Show(e.Message, "Error during the container configuration. KarveWin cannot start!", MessageBoxButton.OK);
            }
        }
        public async Task Should_Receive_ACorrectPayloadAndExposeDataObject()
        {
            _testBase = new DAL.TestBase();

            IConfigurationService configurationService = _testBase.SetupConfigurationService();
            ISqlExecutor          queryExecutor        = _testBase.SetupSqlQueryExecutor();
            IDataServices         dataServices         = new DataServiceImplementation(queryExecutor);
            var value   = dataServices.GetOfficeDataServices();
            var offices = await value.GetAsyncAllOfficeSummary();

            var         dataObject  = offices.FirstOrDefault();
            DataPayLoad dataPayLoad = new DataPayLoad
            {
                HasDataObject   = true,
                PrimaryKeyValue = IdDefault,
                DataObject      = dataObject
            };

            _companyInfoViewModel.IncomingPayload(dataPayLoad);
            var outObject = _companyInfoViewModel.DataObject;

            Assert.NotNull(outObject);
            Assert.Equals(outObject.Codigo, IdDefault);
        }