public void WhenServiceRegisteredAsSingletonThenGetSameInstance() { var factory = new SimpleServiceContainer(); factory.RegisterSingleton <IMyService>(x => new MyService()); var first = factory.GetInstance <IMyService>(); var actual = factory.GetInstance <IMyService>(); actual.Should().Be.SameInstanceAs(first); }
public void WhenTransientServiceThenGetNewInstance() { var factory = new SimpleServiceContainer(); factory.RegisterTransient <IMyService>(x => new MyService()); var first = factory.GetInstance <IMyService>(); var actual = factory.GetInstance <IMyService>(); actual.Should().Not.Be.SameInstanceAs(first); }
public void WhenNoServiceRegisteredThenNull() { var factory = new SimpleServiceContainer(); var actual = factory.GetInstance <IMyService>(); actual.Should().Be.Null(); }
private static void StorageInitialize() { var account = container.GetInstance <CloudStorageAccount>(); new QueueStorageInitializer <StationSensorHourlyStateChanged>(account).Initialize(); new QueueStorageInitializer <StationSensorDayStateChanged>(account).Initialize(); new TableStorageInitializer(account, StationsSensorsYearActivityPersister.StationsTableName).Initialize(); }
public void WhenServiceRegisteredThenGetInstance() { var factory = new SimpleServiceContainer(); factory.RegisterTransient <IMyService>(x => new MyService()); var actual = factory.GetInstance <IMyService>(); actual.Should().Be.OfType <MyService>(); }
internal static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); InitializeDefaultFormIcon(); AuthenticationStart.Initialize(); Container.RegisterAllServices(); DomainEventsWiring.RegisterHandlers(Container); ReportsConfig.RegisterAllReports(Container.GetInstance <IReportsStore>()); Container.RegisterApplicationViewModels(Container); var mainExposer = Container.GetInstance <IViewModelExposer>(); var mainForm = new FormMain(new MainViewModel(mainExposer)); Application.Run(mainForm); Application.ThreadExit += (sender, args) => { mainExposer.Dispose(); Container.Dispose(); }; }
private static void StorageInitialize() { var account = container.GetInstance <CloudStorageAccount>(); new QueueStorageInitializer <StationSensorHourlyStateChanged>(account).Initialize(); }