Skip to content

Commit

Permalink
Merge pull request #30 from ferventcoder/ticket/master/autouninstaller
Browse files Browse the repository at this point in the history
(GH-15)(GH-9) AutoInstaller Enhancements
  • Loading branch information
ferventcoder committed Jan 21, 2015
2 parents 97b8803 + ffc5e6e commit 5f2d410
Show file tree
Hide file tree
Showing 37 changed files with 807 additions and 139 deletions.
2 changes: 1 addition & 1 deletion .uppercut
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<!-- These are run two folders down from the top level folder, so figure out the relative path from there and add "..\..\" -->
<!-- In example, if from the top level directory, you have an item that is in lib\NCover\NCover.Console.exe you should add it here as ..\..\lib\NCover\NCover.Console.exe -->
<!-- To not use the tool, change to a location that doesn't exist -->
<property name="app.nunit.console" value="..${path.separator}..${path.separator}src${path.separator}packages${path.separator}NUnit.2.5.10.11092${path.separator}tools${path.separator}nunit-console.exe" overwrite="false" if="${platform::is-windows()}" />
<property name="app.nunit.console" value="..${path.separator}..${path.separator}src${path.separator}packages${path.separator}NUnit.Runners.2.6.4${path.separator}tools${path.separator}nunit-console.exe" overwrite="false" if="${platform::is-windows()}" />
<property name="app.nunit.console" value="nunit-console" overwrite="false" if="${platform::is-unix()}"/>
<property name="app.xunit.console" value="..${path.separator}..${path.separator}${folder.references}${path.separator}xUnit${path.separator}xunit.console.clr4.exe" overwrite="false" />
<property name="app.storevil.console" value="..${path.separator}..${path.separator}${folder.references}${path.separator}StorEvil${path.separator}StorEvil.exe" overwrite="false" />
Expand Down
4 changes: 4 additions & 0 deletions src/.nuget/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit.Runners" version="2.6.4" />
</packages>
5 changes: 5 additions & 0 deletions src/chocolatey.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "chocolatey.resources", "cho
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "chocolatey.tests.integration", "chocolatey.tests.integration\chocolatey.tests.integration.csproj", "{12ECAD4F-D463-4D72-A792-A4FCCFE9C456}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{7A36F8E0-B170-4A51-A788-F1246513808A}"
ProjectSection(SolutionItems) = preProject
.nuget\packages.config = .nuget\packages.config
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="Should, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Should.1.1.12.0\lib\Should.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@ public class CommandExecutorSpecs
{
public abstract class CommandExecutorSpecsBase : TinySpec
{
protected readonly IFileSystem fileSystem = new DotNetFileSystem();
protected CommandExecutor commandExecutor;

public override void Context()
{
commandExecutor = new CommandExecutor(fileSystem);

}
}

public class when_CommandExecutor_errors : CommandExecutorSpecsBase
{
private int result;
private string errorOutput;
private readonly IFileSystem file_system = new DotNetFileSystem();

public override void Context()
{
Expand All @@ -43,7 +47,7 @@ public override void Context()

public override void Because()
{
result = CommandExecutor.execute("cmd.exe", "/c bob123123", ApplicationParameters.DefaultWaitForExitInSeconds, file_system.get_current_directory(), null, (s, e) => { errorOutput += e.Data; }, updateProcessPath: false);
result = CommandExecutor.execute("cmd.exe", "/c bob123123", ApplicationParameters.DefaultWaitForExitInSeconds, fileSystem.get_current_directory(), null, (s, e) => { errorOutput += e.Data; }, updateProcessPath: false);
}

[Fact]
Expand Down Expand Up @@ -74,7 +78,7 @@ public override void Because()
{
try
{
CommandExecutor.execute("noprocess.exe", "/c bob123123", ApplicationParameters.DefaultWaitForExitInSeconds, null, (s, e) => { errorOutput += e.Data; });
commandExecutor.execute("noprocess.exe", "/c bob123123", ApplicationParameters.DefaultWaitForExitInSeconds, null, (s, e) => { errorOutput += e.Data; });
}
catch (Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/chocolatey.tests.integration/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<packages>
<package id="Moq" version="4.2.1402.2112" targetFramework="net40" />
<package id="NUnit" version="2.5.10.11092" />
<package id="NUnit" version="2.6.4" targetFramework="net40" />
<package id="Rx-Core" version="2.1.30214.0" targetFramework="net40" />
<package id="Rx-Interfaces" version="2.1.30214.0" targetFramework="net40" />
<package id="Rx-Linq" version="2.1.30214.0" targetFramework="net40" />
Expand Down
24 changes: 14 additions & 10 deletions src/chocolatey.tests/MockLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public enum LogLevel

public class MockLogger : Mock<ILog>, ILog, ILog<MockLogger>
{
public MockLogger()
{
}

private readonly Lazy<ConcurrentDictionary<string, IList<string>>> _messages = new Lazy<ConcurrentDictionary<string, IList<string>>>();

public ConcurrentDictionary<string, IList<string>> Messages
Expand All @@ -57,61 +61,61 @@ public void LogMessage(LogLevel logLevel, string message)
public void Debug(string message, params object[] formatting)
{
LogMessage(LogLevel.Debug, message.format_with(formatting));
Object.Debug(message, formatting);
Object.Debug(message.format_with(formatting));
}

public void Debug(Func<string> message)
{
LogMessage(LogLevel.Debug, message());
Object.Debug(message);
Object.Debug(message());
}

public void Info(string message, params object[] formatting)
{
LogMessage(LogLevel.Info, message.format_with(formatting));
Object.Info(message, formatting);
Object.Info(message.format_with(formatting));
}

public void Info(Func<string> message)
{
LogMessage(LogLevel.Info, message());
Object.Info(message);
Object.Info(message());
}

public void Warn(string message, params object[] formatting)
{
LogMessage(LogLevel.Warn, message.format_with(formatting));
Object.Warn(message, formatting);
Object.Warn(message.format_with(formatting));
}

public void Warn(Func<string> message)
{
LogMessage(LogLevel.Warn, message());
Object.Warn(message);
Object.Warn(message());
}

public void Error(string message, params object[] formatting)
{
LogMessage(LogLevel.Error, message.format_with(formatting));
Object.Error(message, formatting);
Object.Error(message.format_with(formatting));
}

public void Error(Func<string> message)
{
LogMessage(LogLevel.Error, message());
Object.Error(message);
Object.Error(message());
}

public void Fatal(string message, params object[] formatting)
{
LogMessage(LogLevel.Fatal, message.format_with(formatting));
Object.Fatal(message, formatting);
Object.Fatal(message.format_with(formatting));
}

public void Fatal(Func<string> message)
{
LogMessage(LogLevel.Fatal, message());
Object.Fatal(message);
Object.Fatal(message());
}
}
}
15 changes: 11 additions & 4 deletions src/chocolatey.tests/TinySpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ namespace chocolatey.tests
[TestFixture]
public abstract class TinySpec
{
public MockLogger MockLogger { get; set; }
private MockLogger _mockLogger;

public MockLogger MockLogger
{
get { return _mockLogger; }
}

[TestFixtureSetUp]
public void Setup()
{
MockLogger = new MockLogger();
Log.InitializeWith(MockLogger);
_mockLogger = new MockLogger();
Log.InitializeWith(_mockLogger);
Context();
Because();
}
Expand Down Expand Up @@ -65,8 +70,10 @@ public virtual void AfterEachSpec()
[TestFixtureTearDown]
public void TearDown()
{

AfterObservations();
MockLogger = new MockLogger();
_mockLogger = null;
Log.InitializeWith(new NullLog());
}

public virtual void AfterObservations()
Expand Down
12 changes: 10 additions & 2 deletions src/chocolatey.tests/chocolatey.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Web.XmlTransform, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll</HintPath>
</Reference>
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
<Reference Include="NuGet.Core, Version=2.8.50506.491, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.Core.2.8.2\lib\net40-Client\NuGet.Core.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="Should, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Should.1.1.12.0\lib\Should.dll</HintPath>
Expand All @@ -62,6 +69,7 @@
<Compile Include="infrastructure.app\commands\ChocolateyUnpackSelfCommandSpecs.cs" />
<Compile Include="infrastructure.app\commands\ChocolateyUpgradeCommandSpecs.cs" />
<Compile Include="infrastructure.app\configuration\ConfigurationOptionsSpec.cs" />
<Compile Include="infrastructure.app\services\AutomaticUninstallerServiceSpecs.cs" />
<Compile Include="infrastructure\commands\ExternalCommandArgsBuilderSpecs.cs" />
<Compile Include="infrastructure\commandline\InteractivePromptSpecs.cs" />
<Compile Include="infrastructure\commands\CommandExecutorSpecs.cs" />
Expand Down
Loading

0 comments on commit 5f2d410

Please sign in to comment.