public static ValidationTestFactory InitialiseValidation()
        {
            IServiceProvider    serviceProvider;
            ServiceCollection   services;
            ValidationSubsystem validationSubsystem;

            services = new ServiceCollection();

            services.AddLogging();

            // Initialise validation to the point where data access is possible using the in-memory repository
            services.AddValidationSubsystem();
            services.AddValidationInMemoryRepositories();

            serviceProvider     = services.BuildServiceProvider();
            validationSubsystem = ValidationSubsystem.Initialise(serviceProvider);

            return(new ValidationTestFactory(serviceProvider, validationSubsystem));
        }
        public void TryCompleteInitialisation_InMemoryRepositories_InitialisesCorrectly()
        {
            // Arrange
            IServiceCollection services;
            IServiceProvider   serviceProvider;
            bool expected = true;
            bool actual;

            services = new ServiceCollection();
            services.AddLogging();
            services.AddValidationSubsystem();
            services.AddValidationInMemoryRepositories();
            serviceProvider = services.BuildServiceProvider();

            // Act
            var subsystem = ValidationSubsystem.StartInitialisation(serviceProvider);

            actual = subsystem.TryCompleteInitialisation(TimeSpan.FromSeconds(2));

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void TryCompleteInitialisation_FakeBlockingRepositories_InitialisationTimesOut()
        {
            // Arrange
            IServiceCollection services;
            IServiceProvider   serviceProvider;
            bool expected = false;
            bool actual;

            services = new ServiceCollection();
            services.AddLogging();
            services.AddValidationSubsystem();
            services.AddTransient <ICharacterSetRepository, Fakes.FakeBlockingCharacterSetRepository>();
            services.AddTransient <IDisallowedFragmentRepository, Fakes.FakeBlockingDisallowedFragmentRepository>();
            serviceProvider = services.BuildServiceProvider();

            // Act
            var subsystem = ValidationSubsystem.StartInitialisation(serviceProvider);

            actual = subsystem.TryCompleteInitialisation(TimeSpan.FromSeconds(2));

            // Assert
            Assert.AreEqual(expected, actual);
        }
 private ValidationTestFactory(IServiceProvider serviceProvider, ValidationSubsystem validationSubsystem)
 {
     _serviceProvider     = serviceProvider;
     _validationSubsystem = validationSubsystem;
 }