public VendingMachineControllerTest()
 {
     _container      = new Container(new TestRegistry());
     _controller     = _container.GetInstance <VendingMachineController>();
     _vmRepository   = _container.GetInstance <IRepository <VendingMachine> >();
     _userRepository = _container.GetInstance <IRepository <User> >();
     _goodRepository = _container.GetInstance <IRepository <Good> >();
 }
Exemple #2
0
        void ConnectToSubscriptionService()
        {
            _subscriptionServiceEndpoint =
                _bus.GetEndpoint(_container.GetInstance <IConfiguration>().SubscriptionServiceUri);

            _subscriptionServiceEndpoint.Send(new AddSubscriptionClient(_clientId, _bus.Endpoint.Address.Uri,
                                                                        _bus.Endpoint.Address.Uri));
        }
        public static void ClassInitialize(TestContext testContext)
        {
            container = DependencyResolution.IoC.Initialize();
            var contextFactory = container.GetInstance<IDbContextFactory<HealthCheckDbContext>>();
            dbContext = contextFactory.Build();

            Assert.IsNotNull(dbContext);
        }
Exemple #4
0
        public static void SetupHubDistributr(DB_TestingHelper dbTestingHelper, IContainer structureMapContainer)
        {
//hub sql dist
            CokeDataContext ctxHubDist = structureMapContainer.GetInstance<CokeDataContext>();
            TI.trace("Remove all tables from Hub distributr db");
            dbTestingHelper.RemoveAllHubDistTables();
            TI.trace("Setup Hub distributr db");
            dbTestingHelper.SetupHubDistSql(ctxHubDist);
        }
Exemple #5
0
        private static void RunConsole(StructureMap.IContainer container, OctoPlusOptions consoleOptions)
        {
            System.Console.WriteLine("Using key " + consoleOptions.ApiKey + " and profile at path " +
                                     consoleOptions.ProfileFile);
            var doJob = container.GetInstance <IConsoleDoJob>();

            doJob.StartJob(consoleOptions.ProfileFile, consoleOptions.ReleaseMessage, consoleOptions.ReleaseVersion,
                           consoleOptions.ForceDeploymentIfSamePackage).GetAwaiter().GetResult();
        }
        public static void ClassInitialize(TestContext testContext)
        {
            container = DependencyResolution.IoC.Initialize();
            var contextFactory = container.GetInstance <IDbContextFactory <HealthCheckDbContext> >();

            dbContext = contextFactory.Build();

            Assert.IsNotNull(dbContext);
        }
Exemple #7
0
        static void Main(string[] args)
        {
            //Console.WriteLine("I'm the Responder");

            Log4NetLogger.Use("responder.log4net.xml");
            IContainer c = BootstrapContainer();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new OrderForm(c.GetInstance <IServiceBus>()));
        }
 protected override void ConfigureContainer(StructureMap.IContainer container)
 {
     container.Configure(cfg =>
     {
         cfg.For <IEventAggregator>().Singleton().Use <MockEventAggregator>();
         cfg.For <Deck>().Singleton().Use(new Deck(7.Coppers(), 3.Estates()));
         cfg.For <DiscardPile>().Use <DiscardPile>();
         cfg.For <Player>().Use <Player>().Ctor <string>().Is("Test player");
         cfg.For <Guid>().Use(Guid.NewGuid);
     });
     _eventAggregator = container.GetInstance <IEventAggregator>() as MockEventAggregator;
 }
Exemple #9
0
        private void BootstrapContainer()
        {
            _container = new StructureMap.Container();
            _container.Configure(x =>
            {
                x.For <IConfiguration>()
                .Singleton()
                .Use <Configuration>();
            });

            var registry = new SystemViewRegistry(_container.GetInstance <IConfiguration>());

            _container.Configure(x => x.AddRegistry(registry));
        }
Exemple #10
0
        protected override void ConfigureContainer(StructureMap.IContainer container)
        {
            base.ConfigureContainer(container);

            new Bootstrapper().BootstrapApplication(container);
            container.Configure(cfg =>
            {
                cfg.For <PlayerBuilder>()
                .EnrichAllWith(x => x.ForSpec(new PlayerSpec().WithController(new NaivePlayerController())));
                cfg.For <IEventAggregator>().Singleton().Use <MockEventAggregator>();

                //cfg.For<IPlayerController>().Use<NaivePlayerController>();
            });

            _eventAggregator = container.GetInstance <IEventAggregator>() as MockEventAggregator;
            container.SetDefaultsToProfile("UnitTests");
        }
Exemple #11
0
 public object GetService(Type serviceType)
 {
     if (serviceType == null)
     {
         return(null);
     }
     try
     {
         return(serviceType.IsAbstract || serviceType.IsInterface
                  ? container.TryGetInstance(serviceType)
                  : container.GetInstance(serviceType));
     }
     catch
     {
         return(null);
     }
 }
        public void Test03TestOnDelete()
        {
            dbCreated = true;
            var test = new Test
            {
                Name = "Test",
                ClientApplication = new ClientApplication
                {
                    Name     = "Test app",
                    Key      = Guid.NewGuid(),
                    IsActive = true
                },
                IsActive = true,
                Key      = "Test"
            };

            dbContext.Tests.Add(test);

            // save and refresh context
            dbContext.SaveChanges();
            dbContext.Dispose();
            var contextFactory = container.GetInstance <IDbContextFactory <HealthCheckDbContext> >();

            dbContext = contextFactory.Build();

            var beforeDelete = dbContext.Tests.Count();

            Assert.IsTrue(beforeDelete > 0, "No tests after save.");

            var test2 = dbContext.Tests.First(g => g.Id == test.Id); // reload from new context

            dbContext.Tests.Remove(test2);
            dbContext.SaveChanges();

            int afterDelete = dbContext.Tests.Count();

            Assert.AreEqual(beforeDelete - 1, afterDelete, "Tests should be deleted.");
        }
 private IAggregateEventStore EventStore()
 {
     return(new MySqlEventSource(container.GetInstance <MySqlConnectionString>(), bus));
 }
Exemple #14
0
 public object Resolve(Type resolve)
 {
     return(_container.GetInstance(resolve));
 }
Exemple #15
0
 /// <summary>
 /// Gets the currently-registered <see cref="Keyboard"/> class.
 /// </summary>
 /// <returns><see cref="IKeyboard"/></returns>
 static public IKeyboard GetKeyboard()
 {
     return(container.GetInstance <IKeyboard>());
 }
Exemple #16
0
 public T Resolve <T>()
 {
     return(_mapContainer.GetInstance <T>());
 }
                protected override void ConfigureContainer(StructureMap.IContainer container)
                {
                    base.ConfigureContainer(container);

                    container.GetInstance <SchemaManagerGlobalOptions>().TargetRevision = new DatabaseVersion(0, 0, 0, 0);
                }
Exemple #18
0
 public bool HasService(Type service)
 {
     return(_container.GetInstance(service) != null);
 }
 public void StructureMap()
 {
     structureMapContainer.GetInstance(Types[Depth].serviceType);
 }
 public TService Resolve <TService>() where TService : class
 {
     return(structureMapContainer.GetInstance <TService>());
 }
Exemple #21
0
 public T GetInstance <T>()
 {
     return(_container.GetInstance <T>());
 }
 protected override object GetInstance(Type serviceType, string key)
 {
     return(string.IsNullOrEmpty(key)
         ? _container.GetInstance(serviceType)
         : _container.GetInstance(serviceType ?? typeof(object), key));
 }