public void CorrectOptionsAddedByKeyValue()
        {
            var configuration = RhetosHostTestBuilder.GetBuildConfiguration();

            Assert.AreEqual(true, configuration.GetOptions <ConfigurationProviderOptions>().LegacyKeysWarning);
            Assert.AreEqual(60.0, configuration.GetOptions <LoggingOptions>().DelayedLogTimout);
        }
        public void CorrectBuildOptions()
        {
            var configuration = RhetosHostTestBuilder.GetBuildConfiguration();

            Assert.AreEqual("TestValue", configuration.GetValue <string>("TestBuildSettings"));
            var connectionsString = configuration.GetValue <string>($"ConnectionStrings:RhetosConnectionString");

            TestUtility.AssertContains(connectionsString, new[] { "TestSql", "TestDb" });
        }
        public void CorrectRegistrationsBuildTime()
        {
            var configuration = RhetosHostTestBuilder.GetBuildConfiguration();
            var build         = new ApplicationBuildAccessor(configuration, new NLogProvider(), PluginsFromThisAssembly(), new InstalledPackages());
            var builder       = build.CreateBuildComponentsContainer();

            using (var container = builder.Build())
            {
                var registrationsDump = DumpSortedRegistrations(container);
                System.Diagnostics.Trace.WriteLine(registrationsDump);
                TestUtility.AssertAreEqualByLine(_expectedRegistrationsBuild, registrationsDump);

                TestAmbiguousRegistations(container,
                                          expectedMultiplePlugins: new[] { "Rhetos.Dsl.IDslModelIndex", "Rhetos.Extensibility.IGenerator" },
                                          expectedOverridenRegistrations: new Dictionary <Type, string> {
                    { typeof(IUserInfo), "NullUserInfo" }
                });
            }
        }
        public void CorrectRegistrationsDbUpdate()
        {
            var deployment = new ApplicationDeploymentAccessor();

            var rhetosHostBuilder = new RhetosHostTestBuilder()
                                    .ConfigureConfiguration(RhetosHostTestBuilder.GetRuntimeConfiguration)
                                    .UseBuilderLogProvider(new NLogProvider())
                                    .OverrideContainerConfiguration(deployment.SetDbUpdateComponents);

            using (var rhetosHost = rhetosHostBuilder.Build())
            {
                var registrationsDump = DumpSortedRegistrations(rhetosHost.GetRootContainer());
                System.Diagnostics.Trace.WriteLine(registrationsDump);
                TestUtility.AssertAreEqualByLine(_expectedRegistrationsDbUpdate, registrationsDump);

                TestAmbiguousRegistations(rhetosHost.GetRootContainer(),
                                          expectedOverridenRegistrations: new Dictionary <Type, string> {
                    { typeof(IUserInfo), "NullUserInfo" }
                });
            }
        }
        public void CorrectRegistrationsRuntimeWithInitialization()
        {
            // we construct the object, but need only its 'almost' static .AddAppInitilizationComponents
            var deployment        = new ApplicationDeploymentAccessor();
            var rhetosHostBuilder = new RhetosHostTestBuilder()
                                    .ConfigureConfiguration(RhetosHostTestBuilder.GetRuntimeConfiguration)
                                    .ConfigureContainer(deployment.AddAppInitializationComponents);

            using (var rhetosHost = rhetosHostBuilder.Build())
            {
                var registrationsDump = DumpSortedRegistrations(rhetosHost.GetRootContainer());
                System.Diagnostics.Trace.WriteLine(registrationsDump);
                TestUtility.AssertAreEqualByLine(_expectedRegistrationsRuntimeWithInitialization, registrationsDump);

                TestAmbiguousRegistations(rhetosHost.GetRootContainer(),
                                          expectedMultiplePlugins: new[] { "Rhetos.Dsl.IDslModelIndex" },
                                          expectedOverridenRegistrations: new Dictionary <Type, string> {
                    { typeof(IUserInfo), "ProcessUserInfo" },
                    { typeof(ILogProvider), "NLogProvider" }
                });
            }
        }