/* * .NET tools :: Gallio Runner * Copyright (C) 2010 Jose Chillan, Alexandre Victoor and SonarSource * dev@sonar.codehaus.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 */ package org.sonar.dotnet.tools.gallio; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.File; import org.junit.BeforeClass; import org.junit.Test; import org.sonar.dotnet.tools.commons.visualstudio.VisualStudioProject; import org.sonar.dotnet.tools.commons.visualstudio.VisualStudioSolution; import org.sonar.test.TestUtils; import com.google.common.collect.Lists; public class GallioRunnerTest { private static GallioRunner runner; private static String fakeExecInstallPath; private static String workDir; private static VisualStudioSolution solution; @BeforeClass public static void initData() { VisualStudioProject vsProject1 = mock(VisualStudioProject.class); when(vsProject1.getArtifact("Debug")).thenReturn(TestUtils.getResource("/Runner/FakeAssemblies/Fake1.assembly")); VisualStudioProject vsProject2 = mock(VisualStudioProject.class); when(vsProject2.getArtifact("Debug")).thenReturn(TestUtils.getResource("/Runner/FakeAssemblies/Fake2.assembly")); solution = mock(VisualStudioSolution.class); when(solution.getTestProjects()).thenReturn(Lists.newArrayList(vsProject1, vsProject2)); fakeExecInstallPath = TestUtils.getResource("/Runner/FakeProg/Gallio").getAbsolutePath(); workDir = TestUtils.getResource("/Runner").getAbsolutePath(); runner = GallioRunner.create(fakeExecInstallPath, workDir, false); } @Test public void testCreateCommandBuilderForSolution() throws Exception { GallioCommandBuilder builder = runner.createCommandBuilder(solution); builder.setReportFile(new File("target/sonar/gallio-report-folder/gallio-report.xml")); assertThat(builder.toCommand().getExecutable(), is(new File(fakeExecInstallPath, "bin/Gallio.Echo.exe").getAbsolutePath())); } }