### Question:
ShimGenerator implements IShimGenerator { public void generateSilence(double shimLength, String targetFile, int monoOrStereo) { try { int sampleRate = 44100; double duration = shimLength; long numFrames = (long) (duration * sampleRate); WavFile wavFile = WavFile.newWavFile(new File(targetFile), monoOrStereo, numFrames, 16, sampleRate); double[][] buffer = new double[2][100]; long frameCounter = 0; while (frameCounter < numFrames) { long remaining = wavFile.getFramesRemaining(); int toWrite = (remaining > 100) ? 100 : (int) remaining; for (int s = 0; s < toWrite; s++, frameCounter++) { buffer[0][s] = 0; buffer[1][s] = 0; } wavFile.writeFrames(buffer, toWrite); } wavFile.close(); } catch (Exception e) { Application.logger.debug("LOG:",e); } }  void generateSilence(double shimLength, String targetFile, int monoOrStereo);  }### Answer:
@Test public void ShouldCreateSampleOfCoorectLengthMono() { try { float shimLength = 23.53f; String shimPath = appConfigs.getMockDataDir() + "mockAudio\\shimTest.wav"; File file = new File(shimPath); if(file != null && file.exists()){ deleteFolderAndContents(file); } shimGenerator.generateSilence(shimLength, shimPath, 1); float audioLength; audioLength = audioUtils.getAudioLength(shimPath); file = new File(shimPath); if(file != null && file.exists()){ deleteFolderAndContents(file); } assertEquals(shimLength, audioLength, 0.01f); } catch (Exception e) { assertEquals(false, true); } }
@Test public void ShouldCreateSampleOfCoorectLengthStereo() { try { float shimLength = 23.53f; String shimPath = appConfigs.getMockDataDir() + "mockAudio\\shimTest.wav"; File file = new File(shimPath); if(file != null && file.exists()){ deleteFolderAndContents(file); } shimGenerator.generateSilence(shimLength, shimPath, 2); float audioLength; audioLength = audioUtils.getAudioLength(shimPath); file = new File(shimPath); if(file != null && file.exists()){ deleteFolderAndContents(file); } assertEquals(shimLength, audioLength, 0.01f); } catch (Exception e) { assertEquals(false, true); } }