コード例 #1
0
        public void ServiceRegistrations_AvailableAfterSealing()
        {
            var config = new BootConfiguration();

            config.Seal();
            Assert.NotNull(config.ServiceRegistrations);
        }
コード例 #2
0
        public void ContainsPancakesAssembly_ByDefault()
        {
            var config = new BootConfiguration();

            config.Seal();
            Assert.Collection(config.Assemblies, item => Assert.NotNull(item), item => Assert.True(item.FullName.StartsWith("Pancakes")));
        }
コード例 #3
0
        public void Sealing_MarksHasBeenSealed()
        {
            var config = new BootConfiguration();

            Assert.False(config.Sealed);
            config.Seal();
            Assert.True(config.Sealed);
        }
コード例 #4
0
        public void WillNotReaddAssemblies_AtSeal_WhenAlreadyAdded()
        {
            var config = new BootConfiguration();

            config.LoadAssembly(typeof(BootConfiguration).GetTypeInfo().Assembly);
            config.Seal();
            Assert.True(config.Assemblies.Count() == 2);
        }
コード例 #5
0
        public void ContainsEntryPointAssembly_ByDefault()
        {
            var config = new BootConfiguration();

            config.Seal();
            Assert.Collection(config.Assemblies,
                              item => Assert.True(item.FullName.StartsWith("dotnet-test-xunit")),
                              item => Assert.NotNull(item)); // we don't care about this item for this test.
        }
コード例 #6
0
        private void TestPostBootCheckWithAcion(Action <BootConfiguration> action)
        {
            var config = new BootConfiguration();

            config.Seal();
            var exception = Assert.Throws <ErrorCodeInvalidOperationException>(() => action(config));

            Assert.Equal(CoreErrorCodes.CannotConfigurePostBoot, exception.ErrorCode);
        }
コード例 #7
0
        public void PostSealing_ContainsValidCommands()
        {
            var config = new BootConfiguration();

            config.LoadAssembly(typeof(TestCommand).GetTypeInfo().Assembly);
            config.Seal();

            Assert.True(config.Commands.Any(s => s == typeof(TestCommand)));
        }
コード例 #8
0
        public void PostSealing_ContainsValidSanityChecks()
        {
            var config = new BootConfiguration();

            config.LoadAssembly(typeof(SanityCheck).GetTypeInfo().Assembly);
            config.Seal();

            Assert.True(config.SanityChecks.Any(s => s == typeof(SanityCheck)));
        }
コード例 #9
0
        public void PostSealing_ContainsValidServiceRegistrations()
        {
            var config = new BootConfiguration();

            config.LoadAssembly(typeof(TestServiceRegistration).GetTypeInfo().Assembly);
            config.Seal();

            Assert.True(config.ServiceRegistrations.Any(sr => sr.GetType() == typeof(TestServiceRegistration)));
        }
コード例 #10
0
        public void ThrowsBootException_WhenSanityCheckFails()
        {
            var kernel        = new Kernel();
            var configuration = new BootConfiguration(AssemblyCollectionMockBuilder.GetWithFailingSanityCheck());

            configuration.Seal();
            var exception = Assert.Throws <BootException>(() => kernel.Boot(configuration));

            Assert.Equal(CoreErrorCodes.InsaneKernel, exception.ErrorCode);
        }
コード例 #11
0
        public void RegistersCommandsFromBootConfiguration()
        {
            var kernel        = new Kernel();
            var configuration = new BootConfiguration(AssemblyCollectionMockBuilder.GetWithEasyCommand());

            configuration.WithOutput(this.output.WriteLine);
            configuration.Seal();

            kernel.Boot(configuration);

            var registry = kernel.ServiceLocator.GetService <ICommandRegistry>();

            Assert.True(registry.IsRegistered("Test"));
        }