Skip to content

Commit

Permalink
Merge pull request #61 from SubPointSolutions/dev
Browse files Browse the repository at this point in the history
MetaPack 0.1.0-beta5, March 2017
  • Loading branch information
SubPointSupport authored Mar 27, 2017
2 parents f383b06 + dd3bce1 commit cbe23fc
Show file tree
Hide file tree
Showing 30 changed files with 1,181 additions and 134 deletions.
26 changes: 13 additions & 13 deletions Build/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"customNuspecs": [
{
"Id": "MetaPack.Core",
"Version": "0.1.0-beta4",
"Version": "0.1.0-beta5",
"Dependencies": [ ],
"LicenseUrl": "http://docs.subpointsolutions.com/metapack/license",
"ProjectUrl": "https://github.com/SubPointSolutions/metapack",
Expand All @@ -44,11 +44,11 @@
},
{
"Id": "MetaPack.NuGet",
"Version": "0.1.0-beta4",
"Version": "0.1.0-beta5",
"Dependencies": [
{
"Id": "MetaPack.Core",
"Version": "0.1.0-beta4"
"Version": "0.1.0-beta5"
},
{
"Id": "NuGet.Core",
Expand Down Expand Up @@ -77,15 +77,15 @@
},
{
"Id": "MetaPack.SPMeta2",
"Version": "0.1.0-beta4",
"Version": "0.1.0-beta5",
"Dependencies": [
{
"Id": "MetaPack.Core",
"Version": "0.1.0-beta4"
"Version": "0.1.0-beta5"
},
{
"Id": "MetaPack.NuGet",
"Version": "0.1.0-beta4"
"Version": "0.1.0-beta5"
}
],
"LicenseUrl": "http://docs.subpointsolutions.com/metapack/license",
Expand All @@ -106,15 +106,15 @@
},
{
"Id": "MetaPack.SharePointPnP",
"Version": "0.1.0-beta4",
"Version": "0.1.0-beta5",
"Dependencies": [
{
"Id": "MetaPack.Core",
"Version": "0.1.0-beta4"
"Version": "0.1.0-beta5"
},
{
"Id": "MetaPack.NuGet",
"Version": "0.1.0-beta4"
"Version": "0.1.0-beta5"
}
],
"LicenseUrl": "http://docs.subpointsolutions.com/metapack/license",
Expand All @@ -135,15 +135,15 @@
},
{
"Id": "MetaPack.Client.Common",
"Version": "0.1.0-beta4",
"Version": "0.1.0-beta5",
"Dependencies": [
{
"Id": "MetaPack.Core",
"Version": "0.1.0-beta4"
"Version": "0.1.0-beta5"
},
{
"Id": "MetaPack.NuGet",
"Version": "0.1.0-beta4"
"Version": "0.1.0-beta5"
}
],
"LicenseUrl": "http://docs.subpointsolutions.com/metapack/license",
Expand All @@ -166,7 +166,7 @@
"customChocolateySpecs": [
{
"Id": "MetaPack",
"Version": "0.1.0-beta4",
"Version": "0.1.0-beta5",
"LicenseUrl": "http://docs.subpointsolutions.com/metapack/license",
"ProjectUrl": "https://github.com/SubPointSolutions/metapack",
"IconUrl": "https://raw.githubusercontent.com/SubPointSolutions/spmeta2/dev/SPMeta2/SPMeta2.Dependencies/Images/SPMeta2_64_64.png",
Expand Down
49 changes: 49 additions & 0 deletions MetaPack.Client.Common.Tests/Scenarios/CommandsSenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
using MetaPack.Tests.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NuGet;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System;
using System.Text;

namespace MetaPack.Client.Common.Tests.Scenarios
{
Expand All @@ -21,6 +26,7 @@ public class CommandsSenarioTests : DeploymentScenarioTests
[TestCategory("Metapack.Client.API.SP2013")]
public void Can_Call_List_Command_OnPremise()
{
var hasOnTraceEvents = false;
var webSiteUrl = EnvironmentUtils.GetEnvironmentVariable(RegConsts.SP2013.RootWebUrl);

var command = new NuGetListCommand
Expand All @@ -35,14 +41,24 @@ public void Can_Call_List_Command_OnPremise()
UserPassword = SP2013UserPassword,
};

command.OnTraceEvent += (s, e) =>
{
hasOnTraceEvents = true;
Trace.WriteLine(e.Message);
};

command.Execute();

Assert.IsTrue(command.Packages.Count() > 0);
Assert.IsTrue(hasOnTraceEvents);
}

[TestMethod]
[TestCategory("Metapack.Client.API")]
[TestCategory("Metapack.Client.API.O365")]
public void Can_Call_List_Command_O365()
{
var hasOnTraceEvents = false;
var webSiteUrl = EnvironmentUtils.GetEnvironmentVariable(RegConsts.O365.RootWebUrl);

var userName = EnvironmentUtils.GetEnvironmentVariable(RegConsts.O365.UserName);
Expand All @@ -58,7 +74,31 @@ public void Can_Call_List_Command_O365()
SharePointVersion = "o365"
};

command.OnTraceEvent += (s, e) =>
{
hasOnTraceEvents = true;
Trace.WriteLine(e.Message);
};

command.Execute();

Assert.IsTrue(command.Packages.Count() > 0);
Assert.IsTrue(hasOnTraceEvents);
}

public class TraceWriter : TextWriter
{
public override Encoding Encoding { get { return Encoding.UTF8; } }

public override void Write(string value)
{
WriteLine(value);
}

public override void WriteLine(string value)
{
Trace.WriteLine(value);
}
}


Expand All @@ -72,6 +112,8 @@ public void Can_Call_List_Command_O365()
//[TestCategory("CI.Core")]
public void Can_Call_Install_Command_O365()
{
var hasOnTraceEvents = false;

var expectedInstallHits = 0;
var actualInstallHits = 0;

Expand Down Expand Up @@ -111,6 +153,12 @@ public void Can_Call_Install_Command_O365()
PreRelease = true
};

command.OnTraceEvent += (s, e) =>
{
hasOnTraceEvents = true;
Trace.WriteLine(e.Message);
};

command.PackageSources.Add(repoUrl);

if (UseLocaNuGet)
Expand All @@ -124,6 +172,7 @@ public void Can_Call_Install_Command_O365()
});

Assert.AreEqual(expectedInstallHits, actualInstallHits);
Assert.IsTrue(hasOnTraceEvents);
}


Expand Down
60 changes: 56 additions & 4 deletions MetaPack.Client.Common/Commands/Base/CommandBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using MetaPack.Core;
using MetaPack.Core.Services;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -9,11 +11,19 @@ namespace MetaPack.Client.Common.Commands.Base
{
public abstract class CommandBase
{
#region static
static CommandBase()
{
DefaultOut = Console.Out;
}

#endregion

#region constructros

protected CommandBase()
{
Out = Console.Out;
Out = DefaultOut;

PackageSources = new List<string>();

Expand All @@ -24,6 +34,23 @@ protected CommandBase()

#endregion

#region static

public static TextWriter DefaultOut { get; set; }
protected virtual EventableTraceServiceBase EventableTraceService
{
get
{
return MetaPackServiceContainer.Instance
.GetService<TraceServiceBase>() as EventableTraceServiceBase;
}
}


public event EventHandler<TraceEventEventArgs> OnTraceEvent;

#endregion

#region properties

public bool PreRelease { get; set; }
Expand All @@ -43,7 +70,7 @@ protected CommandBase()
public string SharePointVersion { get; set; }
public string SharePointEdition { get; set; }

public TextWriter Out { get; private set; }
public TextWriter Out { get; set; }

#endregion

Expand All @@ -57,9 +84,34 @@ protected virtual bool IsSharePointOnline
}
}

public abstract object Execute();

protected virtual void WithEmitingTraceEvents(Action action)
{
try
{
if (EventableTraceService != null)
EventableTraceService.OnTraceEvent += CommandBase_OnTraceEvent;

public abstract object Execute();
action();
}
finally
{
if (EventableTraceService != null)
EventableTraceService.OnTraceEvent -= CommandBase_OnTraceEvent;
}
}

private void CommandBase_OnTraceEvent(object sender, TraceEventEventArgs e)
{
InvokeOnTraceEvent(sender, e);
}

private void InvokeOnTraceEvent(object sender, TraceEventEventArgs e)
{
if (OnTraceEvent != null)
OnTraceEvent(sender, e);
}

#endregion

Expand Down
8 changes: 6 additions & 2 deletions MetaPack.Client.Common/Commands/DefaultInstallCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public override string Name

#region methods
public override object Execute()
{
WithEmitingTraceEvents(InternalExecute);
return null;
}

protected virtual void InternalExecute()
{
if (PackageSources.Count == 0)
throw new ArgumentException("Source");
Expand Down Expand Up @@ -150,8 +156,6 @@ public override object Execute()
packageManager.InstallPackage(package, false, PreRelease);
MetaPackTrace.Info("Completed installation. All good!");
});

return null;
}

protected virtual MetaPackSolutionPackageManagerBase CreatePackageManager(IPackageRepository repo, ClientContext context)
Expand Down
9 changes: 7 additions & 2 deletions MetaPack.Client.Common/Commands/DefaultListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ public IEnumerable<IPackage> Packages

#region methods
public override object Execute()
{
WithEmitingTraceEvents(InternalExecute);

return null;
}

private void InternalExecute()
{
_packages.Clear();

Expand Down Expand Up @@ -92,8 +99,6 @@ public override object Execute()
Out.WriteLine(package.GetFullName());
}
});

return null;
}

#endregion
Expand Down
9 changes: 6 additions & 3 deletions MetaPack.Client.Common/Commands/DefaultNuGetPushCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public override string Name

#region methods
public override object Execute()
{
WithEmitingTraceEvents(InternalExecute);
return null;
}

private void InternalExecute()
{
if (string.IsNullOrEmpty(Source))
throw new ArgumentException("Source");
Expand All @@ -43,10 +49,7 @@ public override object Execute()

throw new NotImplementedException();

//var packagingService = new 2SolutionPackageService();
//packagingService.Push(Package, Source, ApiKey);

return null;
}

#endregion
Expand Down
Loading

0 comments on commit cbe23fc

Please sign in to comment.