static void EnsureFailure(Controller.EqFailureKey reason) { // Arrange var eqController = new Controller() { LHS = 1, RHS = 1, EqualityFailure = reason }; var neqController = new Controller() { LHS = 1, RHS = 2, EqualityFailure = reason }; var eqOne = new Controllable() { ID = 1, Controller = eqController }; var neqOne = new Controllable() { ID = 1, Controller = neqController }; var neqTwo = new Controllable() { ID = 2, Controller = neqController }; // Act var failAreEqual = FullCheck.ExpectEqual(eqOne, eqOne); var failAreNotEqual = FullCheck.ExpectNotEqual(neqOne, neqTwo); // Assert failAreEqual.Should().HaveValue(); if (reason != Controller.EqFailureKey.Hash) { failAreNotEqual.Should().HaveValue(); } }
[TestMethod] public void StructsAlternativeOperators() { // Arrange var lhs = new StructAlternateOperators() { ID = 1 }; var rhs = new StructAlternateOperators() { ID = 2 }; // Act StructAlternateOperators.Tracker.Reset(); var isLess = FullCheck.ExpectLessThan(lhs, rhs); var areEquiv = FullCheck.ExpectEquivalent(lhs, lhs); var isGreater = FullCheck.ExpectGreaterThan(rhs, lhs); // Assert isLess.Should().NotHaveValue(); areEquiv.Should().NotHaveValue(); isGreater.Should().NotHaveValue(); StructAlternateOperators.Tracker[CallKey.OpEQ].Should().Be(0); StructAlternateOperators.Tracker[CallKey.OpNEQ].Should().Be(0); StructAlternateOperators.Tracker[CallKey.OpLT].Should().Be(0); StructAlternateOperators.Tracker[CallKey.OpGT].Should().Be(0); StructAlternateOperators.Tracker[CallKey.OpLTE].Should().Be(0); StructAlternateOperators.Tracker[CallKey.OpGTE].Should().Be(0); StructAlternateOperators.Tracker[CallKey.StrongEQ].Should().Be(0); StructAlternateOperators.Tracker[CallKey.WeakEQ].Should().Be(0); StructAlternateOperators.Tracker[CallKey.Comparison].Should().Be(0); StructAlternateOperators.Tracker[CallKey.HashCode].Should().Be(0); }
[TestMethod] public void Incomparable() { // Arrange var lhs = new ClassIncomparable() { ID = 1 }; ClassIncomparable?nll = null; // Act ClassIncomparable.Tracker.Reset(); var isIncomp = FullCheck.ExpectIncomparable(lhs, lhs); var nullIncomp = FullCheck.ExpectIncomparable(nll, nll); // Assert isIncomp.Should().NotHaveValue(); nullIncomp.Should().NotHaveValue(); ClassIncomparable.Tracker[CallKey.OpEQ].Should().Be(0); ClassIncomparable.Tracker[CallKey.OpNEQ].Should().Be(0); ClassIncomparable.Tracker[CallKey.OpLT].Should().Be(4); ClassIncomparable.Tracker[CallKey.OpGT].Should().Be(4); ClassIncomparable.Tracker[CallKey.OpLTE].Should().Be(4); ClassIncomparable.Tracker[CallKey.OpGTE].Should().Be(4); ClassIncomparable.Tracker[CallKey.StrongEQ].Should().Be(0); ClassIncomparable.Tracker[CallKey.WeakEQ].Should().Be(0); ClassIncomparable.Tracker[CallKey.Comparison].Should().Be(0); ClassIncomparable.Tracker[CallKey.HashCode].Should().Be(0); }
[TestMethod] public void StructsAlternateOperators() { // Arrange var lhs = new StructAlternateOperators() { ID = 1 }; var rhs = new StructAlternateOperators() { ID = 2 }; // Act StructAlternateOperators.Tracker.Reset(); var areEqual = FullCheck.ExpectEqual(lhs, lhs); var areNotEqual = FullCheck.ExpectNotEqual(lhs, rhs); // Assert areEqual.Should().NotHaveValue(); areNotEqual.Should().NotHaveValue(); StructAlternateOperators.Tracker[CallKey.OpEQ].Should().Be(0); StructAlternateOperators.Tracker[CallKey.OpNEQ].Should().Be(0); StructAlternateOperators.Tracker[CallKey.OpLT].Should().Be(0); StructAlternateOperators.Tracker[CallKey.OpGT].Should().Be(0); StructAlternateOperators.Tracker[CallKey.OpLTE].Should().Be(0); StructAlternateOperators.Tracker[CallKey.OpGTE].Should().Be(0); StructAlternateOperators.Tracker[CallKey.StrongEQ].Should().Be(0); StructAlternateOperators.Tracker[CallKey.WeakEQ].Should().Be(0); StructAlternateOperators.Tracker[CallKey.Comparison].Should().Be(0); StructAlternateOperators.Tracker[CallKey.HashCode].Should().Be(0); }
[TestMethod] public void WeakEquality() { // Arrange var now = new DBValue(DateTime.Now); var nonDbValue = now.Datum; object?nll = null; // Act var areNotEqual = FullCheck.ExpectNotEqual(now, nonDbValue); var nullAreNotEqual = FullCheck.ExpectNotEqual(now, nll); // Assert areNotEqual.Should().NotHaveValue(); nullAreNotEqual.Should().NotHaveValue(); }
[TestMethod] public void WeakEquality() { // Arrange var mercury = new ElementString("Mercury (Hg)"); var nonElement = "Mercury (Hg)"; object?nll = null; // Act var areNotEqual = FullCheck.ExpectNotEqual <object>(mercury, nonElement); var nullAreNotEqual = FullCheck.ExpectNotEqual(mercury, nll); // Assert areNotEqual.Should().NotHaveValue(); nullAreNotEqual.Should().NotHaveValue(); }
[TestMethod] public void WeakEquality() { // Arrange var byteType = DBType.UInt8; var nonDbType = typeof(byte); object?nll = null; // Act var areNotEqual = FullCheck.ExpectNotEqual <object>(byteType, nonDbType); var nullAreNotEqual = FullCheck.ExpectNotEqual(byteType, nll); // Assert areNotEqual.Should().NotHaveValue(); nullAreNotEqual.Should().NotHaveValue(); }
[TestMethod] public void StrictTotalOrder() { // Arrange var dubnium = new ElementString("Dubnium (Db)"); var einsteinium = new ElementString("Einsteinium (Es)"); ElementString?nll = null; // Act var nonEquiv = FullCheck.ExpectLessThan(dubnium, einsteinium); var equiv = FullCheck.ExpectEquivalent(dubnium, dubnium); var nullNonEquiv = FullCheck.ExpectLessThan(nll, einsteinium); var nullEquiv = FullCheck.ExpectEquivalent(nll, nll); // Assert nonEquiv.Should().NotHaveValue(); equiv.Should().NotHaveValue(); nullNonEquiv.Should().NotHaveValue(); nullEquiv.Should().NotHaveValue(); }
[TestMethod] public void StrongEquality() { // Arrange var nickel = new ElementString("Nickel (Ni)"); var copper = new ElementString("Copper (Cu)"); ElementString?nll = null; // Act var areEqual = FullCheck.ExpectEqual(nickel, nickel); var areNotEqual = FullCheck.ExpectNotEqual(nickel, copper); var nullAreEqual = FullCheck.ExpectEqual(nll, nll); var nullAreNotEqual = FullCheck.ExpectNotEqual(copper, nll); // Assert areEqual.Should().NotHaveValue(); areNotEqual.Should().NotHaveValue(); nullAreEqual.Should().NotHaveValue(); nullAreNotEqual.Should().NotHaveValue(); }
[TestMethod] public void StrongEquality() { // Arrange var textType = DBType.Text; var longType = DBType.Int64; DBType?nullType = null; // Act var areEqual = FullCheck.ExpectEqual(textType, textType); var areNotEqual = FullCheck.ExpectNotEqual(textType, longType); var nullAreEqual = FullCheck.ExpectEqual(nullType, nullType); var nullAreNotEqual = FullCheck.ExpectNotEqual(longType, nullType); // Assert areEqual.Should().NotHaveValue(); areNotEqual.Should().NotHaveValue(); nullAreEqual.Should().NotHaveValue(); nullAreNotEqual.Should().NotHaveValue(); }
[TestMethod] public void ClassesInheritingInterfaces() { // Arrange var lhs = new ClassInheritedInterfaces() { ID = 1 }; var rhs = new ClassInheritedInterfaces() { ID = 2 }; ClassInheritedInterfaces?nll = null; // Act ClassInheritedInterfaces.Tracker.Reset(); ClassInterfaces.Tracker.Reset(); var isLess = FullCheck.ExpectLessThan(lhs, rhs); var isEquiv = FullCheck.ExpectEquivalent(lhs, lhs); var isGreater = FullCheck.ExpectGreaterThan(rhs, lhs); var nullIsLess = FullCheck.ExpectLessThan(nll, lhs); var nullIsEquiv = FullCheck.ExpectEquivalent(nll, nll); var nullIsGreater = FullCheck.ExpectGreaterThan(lhs, nll); // Assert isLess.Should().NotHaveValue(); isEquiv.Should().NotHaveValue(); isGreater.Should().NotHaveValue(); nullIsLess.Should().NotHaveValue(); nullIsEquiv.Should().NotHaveValue(); nullIsGreater.Should().NotHaveValue(); ClassInheritedInterfaces.Tracker[CallKey.OpEQ].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.OpNEQ].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.OpLT].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.OpGT].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.OpLTE].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.OpGTE].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.StrongEQ].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.WeakEQ].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.Comparison].Should().Be(8); ClassInterfaces.Tracker[CallKey.Comparison].Should().Be(8); ClassInheritedInterfaces.Tracker[CallKey.HashCode].Should().Be(0); }
[TestMethod] public void ClassesInheritingInterfaces() { // Arrange var lhs = new ClassInheritedInterfaces() { ID = 1 }; var rhs = new ClassInheritedInterfaces() { ID = 2 }; ClassInheritedInterfaces?nll = null; // Act ClassInheritedInterfaces.Tracker.Reset(); ClassInterfaces.Tracker.Reset(); var areEqual = FullCheck.ExpectEqual(lhs, lhs); var areNotEqual = FullCheck.ExpectNotEqual(lhs, rhs); var nullAreEqual = FullCheck.ExpectEqual(nll, nll); var nullAreNotEqualL = FullCheck.ExpectNotEqual(nll, lhs); var nullAreNotEqualR = FullCheck.ExpectNotEqual(lhs, nll); // Assert areEqual.Should().NotHaveValue(); areNotEqual.Should().NotHaveValue(); nullAreEqual.Should().NotHaveValue(); nullAreNotEqualL.Should().NotHaveValue(); nullAreNotEqualR.Should().NotHaveValue(); ClassInheritedInterfaces.Tracker[CallKey.OpEQ].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.OpNEQ].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.OpLT].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.OpGT].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.OpLTE].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.OpGTE].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.StrongEQ].Should().Be(6); ClassInterfaces.Tracker[CallKey.StrongEQ].Should().Be(6); ClassInheritedInterfaces.Tracker[CallKey.WeakEQ].Should().Be(6); ClassInheritedInterfaces.Tracker[CallKey.Comparison].Should().Be(0); ClassInheritedInterfaces.Tracker[CallKey.HashCode].Should().Be(2); }
static void EnsureFailure(Controller.CompFailureKey reason) { // Arrange var ltController = new Controller() { LHS = 1, RHS = 2, ComparisonFailure = reason }; var gtController = new Controller() { LHS = 2, RHS = 1, ComparisonFailure = reason }; var ltOne = new Controllable() { ID = 1, Controller = ltController }; var ltTwo = new Controllable() { ID = 2, Controller = ltController }; var gtOne = new Controllable() { ID = 1, Controller = gtController }; var gtTwo = new Controllable() { ID = 2, Controller = gtController }; // Act var failLess = FullCheck.ExpectLessThan(ltOne, ltTwo); var failGreater = FullCheck.ExpectGreaterThan(gtTwo, gtOne); // Assert failLess.Should().HaveValue(); failGreater.Should().HaveValue(); }
[TestMethod] public void StrongEquality() { // Arrange var zero = DBValue.Create(0); var hash = DBValue.Create('#'); var nullValue = DBValue.Create(null); DBValue?nll = null; // Act var areEqual1 = FullCheck.ExpectEqual(zero, zero); var areEqual2 = FullCheck.ExpectEqual(nullValue, nullValue); var areNotEqual1 = FullCheck.ExpectNotEqual(zero, hash); var areNotEqual2 = FullCheck.ExpectNotEqual(hash, nullValue); var nullAreEqual = FullCheck.ExpectEqual(nll, nll); var nullAreNotEqual = FullCheck.ExpectNotEqual(zero, nll); // Assert areEqual1.Should().NotHaveValue(); areEqual2.Should().NotHaveValue(); areNotEqual1.Should().NotHaveValue(); areNotEqual2.Should().NotHaveValue(); nullAreEqual.Should().NotHaveValue(); nullAreNotEqual.Should().NotHaveValue(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public Result runFullConsistencyCheck(org.neo4j.io.layout.DatabaseLayout databaseLayout, org.neo4j.kernel.configuration.Config config, org.neo4j.helpers.progress.ProgressMonitorFactory progressFactory, final org.neo4j.logging.LogProvider logProvider, final org.neo4j.io.fs.FileSystemAbstraction fileSystem, final org.neo4j.io.pagecache.PageCache pageCache, final boolean verbose, java.io.File reportDir, org.neo4j.consistency.checking.full.ConsistencyFlags consistencyFlags) throws org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException //JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: public virtual Result RunFullConsistencyCheck(DatabaseLayout databaseLayout, Config config, ProgressMonitorFactory progressFactory, LogProvider logProvider, FileSystemAbstraction fileSystem, PageCache pageCache, bool verbose, File reportDir, ConsistencyFlags consistencyFlags) { AssertRecovered(databaseLayout, config, fileSystem, pageCache); Log log = logProvider.getLog(this.GetType()); config.augment(GraphDatabaseSettings.read_only, TRUE); config.augment(GraphDatabaseSettings.pagecache_warmup_enabled, FALSE); StoreFactory factory = new StoreFactory(databaseLayout, config, new DefaultIdGeneratorFactory(fileSystem), pageCache, fileSystem, logProvider, EmptyVersionContextSupplier.EMPTY); ConsistencySummaryStatistics summary; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.io.File reportFile = chooseReportPath(reportDir); File reportFile = ChooseReportPath(reportDir); Suppliers.Lazy <PrintWriter> reportWriterSupplier = GetReportWriterSupplier(fileSystem, reportFile); Log reportLog = new ConsistencyReportLog(reportWriterSupplier); // Bootstrap kernel extensions Monitors monitors = new Monitors(); LifeSupport life = new LifeSupport(); JobScheduler jobScheduler = life.Add(JobSchedulerFactory.createInitialisedScheduler()); TokenHolders tokenHolders = new TokenHolders(new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_PROPERTY_KEY), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_LABEL), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_RELATIONSHIP_TYPE)); DatabaseKernelExtensions extensions = life.Add(instantiateKernelExtensions(databaseLayout.DatabaseDirectory(), fileSystem, config, new SimpleLogService(logProvider, logProvider), pageCache, jobScheduler, RecoveryCleanupWorkCollector.ignore(), TOOL, monitors, tokenHolders)); DefaultIndexProviderMap indexes = life.Add(new DefaultIndexProviderMap(extensions, config)); try { using (NeoStores neoStores = factory.OpenAllNeoStores()) { // Load tokens before starting extensions, etc. tokenHolders.PropertyKeyTokens().InitialTokens = neoStores.PropertyKeyTokenStore.Tokens; tokenHolders.LabelTokens().InitialTokens = neoStores.LabelTokenStore.Tokens; tokenHolders.RelationshipTypeTokens().InitialTokens = neoStores.RelationshipTypeTokenStore.Tokens; life.Start(); LabelScanStore labelScanStore = new NativeLabelScanStore(pageCache, databaseLayout, fileSystem, Org.Neo4j.Kernel.Impl.Api.scan.FullStoreChangeStream_Fields.Empty, true, monitors, RecoveryCleanupWorkCollector.ignore()); life.Add(labelScanStore); int numberOfThreads = DefaultConsistencyCheckThreadsNumber(); Statistics statistics; StoreAccess storeAccess; AccessStatistics stats = new AccessStatistics(); if (verbose) { statistics = new VerboseStatistics(stats, new DefaultCounts(numberOfThreads), log); storeAccess = new AccessStatsKeepingStoreAccess(neoStores, stats); } else { statistics = Statistics.NONE; storeAccess = new StoreAccess(neoStores); } storeAccess.Initialize(); DirectStoreAccess stores = new DirectStoreAccess(storeAccess, labelScanStore, indexes, tokenHolders); FullCheck check = new FullCheck(progressFactory, statistics, numberOfThreads, consistencyFlags, config, true); summary = check.Execute(stores, new DuplicatingLog(log, reportLog)); } } finally { life.Shutdown(); if (reportWriterSupplier.Initialised) { reportWriterSupplier.get().close(); } } if (!summary.Consistent) { log.Warn("See '%s' for a detailed consistency report.", reportFile.Path); return(Result.failure(reportFile)); } return(Result.success(reportFile)); }