content: package net.amygdalum.testrecorder.scenarios;
  
  import static net.amygdalum.testrecorder.test.JUnit4TestsRun.testsRun;
  import static org.assertj.core.api.Assertions.assertThat;
  
  import org.junit.jupiter.api.Test;
  import org.junit.jupiter.api.extension.ExtendWith;
  
  import net.amygdalum.testrecorder.generator.TestGenerator;
  import net.amygdalum.testrecorder.integration.Instrumented;
  import net.amygdalum.testrecorder.integration.TestRecorderAgentExtension;
  
  @ExtendWith(TestRecorderAgentExtension.class)
  @Instrumented(classes = { "net.amygdalum.testrecorder.scenarios.SideEffects" })
  public class SideEffectsTest {
  
  	@Test
  	public void testSideEffectsOnThis() throws Exception {
  		SideEffects sideEffects = new SideEffects();
  		for (int i = 0; i < 100; i += sideEffects.getI()) {
  			sideEffects.methodWithSideEffectOnThis(i);
  		}
  
  		TestGenerator testGenerator = TestGenerator.fromRecorded();
  		assertThat(testGenerator.testsFor(SideEffects.class)).hasSize(7);
  		assertThat(testGenerator.testsFor(SideEffects.class)).allSatisfy(test -> assertThat(test).contains("assert"));
  	}
  
  	@Test
  	public void testSideEffectsOnArgument() throws Exception {
  		int[] array = new int[] { 0 };
  		SideEffects sideEffects = new SideEffects();
  		for (int i = 0; i < 10; i++) {
  			sideEffects.methodWithSideEffectOnArgument(array);
  		}
  
  		TestGenerator testGenerator = TestGenerator.fromRecorded();
  		assertThat(testGenerator.testsFor(SideEffects.class)).hasSize(10);
  		assertThat(testGenerator.testsFor(SideEffects.class)).allSatisfy(test -> assertThat(test).contains("assert"));
  	}
  
  	@Test
  	public void testSideEffectsCompilable() throws Exception {
  		int[] array = new int[] { 0 };
  		SideEffects sideEffects = new SideEffects();
  		for (int i = 0; i < 100; i += sideEffects.getI()) {
  			sideEffects.methodWithSideEffectOnThis(i);
  		}
  		for (int i = 0; i < 10; i++) {
  			sideEffects.methodWithSideEffectOnArgument(array);
  		}
  
  		TestGenerator testGenerator = TestGenerator.fromRecorded();
  		assertThat(testGenerator.renderTest(SideEffects.class)).satisfies(testsRun());
  	}
  
  }