Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinRansom authored and colombod committed Aug 4, 2021
1 parent f4c45fa commit 8563548
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public PackageReference GetOrAddPackageReference(

PackageReference AppendPathSeparator(PackageReference resolved)
{
if (resolved == null)
if (resolved is null)
{
var newPackageRef = new PackageReference(packageName, packageVersion);
_requestedPackageReferences.TryAdd(key, newPackageRef);
Expand Down
114 changes: 35 additions & 79 deletions src/Microsoft.DotNet.Interactive.Tests/LanguageKernelPackageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -685,12 +685,13 @@ await kernel.SubmitCodeAsync(@"

await kernel.SubmitCodeAsync(code);

events
.OfType<ErrorProduced>()
.Last()
.Value
.Should()
.Be("Microsoft.ML.AutoML version 0.16.1-preview cannot be added because version 0.16.0-preview was added previously.");
events.Should()
.ContainSingle<CommandFailed>()
.Which
.Message
.Should()
.Be("Microsoft.ML.AutoML version 0.16.1-preview cannot be added because version 0.16.0-preview was added previously.");

}

[Theory]
Expand All @@ -717,12 +718,12 @@ await kernel.SubmitCodeAsync(

await kernel.SubmitCodeAsync(code);

events
.OfType<ErrorProduced>()
.Last()
.Value
.Should()
.Be("Microsoft.ML.AutoML version 0.16.1-preview cannot be added because version 0.16.0-preview was added previously.");
events.Should()
.ContainSingle<CommandFailed>()
.Which
.Message
.Should()
.Be("Microsoft.ML.AutoML version 0.16.1-preview cannot be added because version 0.16.0-preview was added previously.");
}

[Theory]
Expand Down Expand Up @@ -794,12 +795,12 @@ await kernel.SubmitCodeAsync(@"
#r ""nuget: Google.Protobuf, 3.10.1""
");

events
.OfType<ErrorProduced>()
.Last()
.Value
.Should()
.Be("Google.Protobuf version 3.10.1 cannot be added because version 3.10.0 was added previously.");
events.Should()
.ContainSingle<CommandFailed>()
.Which
.Message
.Should()
.Be("Google.Protobuf version 3.10.1 cannot be added because version 3.10.0 was added previously.");
}

[Theory]
Expand Down Expand Up @@ -1077,9 +1078,9 @@ public async Task Pound_r_nuget_works_immediately_after_a_language_selector(Lang

var command = new SubmitCode(code);

var result = await kernel.SendAsync(command);
using var events = kernel.KernelEvents.ToSubscribedList();

using var events = result.KernelEvents.ToSubscribedList();
var result = await kernel.SendAsync(command);

using var _ = new AssertionScope();

Expand Down Expand Up @@ -1110,8 +1111,9 @@ public async Task Pound_r_nuget_should_display_only_requested_packages_for_first
";

var command = new SubmitCode(code);

using var events = kernel.KernelEvents.ToSubscribedList();
var result = await kernel.SendAsync(command);
using var events = result.KernelEvents.ToSubscribedList();

using var _ = new AssertionScope();

Expand All @@ -1120,30 +1122,13 @@ public async Task Pound_r_nuget_should_display_only_requested_packages_for_first
"Microsoft.ML.OnnxTransformer, 1.4.0"
};

var notExpectedDisplayed = new[]
{
"google.protobuf, 3.5.1",
"microsoft.ml.kmeansclustering",
"microsoft.ml.pca",
"microsoft.ml.standardtrainers",
"microsoft.ml.transforms",
"microsoft.ml.cpumath",
"microsoft.ml.dataview",
"microsoft.ml.onnxruntime",
"newtonsoft.json",
"system.codedom"
};

events.OfType<DisplayedValueUpdated>()
.Where(v => v.Value is InstallPackagesMessage)
.Last().Value
.As<InstallPackagesMessage>()
.InstalledPackages
.Aggregate((s, acc) => acc + " & " + s)
.Should()
.ContainAll(expectedDisplayed)
.And
.NotContainAny(notExpectedDisplayed);
.BeEquivalentTo(expectedDisplayed);
}

[Theory]
Expand All @@ -1163,40 +1148,24 @@ public async Task Pound_r_nuget_should_display_only_requested_packages_for_subse
#r ""nuget:Google.Protobuf, 3.5.1""
";
var command2 = new SubmitCode(codeSecondSubmission);

using var events = kernel.KernelEvents.ToSubscribedList();
var result2 = await kernel.SendAsync(command2);

using var events = result2.KernelEvents.ToSubscribedList();
using var _ = new AssertionScope();

var expectedDisplayed = new[]
var expected = new[]
{
"google.protobuf, 3.5.1"
};

var notExpectedDisplayed = new[]
{
"microsoft.ml.onnxtransformer, 1.4.0",
"microsoft.ml.kmeansclustering",
"microsoft.ml.pca",
"microsoft.ml.standardtrainers",
"microsoft.ml.transforms",
"microsoft.ml.cpumath",
"microsoft.ml.dataview",
"microsoft.ml.onnxruntime",
"newtonsoft.json",
"system.codedom"
};

events.OfType<DisplayedValueUpdated>()
.Where(v => v.Value is InstallPackagesMessage)
.Last().Value
.As<InstallPackagesMessage>()
.InstalledPackages
.Aggregate((s, acc) => acc + " & " + s)
.Should()
.ContainAll(expectedDisplayed)
.And
.NotContainAny(notExpectedDisplayed);
.BeEquivalentTo(expected);
}

[Theory]
Expand All @@ -1223,9 +1192,10 @@ public async Task Pound_r_nuget_should_display_only_requested_packages_for_third
#r ""nuget:Microsoft.ML.OnnxTransformer, 1.4.0""
";
var command3 = new SubmitCode(codeThirdSubmission);

using var events = kernel.KernelEvents.ToSubscribedList();
var result3 = await kernel.SendAsync(command3);

using var events = result3.KernelEvents.ToSubscribedList();
using var _ = new AssertionScope();

var expectedDisplayed = new[]
Expand All @@ -1234,29 +1204,13 @@ public async Task Pound_r_nuget_should_display_only_requested_packages_for_third
"Microsoft.ML.OnnxTransformer, 1.4.0"
};

var notExpectedDisplayed = new[]
{
"microsoft.ml.kmeansclustering",
"microsoft.ml.pca",
"microsoft.ml.standardtrainers",
"microsoft.ml.transforms",
"microsoft.ml.cpumath",
"microsoft.ml.dataview",
"microsoft.ml.onnxruntime",
"newtonsoft.json",
"system.codedom"
};

events.OfType<DisplayedValueUpdated>()
.Where(v => v.Value is InstallPackagesMessage)
.Last().Value
.As<InstallPackagesMessage>()
.InstalledPackages
.Aggregate((s, acc) => acc + " & " + s)
.Should()
.ContainAll(expectedDisplayed)
.And
.NotContainAny(notExpectedDisplayed);
.BeEquivalentTo(expectedDisplayed);
}

[Theory]
Expand All @@ -1276,9 +1230,10 @@ public async Task Pound_r_nuget_should_error_when_trying_to_specify_a_different_
#r ""nuget:Google.Protobuf, 3.5.0""
";
var command2 = new SubmitCode(codeSecondSubmission);

using var events = kernel.KernelEvents.ToSubscribedList();
var result2 = await kernel.SendAsync(command2);

using var events = result2.KernelEvents.ToSubscribedList();
using var _ = new AssertionScope();

events
Expand All @@ -1301,9 +1256,10 @@ public async Task Pound_r_nuget_should_error_when_trying_to_specify_a_different_
#r ""nuget:Google.Protobuf, 3.5.1""
";
var command = new SubmitCode(codeFirstSubmission);

using var events = kernel.KernelEvents.ToSubscribedList();
var result = await kernel.SendAsync(command);

using var events = result.KernelEvents.ToSubscribedList();
using var _ = new AssertionScope();

events
Expand Down

0 comments on commit 8563548

Please sign in to comment.