//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void healDatabaseWithoutCriticalErrors() public virtual void HealDatabaseWithoutCriticalErrors() { AssertableLogProvider logProvider = new AssertableLogProvider(); DatabaseHealth databaseHealth = new DatabaseHealth(mock(typeof(DatabasePanicEventGenerator)), logProvider.GetLog(typeof(DatabaseHealth))); assertTrue(databaseHealth.Healthy); databaseHealth.Panic(new IOException("Space exception.")); assertFalse(databaseHealth.Healthy); assertTrue(databaseHealth.Healed()); logProvider.RawMessageMatcher().assertContains("Database health set to OK"); logProvider.RawMessageMatcher().assertNotContains("Database encountered a critical error and can't be healed. Restart required."); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogDatabasePanicEvent() public virtual void ShouldLogDatabasePanicEvent() { // GIVEN AssertableLogProvider logProvider = new AssertableLogProvider(); DatabaseHealth databaseHealth = new DatabaseHealth(mock(typeof(DatabasePanicEventGenerator)), logProvider.GetLog(typeof(DatabaseHealth))); databaseHealth.Healed(); // WHEN string message = "Listen everybody... panic!"; Exception exception = new Exception(message); databaseHealth.Panic(exception); // THEN logProvider.AssertAtLeastOnce(inLog(typeof(DatabaseHealth)).error(@is("Database panic: The database has encountered a critical error, " + "and needs to be restarted. Please see database logs for more details."), sameInstance(exception))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGenerateDatabasePanicEvents() public virtual void ShouldGenerateDatabasePanicEvents() { // GIVEN DatabasePanicEventGenerator generator = mock(typeof(DatabasePanicEventGenerator)); DatabaseHealth databaseHealth = new DatabaseHealth(generator, NullLogProvider.Instance.getLog(typeof(DatabaseHealth))); databaseHealth.Healed(); // WHEN Exception cause = new Exception("My own fault"); databaseHealth.Panic(cause); databaseHealth.Panic(cause); // THEN verify(generator, times(1)).generateEvent(TX_MANAGER_NOT_OK, cause); }