This commit is contained in:
Andrey Shchekin 2017-07-23 11:05:32 +12:00
Родитель 45bccb23cf
Коммит f0a6b04bca
2 изменённых файлов: 22 добавлений и 6 удалений

Просмотреть файл

@ -11,6 +11,7 @@ using MirrorSharp.Testing;
using Newtonsoft.Json.Linq;
using Pedantic.IO;
using SharpLab.Server;
using SharpLab.Tests.Internal;
using Xunit;
using Xunit.Abstractions;
@ -27,12 +28,15 @@ namespace SharpLab.Tests {
// Tuples, https://github.com/ashmind/SharpLab/issues/139
[InlineData("class C { void M((int, string) t) {} }")]
public async Task SlowUpdate_DecompilesSimpleCodeWithoutErrors(string code) {
var driver = MirrorSharpTestDriver.New().SetText(code);
var driver = MirrorSharpTestDriver.New(MirrorSharpOptions).SetText(code);
await driver.SendSetOptionsAsync(LanguageNames.CSharp, LanguageNames.CSharp);
var result = await driver.SendSlowUpdateAsync<string>();
var errors = result.JoinErrors();
Assert.True(errors.IsNullOrEmpty(), errors);
Assert.NotNull(result.ExtensionResult);
Assert.NotEmpty(result.ExtensionResult);
}
[Theory]
@ -149,11 +153,7 @@ namespace SharpLab.Tests {
private static async Task<MirrorSharpTestDriver> NewTestDriverAsync(TestData data, OptimizationLevel optimizationLevel = OptimizationLevel.Release) {
var driver = MirrorSharpTestDriver.New(MirrorSharpOptions);
await driver.SendSetOptionsAsync(new Dictionary<string, string> {
{"language", data.SourceLanguageName},
{"optimize", optimizationLevel.ToString().ToLowerInvariant()},
{"x-target", data.TargetLanguageName}
});
await driver.SendSetOptionsAsync(data.SourceLanguageName, data.TargetLanguageName, optimizationLevel);
driver.SetText(data.Original);
return driver;
}

Просмотреть файл

@ -0,0 +1,16 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using MirrorSharp.Testing;
namespace SharpLab.Tests.Internal {
public static class MirrorSharpTestDriverExtensions {
public static Task SendSetOptionsAsync(this MirrorSharpTestDriver driver, string sourceLanguageName, string targetName, OptimizationLevel optimizationLevel = OptimizationLevel.Release) {
return driver.SendSetOptionsAsync(new Dictionary<string, string> {
{"language", sourceLanguageName},
{"optimize", optimizationLevel.ToString().ToLowerInvariant()},
{"x-target", targetName}
});
}
}
}