Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //setup the servicelocator
            ServiceLocator locator = ServiceLocator.Instance;

            locator.AddService(typeof(IFileSystem), new FileSystemWrapper());
            locator.AddService(typeof(ProcessSettings), SettingsFactory.CreateProcessSettings());
            locator.AddService(typeof(IBuildServiceFacade), new ClientFacade());
            locator.AddService(typeof(ILogger), new ConsoleLogger());

            bool everythingOk = true;

            try
            {
                locator.GetService <ProcessSettings>().Validate();
            }
            catch (Exception ex)
            {
                locator.GetService <ILogger>().Log(ex.Message);
                everythingOk = false;
            }

            if (everythingOk)
            {
                _watcher = new SubmitWatcher();
                Console.WriteLine("Start watching for submits to process.. Press enter to quit.");
                _watcher.StartWatching();
            }

            Console.ReadLine();
        }
Exemplo n.º 2
0
        private static ServiceLocator Config()
        {
            var sl = new ServiceLocator();

            sl.AddService <IOrderService, OrderService>();
            sl.AddService <ICustomerService, CustomerService>();

            return(sl);
        }
Exemplo n.º 3
0
        public void GetService_ReplaceService_ReturnService()
        {
            ServiceLocator locator = ServiceLocator.Instance;

            locator.AddService(typeof(IFileSystem), new FileSystemWrapper());
            locator.AddService(typeof(IFileSystem), new FileSystemWrapper());
            IFileSystem fs = locator.GetService <IFileSystem>();

            Assert.IsNotNull(fs);
        }
        private void Awake()
        {
            ServiceLocator.AddService(this);
#if UNITY_EDITOR
            AwakeEditor();
#endif
        }
            public void DeveloperModeIsFalseByDefault()
            {
                ServiceLocator.AddService <BaseStorageService>(new StorageService());
                var channel = new PersistenceChannel();

                Assert.IsFalse(channel.DeveloperMode.Value);
            }
            public void DeveloperModeCanBeModifiedByConfiguration()
            {
                ServiceLocator.AddService <BaseStorageService>(new StorageService());
                var channel = new PersistenceChannel();

                channel.DeveloperMode = true;
                Assert.IsTrue(channel.DeveloperMode.Value);
            }
            public void WhenSetToTrueChangesTelemetryBufferCapacityToOneForImmediateTransmission()
            {
                ServiceLocator.AddService <BaseStorageService>(new StorageService());
                var channel = new PersistenceChannel();

                channel.DeveloperMode = true;
                Assert.AreEqual(1, channel.TelemetryBuffer.Capacity);
            }
            public void GetterReturnsTelemetryBufferCapacity()
            {
                ServiceLocator.AddService <BaseStorageService>(new StorageService());
                var channel = new PersistenceChannel();

                channel.TelemetryBuffer.Capacity = 42;
                Assert.AreEqual(42, channel.MaxTelemetryBufferCapacity);
            }
Exemplo n.º 9
0
    public override void Awake()
    {
        base.Awake();

        LocaleData.Initialize(_LocaleTextAsset);
        // Add to the service locator
        ServiceLocator.AddService(typeof(IShooter), this);
    }
Exemplo n.º 10
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            MainPageVM mainPageVM = (MainPageVM)this.DataContext;

            mainPageVM.NavigationService = this.NavigationService;
            ServiceLocator.AddService <NavigationService>(this.NavigationService);
            mainPageVM.OnPropertyChanged("LoginStatus");
            base.OnNavigatedTo(e);
        }
Exemplo n.º 11
0
        public async Task InitializeSetsSdkVersionPropertyOfGivenTelemetry()
        {
            ServiceLocator.AddService <IPlatformService>(new PlatformService());
            var initializer      = new SdkVersionPropertyContextInitializer();
            var telemetryContext = new TelemetryContext();
            await initializer.Initialize(telemetryContext);

            Assert.NotNull(telemetryContext.Internal.SdkVersion);
        }
Exemplo n.º 12
0
        public void ConstructorAddsExceptionToExceptionPropertyAndExceptionsCollectionProperty()
        {
            ServiceLocator.AddService <IPlatformService>(new PlatformService());
            Exception constructorException   = new Exception("ConstructorException");
            var       testExceptionTelemetry = new ExceptionTelemetry(constructorException);

            Assert.Same(constructorException, testExceptionTelemetry.Exception);
            Assert.Equal(constructorException.Message, testExceptionTelemetry.Exceptions.First().message);
        }
Exemplo n.º 13
0
        public void SerializeWritesSingleInnerExceptionOfAggregateExceptionOnlyOnce()
        {
            ServiceLocator.AddService <IPlatformService>(new PlatformService());
            var exception = new AggregateException("Test Exception", new Exception());

            ExceptionTelemetry expected = CreateExceptionTelemetry(exception);
            var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem <ExceptionTelemetry, DataPlatformModel.ExceptionData>(expected);

            Assert.Equal(2, item.Data.BaseData.Exceptions.Count);
        }
 public void TestInitialize()
 {
     ServiceLocator.AddService <IPlatformService>(new PlatformService());
     ServiceLocator.AddService <IApplicationService>(new ApplicationService());
     this.applicationSettings = new Dictionary <string, object>();
     this.platform            = new StubPlatform {
         OnGetApplicationSettings = () => this.applicationSettings,
     };
     PlatformSingleton.Current = this.platform;
 }
Exemplo n.º 15
0
        public void Register_Single_Transient_Service()
        {
            var serviceLocator = new ServiceLocator();

            serviceLocator.AddService <GuidTest>(ServiceType.Transient);

            var guid1 = serviceLocator.GetService <GuidTest>().Guid;
            var guid2 = serviceLocator.GetService <GuidTest>().Guid;

            guid1.ShouldNotBe(guid2);
        }
Exemplo n.º 16
0
        public void Register_Keyed_With_Interface_Transient_Service()
        {
            var serviceLocator = new ServiceLocator();

            serviceLocator.AddService <IGuidTest, GuidTest>("key", ServiceType.Transient);

            var guid1 = serviceLocator.GetService <IGuidTest>("key").Guid;
            var guid2 = serviceLocator.GetService <IGuidTest>("key").Guid;

            guid1.ShouldNotBe(guid2);
        }
            public void EndpointAddressCanBeModifiedByConfiguration()
            {
                ServiceLocator.AddService <BaseStorageService>(new StorageService());
                var channel = new PersistenceChannel();

                Uri expectedEndpoint = new Uri("http://abc.com");

                channel.EndpointAddress = expectedEndpoint.AbsoluteUri;

                Assert.AreEqual(expectedEndpoint, new Uri(channel.EndpointAddress));
            }
            public void WhenSetToFalseChangesTelemetryBufferCapacityToOriginalValueForBufferedTransmission()
            {
                ServiceLocator.AddService <BaseStorageService>(new StorageService());
                var channel = new PersistenceChannel();
                int originalTelemetryBufferSize = channel.TelemetryBuffer.Capacity;

                channel.DeveloperMode = true;
                channel.DeveloperMode = false;

                Assert.AreEqual(originalTelemetryBufferSize, channel.TelemetryBuffer.Capacity);
            }
Exemplo n.º 19
0
        public void Register_Keyed_Factory_Transient_Service()
        {
            var serviceLocator = new ServiceLocator();

            serviceLocator.AddService("key", ServiceType.Transient, (__) => new GuidTest());

            var guid1 = serviceLocator.GetService <GuidTest>("key").Guid;
            var guid2 = serviceLocator.GetService <GuidTest>("key").Guid;

            guid1.ShouldNotBe(guid2);
        }
Exemplo n.º 20
0
        public void Register_Keyed_With_Interface_Factory_Singleton_Service()
        {
            var serviceLocator = new ServiceLocator();

            serviceLocator.AddService <IGuidTest>("key", ServiceType.Singleton, (__) => new GuidTest());

            var guid1 = serviceLocator.GetService <IGuidTest>("key").Guid;
            var guid2 = serviceLocator.GetService <IGuidTest>("key").Guid;

            guid1.ShouldBe(guid2);
        }
Exemplo n.º 21
0
        public void Register_Keyed_Single_Singleton_Service()
        {
            var serviceLocator = new ServiceLocator();

            serviceLocator.AddService <GuidTest>("key", ServiceType.Singleton);

            var guid1 = serviceLocator.GetService <GuidTest>("key").Guid;
            var guid2 = serviceLocator.GetService <GuidTest>("key").Guid;

            guid1.ShouldBe(guid2);
        }
Exemplo n.º 22
0
        public void Register_With_Interface_Singleton_Service()
        {
            var serviceLocator = new ServiceLocator();

            serviceLocator.AddService <IGuidTest, GuidTest>(ServiceType.Singleton);

            var guid1 = serviceLocator.GetService <IGuidTest>().Guid;
            var guid2 = serviceLocator.GetService <IGuidTest>().Guid;

            guid1.ShouldBe(guid2);
        }
Exemplo n.º 23
0
        public void Register_With_Interface_Factory_Transient_Service()
        {
            var serviceLocator = new ServiceLocator();

            serviceLocator.AddService <IGuidTest>(ServiceType.Transient, (__) => new GuidTest());

            var guid1 = serviceLocator.GetService <IGuidTest>().Guid;
            var guid2 = serviceLocator.GetService <IGuidTest>().Guid;

            guid1.ShouldNotBe(guid2);
        }
Exemplo n.º 24
0
        public void Register_Factory_Singleton_Service()
        {
            var serviceLocator = new ServiceLocator();

            serviceLocator.AddService(ServiceType.Singleton, (__) => new GuidTest());

            var guid1 = serviceLocator.GetService <GuidTest>().Guid;
            var guid2 = serviceLocator.GetService <GuidTest>().Guid;

            guid1.ShouldBe(guid2);
        }
Exemplo n.º 25
0
            public void AddsItselfToTelemetryInitializersToSetSessionIdForAllTelemetryTypes()
            {
                ServiceLocator.AddService <IApplicationService>(new ApplicationService());
                var module        = new SessionTelemetryModule(new StubPlatform(), new StubClock());
                var configuration = new TelemetryConfiguration();

                configuration.TelemetryChannel = new InMemoryChannel();
                module.Initialize();

                Assert.Contains(module, TelemetryConfiguration.Active.TelemetryInitializers);
            }
        public void WindowsBootStrapperSettingTheInstrumentationKeyWhenSupplied()
        {
            ServiceLocator.AddService <BaseStorageService>(new TestStorageService());

            string instrumentationKey = Guid.NewGuid().ToString();

            WindowsAppInitializer.InitializeAsync(instrumentationKey, new TelemetryConfiguration()
            {
                Collectors = WindowsCollectors.Metadata
            }).GetAwaiter().GetResult();
            Assert.IsFalse(string.IsNullOrEmpty(TelemetryConfiguration.Active.InstrumentationKey));
        }
Exemplo n.º 27
0
        public void ExceptionPropertySetterReplacesExceptionDetailsInExceptionsCollectionProperty()
        {
            ServiceLocator.AddService <IPlatformService>(new PlatformService());
            Exception constructorException   = new Exception("ConstructorException");
            var       testExceptionTelemetry = new ExceptionTelemetry(constructorException);

            Exception nextException = new Exception("NextException");

            testExceptionTelemetry.Exception = nextException;

            Assert.Same(nextException, testExceptionTelemetry.Exception);
            Assert.Equal(nextException.Message, testExceptionTelemetry.Exceptions.First().message);
        }
            public void PassesTelemetryToMemoryBufferChannel()
            {
                ServiceLocator.AddService <BaseStorageService>(new StorageService());
                var channel = new PersistenceChannel();

                var telemetry = new StubTelemetry();

                channel.Send(telemetry);

                IEnumerable <ITelemetry> actual = channel.TelemetryBuffer.Dequeue();

                Assert.AreEqual(telemetry, actual.First());
            }
        private void Awake()
        {
            OnBeginConnectingSignal        = new Signal();
            OnConnectedToMasterSignal      = new Signal();
            OnDisconnectedFromMasterSignal = new Signal();
            OnConnectionFailSignal         = new Signal <string>();
            OnJoinedRoomSignal             = new Signal();
            OnAllPlayersConnectedSignal    = new Signal();
            OnRemoteBoardChangeSignal      = new Signal <Seed, int, int>();
            OnNewGameStartedSignal         = new Signal();

            ServiceLocator.AddService <INetworkService>(this);
        }
Exemplo n.º 30
0
        public async Task InitializeSetsSdkVersionValueAsAssemblyVersion()
        {
            ServiceLocator.AddService <IPlatformService>(new PlatformService());
            var initializer      = new SdkVersionPropertyContextInitializer();
            var telemetryContext = new TelemetryContext();
            await initializer.Initialize(telemetryContext);

            string expectedSdkVersion;

            expectedSdkVersion = typeof(SdkVersionPropertyContextInitializer).GetTypeInfo().Assembly.GetCustomAttributes <AssemblyFileVersionAttribute>()
                                 .First()
                                 .Version;
            Assert.Equal("hockeysdk.uwp:" + expectedSdkVersion, telemetryContext.Internal.SdkVersion);
        }