-
Notifications
You must be signed in to change notification settings - Fork 644
/
AutomaticallyCuratePackageCommandFacts.cs
51 lines (44 loc) · 1.72 KB
/
AutomaticallyCuratePackageCommandFacts.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Linq;
using Moq;
using NuGet;
using Xunit;
namespace NuGetGallery.Commands
{
public class AutomaticallyCuratePackageCommandFacts
{
public class TestableAutomaticallyCuratePackageCommand : AutomaticallyCuratePackageCommand
{
public TestableAutomaticallyCuratePackageCommand()
: base(null)
{
StubCurators = new List<Mock<IAutomaticPackageCurator>>();
}
public List<Mock<IAutomaticPackageCurator>> StubCurators { get; private set; }
protected override IEnumerable<T> GetServices<T>()
{
if (typeof(T) == typeof(IAutomaticPackageCurator))
{
return StubCurators.Select(stub => (T)stub.Object);
}
throw new Exception("Tried to get unexpected servicves");
}
}
public class TheExecuteMethod
{
[Fact]
public void WillCuratePackageUsingAllPackageCurators()
{
var cmd = new TestableAutomaticallyCuratePackageCommand();
var firstStubCurator = new Mock<IAutomaticPackageCurator>();
var secondStubCurator = new Mock<IAutomaticPackageCurator>();
cmd.StubCurators.Add(firstStubCurator);
cmd.StubCurators.Add(secondStubCurator);
cmd.Execute(new Package(), new Mock<IPackage>().Object);
firstStubCurator.Verify(stub => stub.Curate(It.IsAny<Package>(), It.IsAny<IPackage>()));
secondStubCurator.Verify(stub => stub.Curate(It.IsAny<Package>(), It.IsAny<IPackage>()));
}
}
}
}