Exemplo n.º 1
0
        public void Initialize_ComposesProperties()
        {
            TestableBootstrapper bootstrapper = new TestableBootstrapper();

            bootstrapper.Initialize();

            Assert.IsInstanceOfType(bootstrapper.ActivationManager, typeof(MockActivationManager));
        }
        public void Initialize_ComposesProperties()
        {
            TestableBootstrapper bootstrapper = new TestableBootstrapper();

            bootstrapper.Initialize();

            Assert.IsAssignableFrom(typeof(MockActivationManager), bootstrapper.ActivationManager);
        }
Exemplo n.º 3
0
        public void ApplicationServices_ThrowsException_IfNotInitialized()
        {
            TestableBootstrapper bootstrapper = new TestableBootstrapper();

            var e = Assert.Throws <InvalidOperationException>(() => { var s = bootstrapper.ApplicationServices; });

            Assert.Equal("The bootstrapper must be initialized before performing this operation.", e.Message);
        }
Exemplo n.º 4
0
        public void OnActivated_CallsSetupServices()
        {
            TestableBootstrapper bootstrapper = new TestableBootstrapper();
            bootstrapper.Initialize();

            bootstrapper.SimulateActivate(new MockActivatedEventArgs(ActivationKind.Launch));

            CollectionAssert.Contains((ICollection)bootstrapper.SetupMethodCalls, "SetupServices");
        }
Exemplo n.º 5
0
        public void Initialize_SetsApplicationServices()
        {
            TestableBootstrapper bootstrapper = new TestableBootstrapper();

            bootstrapper.Initialize();

            Assert.NotNull(bootstrapper.ApplicationServices);
            Assert.Equal(bootstrapper.ServiceProvider, bootstrapper.ApplicationServices);
        }
Exemplo n.º 6
0
        public void Initialize_CallsConfigureServicesThenConfigure()
        {
            TestableBootstrapper bootstrapper = new TestableBootstrapper();

            bootstrapper.Initialize();

            Assert.Equal(2, bootstrapper.MethodCalls.Count);
            Assert.Equal("ConfigureServices", bootstrapper.MethodCalls[0].Item1);
            Assert.Equal("Configure", bootstrapper.MethodCalls[1].Item1);
        }
        public void Activate_ThrowsException_IfEventArgsAreNull()
        {
            TestableBootstrapper bootstrapper = new TestableBootstrapper();
            bootstrapper.Initialize();

            var e = Assert.Throws<ArgumentNullException>(() => bootstrapper.Activate(null));

            Assert.Equal("Value cannot be null.\r\nParameter name: args", e.Message);
            Assert.Equal("args", e.ParamName);
        }
Exemplo n.º 8
0
        public void OnActivated_CallsSetupServices_OnlyOnce()
        {
            TestableBootstrapper bootstrapper = new TestableBootstrapper();
            bootstrapper.Initialize();

            bootstrapper.SimulateActivate(new MockActivatedEventArgs(ActivationKind.Launch));
            bootstrapper.SimulateActivate(new MockActivatedEventArgs(ActivationKind.Launch));
            bootstrapper.SimulateActivate(new MockActivatedEventArgs(ActivationKind.Launch));

            Assert.AreEqual(1, bootstrapper.SetupMethodCalls.Count(str => str == "SetupServices"));
        }
Exemplo n.º 9
0
        public void Initialize_CallsConfigureServices_WithValidServiceCollection()
        {
            TestableBootstrapper bootstrapper = new TestableBootstrapper();

            bootstrapper.Initialize();

            object[]           args = bootstrapper.MethodCalls.Where(m => m.Item1 == "ConfigureServices").FirstOrDefault().Item2;
            IServiceCollection serviceCollection = args[0] as IServiceCollection;

            Assert.NotNull(serviceCollection);
        }
Exemplo n.º 10
0
        public void OnActivated_Launch_PassesActivationEventToNavigationManager()
        {
            TestableBootstrapper bootstrapper = new TestableBootstrapper();
            bootstrapper.Initialize();

            bootstrapper.SimulateActivate(new MockActivatedEventArgs(ActivationKind.Launch));

            MockActivationManager activationManager = (MockActivationManager)bootstrapper.ActivationManager;
            Assert.AreEqual(1, activationManager.ActivationEventArgs.Count);
            Assert.IsInstanceOfType(activationManager.ActivationEventArgs[0], typeof(MockActivatedEventArgs));
            Assert.AreEqual(ActivationKind.Launch, activationManager.ActivationEventArgs[0].Kind);
        }
Exemplo n.º 11
0
        public void Initialize_CallsConfigure_WithOkraAppBuilder()
        {
            TestableBootstrapper bootstrapper = new TestableBootstrapper();

            bootstrapper.Initialize();

            object[]        args       = bootstrapper.MethodCalls.Where(m => m.Item1 == "Configure").FirstOrDefault().Item2;
            IOkraAppBuilder appBuilder = args[0] as IOkraAppBuilder;

            Assert.NotNull(appBuilder);
            Assert.Equal(bootstrapper.OkraAppBuilder, appBuilder);
        }