+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
package jetbrains.buildServer.nuget.server.exec;\r
\r
import org.jetbrains.annotations.NotNull;\r
* Date: 14.07.11 13:23\r
*/\r
public interface NuGetExecutor {\r
+ @NotNull\r
<T> T executeNuGet(@NotNull List<String> arguments,\r
@NotNull NuGetOutputProcessor<T> listener);\r
}\r
--- /dev/null
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.tests.server;\r
+\r
+import jetbrains.buildServer.BaseTestCase;\r
+import jetbrains.buildServer.nuget.server.exec.*;\r
+import org.jmock.Expectations;\r
+import org.jmock.Mockery;\r
+import org.testng.annotations.BeforeMethod;\r
+import org.testng.annotations.Test;\r
+\r
+import java.util.*;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 14.07.11 13:27\r
+ */\r
+public class ListPackagesCommandTest extends BaseTestCase {\r
+ private Mockery m;\r
+ private NuGetExecutor exec;\r
+ private ListPackagesCommand cmd;\r
+\r
+\r
+ @BeforeMethod\r
+ @Override\r
+ protected void setUp() throws Exception {\r
+ super.setUp();\r
+ m = new Mockery();\r
+ exec = m.mock(NuGetExecutor.class);\r
+ cmd = new ListPackagesCommand(exec);\r
+ }\r
+\r
+ private void allowCommandLineCall(final String... cmd) {\r
+ final List<String> list = new ArrayList<String>(Arrays.<String>asList(cmd));\r
+ m.checking(new Expectations(){{\r
+ oneOf(exec).executeNuGet(with(equal(list)), with(any(ListPackagesCommandProcessor.class)));\r
+ will(returnValue(Collections.<PackageInfo>emptyList()));\r
+ }});\r
+ }\r
+\r
+ @Test\r
+ public void test_run_no_version() {\r
+ allowCommandLineCall(\r
+ "TeamCity.List",\r
+ "-Source",\r
+ "source",\r
+ "-Id",\r
+ "package"\r
+ );\r
+\r
+ Collection<PackageInfo> infos = cmd.checkForChanges("source", "package", null);\r
+\r
+\r
+ m.assertIsSatisfied();\r
+ }\r
+\r
+ @Test\r
+ public void test_run_version() {\r
+ allowCommandLineCall(\r
+ "TeamCity.List",\r
+ "-Source",\r
+ "source",\r
+ "-Id",\r
+ "package",\r
+ "-Version",\r
+ "version"\r
+ );\r
+\r
+ Collection<PackageInfo> infos = cmd.checkForChanges("source", "package", "version");\r
+\r
+ m.assertIsSatisfied();\r
+ }\r
+}\r