Beispiel #1
0
        public static IdContextFactoryBuilder Of(IdTypeConfigurationProvider configurationProvider, JobScheduler jobScheduler)
        {
            IdContextFactoryBuilder builder = new IdContextFactoryBuilder();

            builder._idTypeConfigurationProvider = configurationProvider;
            builder._jobScheduler = jobScheduler;
            return(builder);
        }
Beispiel #2
0
        public static IdContextFactoryBuilder Of(FileSystemAbstraction fileSystemAbstraction, JobScheduler jobScheduler)
        {
            IdContextFactoryBuilder builder = new IdContextFactoryBuilder();

            builder._fileSystemAbstraction = fileSystemAbstraction;
            builder._jobScheduler          = jobScheduler;
            return(builder);
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createContextWithFactoryWrapper()
        internal virtual void CreateContextWithFactoryWrapper()
        {
            System.Func <IdGeneratorFactory, IdGeneratorFactory> factoryWrapper = mock(typeof(System.Func));
            IdGeneratorFactory idGeneratorFactory = mock(typeof(IdGeneratorFactory));

            when(factoryWrapper(any())).thenReturn(idGeneratorFactory);

            IdContextFactory contextFactory = IdContextFactoryBuilder.Of(_fs, _jobScheduler).withFactoryWrapper(factoryWrapper).build();

            DatabaseIdContext idContext = contextFactory.CreateIdContext("database");

            assertSame(idGeneratorFactory, idContext.IdGeneratorFactory);
        }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createCommunityBufferedContextByDefault()
        internal virtual void CreateCommunityBufferedContextByDefault()
        {
            IdContextFactory  idContextFactory = IdContextFactoryBuilder.Of(_fs, _jobScheduler).build();
            DatabaseIdContext idContext        = idContextFactory.CreateIdContext("database");

            IdGeneratorFactory idGeneratorFactory = idContext.IdGeneratorFactory;

            assertThat(idContext.IdController, instanceOf(typeof(BufferedIdController)));
            assertThat(idGeneratorFactory, instanceOf(typeof(BufferingIdGeneratorFactory)));

            (( BufferingIdGeneratorFactory )idGeneratorFactory).initialize(() => mock(typeof(KernelTransactionsSnapshot)));
            idGeneratorFactory.Open(_testDirectory.file("a"), IdType.NODE, () => 0, 100).Dispose();
            idGeneratorFactory.Open(_testDirectory.file("b"), IdType.PROPERTY, () => 0, 100).Dispose();

            BufferingIdGeneratorFactory bufferedFactory = ( BufferingIdGeneratorFactory )idGeneratorFactory;

            assertThat(bufferedFactory.Get(IdType.NODE), instanceOf(typeof(IdGeneratorImpl)));
            assertThat(bufferedFactory.Get(IdType.PROPERTY), not(instanceOf(typeof(IdGeneratorImpl))));
        }
Beispiel #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createContextWithCustomIdGeneratorFactoryWhenProvided()
        internal virtual void CreateContextWithCustomIdGeneratorFactoryWhenProvided()
        {
            IdGeneratorFactory idGeneratorFactory = mock(typeof(IdGeneratorFactory));
            IdContextFactory   contextFactory     = IdContextFactoryBuilder.Of(_fs, _jobScheduler).withIdGenerationFactoryProvider(any => idGeneratorFactory).build();
            DatabaseIdContext  idContext          = contextFactory.CreateIdContext("database");

            IdGeneratorFactory bufferedGeneratorFactory = idContext.IdGeneratorFactory;

            assertThat(idContext.IdController, instanceOf(typeof(BufferedIdController)));
            assertThat(bufferedGeneratorFactory, instanceOf(typeof(BufferingIdGeneratorFactory)));

            (( BufferingIdGeneratorFactory )bufferedGeneratorFactory).initialize(() => mock(typeof(KernelTransactionsSnapshot)));
            File   file   = _testDirectory.file("a");
            IdType idType = IdType.NODE;

            System.Func <long> highIdSupplier = () => 0;
            int maxId = 100;

            idGeneratorFactory.Open(file, idType, highIdSupplier, maxId);

            verify(idGeneratorFactory).open(file, idType, highIdSupplier, maxId);
        }
Beispiel #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createContextWithProvidedReusabilityCheck()
        internal virtual void CreateContextWithProvidedReusabilityCheck()
        {
            IdReuseEligibility reuseEligibility         = mock(typeof(IdReuseEligibility));
            IdContextFactory   contextFactory           = IdContextFactoryBuilder.Of(_fs, _jobScheduler).withIdReuseEligibility(reuseEligibility).build();
            DatabaseIdContext  idContext                = contextFactory.CreateIdContext("database");
            IdGeneratorFactory bufferedGeneratorFactory = idContext.IdGeneratorFactory;

            assertThat(bufferedGeneratorFactory, instanceOf(typeof(BufferingIdGeneratorFactory)));
            BufferingIdGeneratorFactory bufferedFactory = ( BufferingIdGeneratorFactory )bufferedGeneratorFactory;

            KernelTransactionsSnapshot snapshot = mock(typeof(KernelTransactionsSnapshot));

            when(snapshot.AllClosed()).thenReturn(true);

            bufferedFactory.Initialize(() => snapshot);
            using (IdGenerator idGenerator = bufferedFactory.Open(_testDirectory.file("a"), IdType.PROPERTY, () => 100, 100))
            {
                idGenerator.FreeId(15);

                bufferedFactory.Maintenance();
                verify(reuseEligibility).isEligible(snapshot);
            }
        }
Beispiel #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void requireFileSystemWhenIdGeneratorFactoryNotProvided()
        internal virtual void RequireFileSystemWhenIdGeneratorFactoryNotProvided()
        {
            System.NullReferenceException exception = assertThrows(typeof(System.NullReferenceException), () => IdContextFactoryBuilder.Of(new CommunityIdTypeConfigurationProvider(), _jobScheduler).build());
            assertThat(exception.Message, containsString("File system is required"));
        }