Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void schemaCacheSnapshotsShouldBeReadOnly()
        public virtual void SchemaCacheSnapshotsShouldBeReadOnly()
        {
            // Given
            SchemaCache cache = NewSchemaCache();

            cache.AddSchemaRule(NewIndexRule(1L, 1, 2));
            cache.AddSchemaRule(NewIndexRule(2L, 2, 3));

            SchemaCache snapshot = cache.Snapshot();

            cache.AddSchemaRule(NewIndexRule(3L, 1, 2));

            // When
            ISet <CapableIndexDescriptor> indexes = asSet(snapshot.IndexDescriptorsForLabel(1));

            // Then
            ISet <StoreIndexDescriptor> expected = asSet(NewIndexRule(1L, 1, 2));

            assertEquals(expected, indexes);

            try
            {
                snapshot.AddSchemaRule(NewIndexRule(3L, 1, 2));
                fail("SchemaCache snapshots should not permit mutation.");
            }
            catch (System.InvalidOperationException)
            {
                // Good.
            }
        }