这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
17f68bf
Take the default as current directory
akshita31 Aug 15, 2019
02453a3
Create the package registry inside the verify command and use the dir…
akshita31 Aug 15, 2019
9d2314b
Add code so that the workspace is built if the files have been added
akshita31 Aug 16, 2019
f73fa0e
add test fot the command line for verify
akshita31 Aug 16, 2019
a6a7521
modify test name
akshita31 Aug 16, 2019
0e1649d
Refactor: Use only the directory accessor
akshita31 Aug 16, 2019
1cbdcbc
Fix command line tests
akshita31 Aug 16, 2019
c397e21
use the up-to-date check in only the rebuildable package
akshita31 Aug 16, 2019
f1df348
remove test from package test
akshita31 Aug 16, 2019
e8b4374
add a test to check when file is added the workspace contains it
akshita31 Aug 16, 2019
3219266
Add test for case where one file is deleted and other is added
akshita31 Aug 17, 2019
33dc4b3
Use directoryInfo extensions to do the matching
akshita31 Aug 20, 2019
82045ea
Add directory accessor to startup options and packageRegistry.CreateF…
akshita31 Aug 20, 2019
efa4b17
Use the directory accessor in the verify command
akshita31 Aug 20, 2019
1bc1dab
Test is passing
akshita31 Aug 21, 2019
478ec5a
clean up
akshita31 Aug 21, 2019
6e29f75
Use the same directory argument
akshita31 Aug 21, 2019
4402ab8
Use only the directory accessor in the startup options
akshita31 Aug 21, 2019
85257c6
Rename to more informative names
akshita31 Aug 21, 2019
12641fe
Remove the DirectoryInfoExtensions
akshita31 Aug 21, 2019
b6cbc6a
Do not use trim end
akshita31 Aug 21, 2019
69d2ba5
Clean up not needed changes
akshita31 Aug 21, 2019
d3aa8d0
clean up
akshita31 Aug 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions MLS.Agent.Tests/ApiViaHttpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using WorkspaceServer.Tests.TestUtility;
using CodeManipulation = WorkspaceServer.Tests.CodeManipulation;
using SourceFile = Microsoft.DotNet.Try.Protocol.ClientApi.SourceFile;
using WorkspaceServer;

namespace MLS.Agent.Tests
{
Expand Down Expand Up @@ -995,7 +996,7 @@ public async Task Scaffolding_HTML_trydotnet_js_autoEnable_useWasmRunner_is_true
var (name, addSource) = await Create.NupkgWithBlazorEnabled("packageName");

var startupOptions = new StartupOptions(
dir: TestAssets.SampleConsole,
rootDirectory: new FileSystemDirectoryAccessor(TestAssets.SampleConsole),
addPackageSource: new WorkspaceServer.PackageSource(addSource.FullName),
package: name);

Expand Down Expand Up @@ -1027,7 +1028,7 @@ public async Task Is_able_to_serve_static_files()
using (var disposableDirectory = DisposableDirectory.Create())
{
System.IO.File.WriteAllText(Path.Combine(disposableDirectory.Directory.FullName, "a.js"), "alert('This is an alert from javascript');");
var options = new StartupOptions(dir: disposableDirectory.Directory);
var options = new StartupOptions(rootDirectory: new FileSystemDirectoryAccessor(disposableDirectory.Directory));

using (var agent = new AgentService(options: options))
{
Expand Down
19 changes: 14 additions & 5 deletions MLS.Agent.Tests/CommandLine/CommandLineParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
using System.IO;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.DotNet.Try.Markdown;
using Microsoft.Extensions.DependencyInjection;
using MLS.Agent.CommandLine;
using WorkspaceServer;
using WorkspaceServer.Tests.TestUtility;
using Xunit;
using Xunit.Abstractions;
using WorkspaceServer.Tests;

namespace MLS.Agent.Tests.CommandLine
{
Expand Down Expand Up @@ -96,7 +98,7 @@ public async Task Parse_root_directory_with_a_valid_path_succeeds()
{
var path = TestAssets.SampleConsole.FullName;
await _parser.InvokeAsync(new[] { path }, _console);
_startOptions.Dir.FullName.Should().Be(path);
_startOptions.RootDirectory.GetFullyQualifiedRoot().FullName.Should().Be(path + Path.DirectorySeparatorChar);
}

[Fact]
Expand Down Expand Up @@ -150,7 +152,7 @@ public async Task It_parses_the_package_version_option()
public async Task Parse_empty_command_line_has_current_directory_as_root_directory()
{
await _parser.InvokeAsync("", _console);
_startOptions.Dir.FullName.Should().Be(Directory.GetCurrentDirectory());
_startOptions.RootDirectory.GetFullyQualifiedRoot().FullName.Should().Be(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar);
}

[Fact]
Expand Down Expand Up @@ -340,7 +342,14 @@ public async Task Verify_argument_specifies_root_directory()
{
var directory = Path.GetDirectoryName(typeof(VerifyCommand).Assembly.Location);
await _parser.InvokeAsync($"verify {directory}", _console);
_verifyOptions.Dir.FullName.Should().Be(directory);
_verifyOptions.RootDirectory.GetFullyQualifiedRoot().FullName.Should().Be(directory + Path.DirectorySeparatorChar);
}

[Fact]
public async Task Verify_takes_current_directory_as_default_if_none_is_specified()
{
await _parser.InvokeAsync($"verify", _console);
_verifyOptions.RootDirectory.GetFullyQualifiedRoot().FullName.Should().Be(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar);
}

[Fact]
Expand All @@ -366,7 +375,7 @@ public async Task jupyter_parses_connection_file_path()

var binder = new ModelBinder<JupyterOptions>();

var options = (JupyterOptions) binder.CreateInstance(new BindingContext(result));
var options = (JupyterOptions)binder.CreateInstance(new BindingContext(result));

options
.ConnectionFile
Expand All @@ -386,7 +395,7 @@ public async Task jupyter_returns_error_if_connection_file_path_does_not_exits()
testConsole.Error.ToString().Should().Contain("File does not exist: not_exist.json");
}

[Fact(Skip ="Skipped until System.CommandLine allows subcommands to skip the arguments from the main command")]
[Fact(Skip = "Skipped until System.CommandLine allows subcommands to skip the arguments from the main command")]
public async Task jupyter_returns_error_if_connection_file_path_is_not_passed()
{
var testConsole = new TestConsole();
Expand Down
20 changes: 6 additions & 14 deletions MLS.Agent.Tests/CommandLine/DemoCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ public async Task Demo_project_passes_verification()
await DemoCommand.Do(new DemoOptions(output: outputDirectory), console);

var resultCode = await VerifyCommand.Do(
new VerifyOptions(dir: outputDirectory),
new VerifyOptions(new FileSystemDirectoryAccessor(outputDirectory)),
console,
() => new FileSystemDirectoryAccessor(outputDirectory),
new PackageRegistry(),
startupOptions: new StartupOptions(package: packageFile.FullName));

_output.WriteLine(console.Out.ToString());
Expand All @@ -63,10 +61,8 @@ public async Task Demo_sources_pass_verification()
await DemoCommand.Do(new DemoOptions(output: demoSourcesDir), console);

var resultCode = await VerifyCommand.Do(
new VerifyOptions(dir: demoSourcesDir),
new VerifyOptions(new FileSystemDirectoryAccessor(demoSourcesDir)),
console,
() => new FileSystemDirectoryAccessor(demoSourcesDir),
new PackageRegistry(),
new StartupOptions(package: packageFile.FullName));

_output.WriteLine(console.Out.ToString());
Expand Down Expand Up @@ -110,10 +106,8 @@ await DemoCommand.Do(
startServer: (options, context) => { });

var resultCode = await VerifyCommand.Do(
new VerifyOptions(dir: outputDirectory),
console,
() => new FileSystemDirectoryAccessor(outputDirectory),
new PackageRegistry());
new VerifyOptions(new FileSystemDirectoryAccessor(outputDirectory)),
console);

resultCode.Should().NotBe(0);
}
Expand All @@ -132,10 +126,8 @@ await DemoCommand.Do(
(options, context) => startupOptions = options);

await VerifyCommand.Do(
new VerifyOptions(dir: outputDirectory),
console,
() => new FileSystemDirectoryAccessor(outputDirectory),
new PackageRegistry());
new VerifyOptions(new FileSystemDirectoryAccessor(outputDirectory)),
console);

_output.WriteLine(console.Out.ToString());
_output.WriteLine(console.Error.ToString());
Expand Down
7 changes: 4 additions & 3 deletions MLS.Agent.Tests/CommandLine/StartupOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using MLS.Agent.CommandLine;
using WorkspaceServer;
using Xunit;

namespace MLS.Agent.Tests.CommandLine
Expand All @@ -16,23 +17,23 @@ public class StartupOptionsTests
[Fact]
public void When_Production_is_true_and_in_hosted_mode_then_EnvironmentName_is_production()
{
var options = new StartupOptions(production: true, dir: null);
var options = new StartupOptions(production: true, rootDirectory: null);

options.EnvironmentName.Should().Be(Environments.Production);
}

[Fact]
public void When_Production_is_true_and_not_in_hosted_mode_then_EnvironmentName_is_production()
{
var options = new StartupOptions(production: true, dir: new DirectoryInfo(Directory.GetCurrentDirectory()));
var options = new StartupOptions(production: true, rootDirectory: new FileSystemDirectoryAccessor(Directory.GetCurrentDirectory()));

options.EnvironmentName.Should().Be(Environments.Production);
}

[Fact]
public void When_not_in_hosted_mode_then_EnvironmentName_is_production()
{
var options = new StartupOptions(dir: new DirectoryInfo(Directory.GetCurrentDirectory()));
var options = new StartupOptions(rootDirectory: new FileSystemDirectoryAccessor(Directory.GetCurrentDirectory()));

options.EnvironmentName.Should().Be(Environments.Production);
}
Expand Down
Loading