public LiveMode()
            {
                For <DbContext>().Use <DockyardDbContext>();
                For <IDBContext>().Use <DockyardDbContext>();
                For <CloudFileManager>().Use <CloudFileManager>();

                var mode = CloudConfigurationManager.GetSetting("AuthorizationTokenStorageMode");

                if (mode != null)
                {
                    switch (mode.ToLower())
                    {
                    case "local":
                        For <IAuthorizationTokenRepository>().Use <SqlAuthorizationTokenRepository>();
                        break;

                    case "keyvault":
                        For <IAuthorizationTokenRepository>().Use <KeyVaultAuthorizationTokenRepository>();
                        break;

                    default:
                        throw new NotSupportedException($"Unsupported AuthorizationTokenStorageMode = {mode}");
                    }
                }
                else
                {
                    For <IAuthorizationTokenRepository>().Use <AuthorizationTokenRepositoryStub>();
                }

                For <IAuthorizationTokenStorageProvider>().Use <EfAuthorizationTokenStorageProvider>();

                For <IPlanStorageProvider>().Use <PlanStorageProviderEf>();
                For <ISqlConnectionProvider>().Use <SqlConnectionProvider>();
                For <IMtObjectsStorage>().Use <SqlMtObjectsStorage>().Singleton();
                For <IMtTypeStorageProvider>().Use <SqlMtTypeStorageProvider>();
                For <ISqlConnectionProvider>().Use <SqlConnectionProvider>();
                For <ISecurityObjectsStorageProvider>().Use <SqlSecurityObjectsStorageProvider>();
                For <ISecurityObjectsStorageProvider>().DecorateAllWith <SecurityObjectsStorage>();
                For <IUtilizationDataProvider>().Use <SqlUtilizationDataProvider>();

                var defaultEncryptionProvider = CloudConfigurationManager.GetSetting("DefaultEncryptionProvider");

                if (!string.IsNullOrWhiteSpace(defaultEncryptionProvider))
                {
                    var providerType = Type.GetType(defaultEncryptionProvider, false);

                    if (providerType == null)
                    {
                        throw new NotSupportedException($"Encryption provider {defaultEncryptionProvider} was not found.");
                    }

                    For(typeof(IEncryptionProvider)).Use(providerType);
                }
                else
                {
                    For <IEncryptionProvider>().Use <RijndaelEncryptionProviderWithCompressionV1>().Singleton();
                }

                DataAutoMapperBootStrapper.ConfigureAutoMapper();
            }
Beispiel #2
0
        public virtual void SetUp()
        {
            ObjectFactory.Initialize();
            StructureMapBootStrapper.ConfigureDependencies(StructureMapBootStrapper.DependencyType.TEST);
            MockedDBContext.WipeMockedDatabase();
            ConfigureAutoMapper();
            DataAutoMapperBootStrapper.ConfigureAutoMapper();
            CrateManager = ObjectFactory.Container.GetInstance <ICrateManager>();
            ObjectFactory.Configure(x => x.AddRegistry <Fr8.Infrastructure.StructureMap.StructureMapBootStrapper.TestMode>());


            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>()) //Get the seeding done first
                uow.SaveChanges();
        }
Beispiel #3
0
        public void Configuration(IAppBuilder app, bool selfHost)
        {
            ConfigureProject(selfHost, TerminalDocusignStructureMapBootstrapper.LiveConfiguration);
            Container.Configure(Hub.StructureMap.StructureMapBootStrapper.LiveConfiguration);

            DataAutoMapperBootStrapper.ConfigureAutoMapper();
            SwaggerConfig.Register(_configuration);
            RoutesConfig.Register(_configuration);
            ConfigureFormatters();
            app.UseWebApi(_configuration);
            if (!selfHost)
            {
                StartHosting();
            }
        }
Beispiel #4
0
        public void Configuration(IAppBuilder app, bool selfHost)
        {
            ConfigureProject(selfHost, Fr8CoreStructureMapConfiguration.LiveConfiguration);

            Container.Configure(x => x.AddRegistry <Hub.StructureMap.StructureMapBootStrapper.LiveMode>());
            DataAutoMapperBootStrapper.ConfigureAutoMapper();

            SwaggerConfig.Register(_configuration);
            RoutesConfig.Register(_configuration);
            ConfigureFormatters();

            app.UseWebApi(_configuration);

            if (!selfHost)
            {
                StartHosting();
            }
        }
        public override void SetUp()
        {
            base.SetUp();
            const StructureMapBootStrapper.DependencyType dependencyType = StructureMapBootStrapper.DependencyType.TEST;

            DataAutoMapperBootStrapper.ConfigureAutoMapper();
            StructureMapBootStrapper.ConfigureDependencies(dependencyType).ConfigureTwilioDependencies(dependencyType);
            TerminalBootstrapper.ConfigureTest();

            _crate = ObjectFactory.GetInstance <ICrateManager>();

            var twilioService = new Mock <ITwilioService>();

            twilioService
            .Setup(c => c.GetRegisteredSenderNumbers())
            .Returns(new List <string> {
                ConfigurationManager.AppSettings["TestPhoneNumber"]
            });
            ObjectFactory.Configure(cfg => cfg.For <ITwilioService>().Use(twilioService.Object));

            var activityDO    = FixtureData.ConfigureTwilioActivity();
            var actionService = new Mock <IActivity>();

            ObjectFactory.Configure(cfg => cfg.For <IActivity>().Use(actionService.Object));

            /*
             * var activity = FixtureData.ConfigureTwilioActivity();
             *
             * var baseTerminalAction = new Mock<ExplicitTerminalActivity>();
             * baseTerminalAction
             *  .Setup(c => c.GetDesignTimeFields(CrateDirection.Upstream, AvailabilityType.NotSet))
             *  .Returns(Task.FromResult(FixtureData.TestFields()));
             * ObjectFactory.Configure(cfg => cfg.For<ExplicitTerminalActivity>().Use(baseTerminalAction.Object));
             */
            var hubCommunicator = new Mock <IHubCommunicator>();

            /* hubCommunicator.Setup(hc => hc.GetDesignTimeFieldsByDirection(
             *                                   It.IsAny<Guid>(),
             *                                   CrateDirection.Upstream,
             *                                   It.IsAny<AvailabilityType>())).Returns(Task.FromResult(FixtureData.TestFields()));*/
            ObjectFactory.Configure(cfg => cfg.For <IHubCommunicator>().Use(hubCommunicator.Object));
        }
            public TestMode()
            {
                For <IAuthorizationTokenStorageProvider>().Use <MockedDbAuthorizationTokenStorageProvider>();
                For <IAuthorizationTokenRepository>().Use <AuthorizationTokenRepositoryForTests>();
                For <IDBContext>().Use <MockedDBContext>();
                For <CloudFileManager>().Use <CloudFileManager>();
                For <IPlanCacheExpirationStrategy>().Use(_ => new SlidingExpirationStrategy(TimeSpan.FromDays(365))).Singleton();     // in test mode cache will never expire in practice
                For <ISecurityCacheExpirationStrategy>().Use(_ => new SlidingExpirationStrategy(TimeSpan.FromDays(365))).Singleton(); // in test mode cache will never expire in practice
                For <IPlanCache>().Use <PlanCache>().Singleton();
                For <ISecurityObjectsCache>().Use <SecurityObjectsCache>().Singleton();
                For <IPlanStorageProvider>().Use <PlanStorageProviderMockedDb>();
                For <ISqlConnectionProvider>().Use <DummyConnectionProvider>();
                For <IMtObjectsStorage>().Use <InMemoryMtObjectsStorage>().Singleton();
                For <IMtTypeStorageProvider>().Use <InMemoryMtTypeStorageProvider>();
                For <ISecurityObjectsStorageProvider>().Use <InMemorySecurityObjectsStorageProvider>();
                For <IEncryptionProvider>().Use <BypassEncryptionProvider>().Singleton();
                For <IUtilizationDataProvider>().Use <MockedUtilizationDataProvider>().Singleton();

                DataAutoMapperBootStrapper.ConfigureAutoMapper();
            }