Skip to content

Commit

Permalink
(GH-4) adjust specs for new logging types
Browse files Browse the repository at this point in the history
  • Loading branch information
ferventcoder committed Dec 22, 2017
1 parent 8d57039 commit dfe2439
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 33 deletions.
7 changes: 6 additions & 1 deletion src/CommandLine/Common/Console.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,20 @@ public void Log(MessageLevel level, string message, params object[] args)
{
switch (level)
{
case MessageLevel.Verbose:
case MessageLevel.Info:
WriteLine(message, args);
break;
break;
case MessageLevel.Warning:
WriteWarning(message, args);
break;
case MessageLevel.Debug:
WriteColor(Out, ConsoleColor.Gray, message, args);
break;
case MessageLevel.Error:
case MessageLevel.Fatal:
WriteError(message, args);
break;
}
}

Expand Down
64 changes: 32 additions & 32 deletions test/CommandLine.Test/MirrorCommandTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void MirrorCommandMirrorsPackageIfArgumentIsNotPackageReferenceFile()
AssertSinglePackage(mirrorCommand, "Foo", "1.0");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 1 package(s).")
});
}
Expand All @@ -46,7 +46,7 @@ public void MirrorCommandUsesMirrorOperation()
Assert.Equal(RepositoryOperationNames.Mirror, mockRepo.LastOperation);
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 1 package(s).")
});
}
Expand Down Expand Up @@ -84,7 +84,7 @@ public void MirrorCommandMirrorsPackageSuccessfullyIfCacheRepositoryIsNotSet()
AssertSinglePackage(mirrorCommand, "Foo", "1.0");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 1 package(s).")
});
}
Expand All @@ -104,7 +104,7 @@ public void MirrorCommandResolvesSourceName()
AssertSinglePackage(mirrorCommand, "Foo", "1.0");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 1 package(s).")
});
}
Expand All @@ -131,7 +131,7 @@ public void MirrorCommandLogsWarningsForFailingRepositoriesIfNoSourcesAreSpecifi
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Warning, "Boom"),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 1 package(s).")
});
}
Expand Down Expand Up @@ -190,7 +190,7 @@ public void MirrorCommandUsesMultipleSourcesIfSpecified()
AssertSinglePackage(mirrorCommand, "Baz", "0.7");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Baz 0.7' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Baz 0.7' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 1 package(s).")
});
}
Expand All @@ -217,7 +217,7 @@ public void MirrorCommandUsesLocalCacheIfNoCacheIsFalse()
AssertSinglePackage(mirrorCommand, "Gamma", "1.0");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Gamma 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Gamma 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 1 package(s).")
});
localCache.Verify();
Expand All @@ -243,7 +243,7 @@ public void MirrorCommandDoesNotUseLocalCacheIfNoCacheIsTrue()
AssertSinglePackage(mirrorCommand, "Baz", "0.7");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Baz 0.7' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Baz 0.7' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 1 package(s).")
});
localCache.Verify(c => c.GetPackages(), Times.Never());
Expand All @@ -265,7 +265,7 @@ public void MirrorCommandMirrorsPrereleasePackageIfFlagIsSpecified()
AssertSinglePackage(mirrorCommand, "Baz", "0.8.1-alpha");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Baz 0.8.1-alpha' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Baz 0.8.1-alpha' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 1 package(s).")
});
}
Expand All @@ -291,8 +291,8 @@ public void MirrorCommandMirrorsMirroringConfigWithVersion()
AssertTwoPackages(mirrorCommand, "Foo", "1.0", "Baz", "0.4");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Baz 0.4' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Baz 0.4' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 2 package(s).")
});
}
Expand All @@ -318,8 +318,8 @@ public void MirrorCommandMirrorsPackagesConfigWithoutVersion()
AssertTwoPackages(mirrorCommand, "Foo", "1.0", "Baz", "0.7");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Baz 0.7' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Baz 0.7' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 2 package(s).")
});
}
Expand All @@ -343,9 +343,9 @@ public void MirrorCommandMirrorsDependenciesByDefaultWhenUsingConfigFile()
AssertTwoPackages(mirrorCommand, "ChildPackage", "3.0", "PackageWithDependencies", "2.0");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Attempting to resolve dependency 'ChildPackage (> 2.0 && < 5.0)'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'ChildPackage 3.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'PackageWithDependencies 2.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Attempting to resolve dependency 'ChildPackage (> 2.0 && < 5.0)'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'ChildPackage 3.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'PackageWithDependencies 2.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 2 package(s).")
});
}
Expand All @@ -372,8 +372,8 @@ public void MirrorCommandMirrorsPackagesConfigWithoutVersionPrerelease()
AssertTwoPackages(mirrorCommand, "Foo", "1.0", "Baz", "0.8.1-alpha");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'Baz 0.8.1-alpha' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Foo 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'Baz 0.8.1-alpha' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 2 package(s).")
});
}
Expand All @@ -395,9 +395,9 @@ public void MirrorCommandMirrorsDependenciesByDefault()
AssertTwoPackages(mirrorCommand, "ChildPackage", "3.0", "PackageWithDependencies", "2.0");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Attempting to resolve dependency 'ChildPackage (> 2.0 && < 5.0)'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'ChildPackage 3.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'PackageWithDependencies 2.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Attempting to resolve dependency 'ChildPackage (> 2.0 && < 5.0)'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'ChildPackage 3.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'PackageWithDependencies 2.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 2 package(s).")
});
}
Expand All @@ -421,12 +421,12 @@ public void MirrorCommandSupportsMultipleEntriesSamePackageAndDownloadsDependent
// Assert
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Attempting to resolve dependency 'ChildPackage (≥ 1.0 && < 2.0)'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'ChildPackage 1.4' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'PackageWithDependencies 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Attempting to resolve dependency 'ChildPackage (> 2.0 && < 5.0)'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'ChildPackage 3.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'PackageWithDependencies 2.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Attempting to resolve dependency 'ChildPackage (≥ 1.0 && < 2.0)'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'ChildPackage 1.4' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'PackageWithDependencies 1.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Attempting to resolve dependency 'ChildPackage (> 2.0 && < 5.0)'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'ChildPackage 3.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'PackageWithDependencies 2.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 4 package(s).")
});
}
Expand All @@ -449,8 +449,8 @@ public void MirrorCommandSkipsAlreadyInstalledDependents()
AssertTwoPackages(mirrorCommand, "ChildPackage", "3.0", "PackageWithDependencies", "2.0");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Attempting to resolve dependency 'ChildPackage (> 2.0 && < 5.0)'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'PackageWithDependencies 2.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Attempting to resolve dependency 'ChildPackage (> 2.0 && < 5.0)'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'PackageWithDependencies 2.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 1 package(s).")
});
}
Expand All @@ -473,7 +473,7 @@ public void MirrorCommandSkipDependentsWhenDependentsModeIsSkip()
AssertSinglePackage(mirrorCommand, "PackageWithDependencies", "2.0");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'PackageWithDependencies 2.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'PackageWithDependencies 2.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 1 package(s).")
});
}
Expand Down Expand Up @@ -512,8 +512,8 @@ public void MirrorCommandSucceedsWhenDependentsPresentInTargetAndDependentsModeI
AssertTwoPackages(mirrorCommand, "ChildPackage", "3.0", "PackageWithDependencies", "2.0");
AssertOutputEquals(mirrorCommand, new[]
{
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Attempting to resolve dependency 'ChildPackage (> 2.0 && < 5.0)'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Successfully mirrored 'PackageWithDependencies 2.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Attempting to resolve dependency 'ChildPackage (> 2.0 && < 5.0)'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Verbose, "Successfully mirrored 'PackageWithDependencies 2.0' to 'destinationurlpull'."),
new KeyValuePair<MessageLevel, string>(MessageLevel.Info, "Mirrored 1 package(s).")
});
}
Expand Down

0 comments on commit dfe2439

Please sign in to comment.