public void TearDown() { _testApp = null; ApplicationEventsResolver.Reset(); SqlSyntaxProvidersResolver.Reset(); Resolution.IsFrozen = false; }
public override void TearDown() { base.TearDown(); _testApp = null; //ApplicationEventsResolver.Reset(); //SqlSyntaxProvidersResolver.Reset(); }
public void Can_handle_GET_routes_with_a_single_parameter() { using (var app = new TestApp()) { var context = new Mock<IQuickContext>().Object; app.FindRouteFor(SupportedHttpMethod.GET, "/hi/bob").Handle(context); Mock.Get(context).Verify(cxt => cxt.Write("Hello bob")); } }
public void Can_handle_GET_routes_with_a_single_parameter2() { using (var app = new TestApp()) { var context = new QuickContextSpy(); app.FindRouteFor(SupportedHttpMethod.GET, "/hi/bob").Handle(context); context.Response.ShouldEqual("Hello bob"); } }
public void WhenAnExceptionOccurs_TheLogErrorMethodIsCalled() { // Arrange var mockILog = Fixture.Freeze<Mock<ILog>>(); var sut = Fixture.Create<ExceptionHandler>(); var app = new TestApp(); // Act sut.SetupExceptionHandling(); Assert.Throws<NotImplementedException>(() => app.Run()); // Assert mockILog.Verify(x => x.Error(It.IsAny<string>()), Times.AtLeastOnce); }
private void StartDispatcher() { app = new TestApp { ShutdownMode = ShutdownMode.OnExplicitShutdown }; app.Exit += (sender, args) => { var message = $"Exit TestApp with Thread.CurrentThread: {Thread.CurrentThread.ManagedThreadId}" + $" and Current.Dispatcher.Thread: {Application.Current.Dispatcher.Thread.ManagedThreadId}"; Debug.WriteLine(message); }; app.Startup += (sender, args) => { var message = $"Start TestApp with Thread.CurrentThread: {Thread.CurrentThread.ManagedThreadId}" + $" and Current.Dispatcher.Thread: {Application.Current.Dispatcher.Thread.ManagedThreadId}"; Debug.WriteLine(message); gate.Set(); }; app.Run(); }
protected CommandResult RunTest( DotNetCli dotnet, TestApp app, TestSettings settings, Action <CommandResult> resultAction = null, bool multiLevelLookup = false) { using (DotNetCliExtensions.DotNetCliCustomizer dotnetCustomizer = settings.DotnetCustomizer == null ? null : dotnet.Customize()) { settings.DotnetCustomizer?.Invoke(dotnetCustomizer); if (settings.RuntimeConfigCustomizer != null) { settings.RuntimeConfigCustomizer(RuntimeConfig.Path(app.RuntimeConfigJson)).Save(); } settings.WithCommandLine(app.AppDll); Command command = dotnet.Exec(settings.CommandLine.First(), settings.CommandLine.Skip(1).ToArray()); if (settings.WorkingDirectory != null) { command = command.WorkingDirectory(settings.WorkingDirectory); } CommandResult result = command .EnvironmentVariable("COREHOST_TRACE", "1") .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", multiLevelLookup ? "1" : "0") .Environment(settings.Environment) .CaptureStdOut() .CaptureStdErr() .Execute(); resultAction?.Invoke(result); return(result); } }
public TestApp CreateSelfContainedAppWithMockHostPolicy() { string testAppDir = Path.Combine(_baseDir, "SelfContainedApp"); Directory.CreateDirectory(testAppDir); TestApp testApp = new TestApp(testAppDir); string hostFxrFileName = RuntimeInformationExtensions.GetSharedLibraryFileNameForCurrentPlatform("hostfxr"); string hostPolicyFileName = RuntimeInformationExtensions.GetSharedLibraryFileNameForCurrentPlatform("hostpolicy"); string mockHostPolicyFileName = RuntimeInformationExtensions.GetSharedLibraryFileNameForCurrentPlatform("mockhostpolicy"); string appHostFileName = RuntimeInformationExtensions.GetExeFileNameForCurrentPlatform("apphost"); DotNetCli builtDotNetCli = new DotNetCli(_builtDotnet); // ./hostfxr - the product version File.Copy(builtDotNetCli.GreatestVersionHostFxrFilePath, Path.Combine(testAppDir, hostFxrFileName)); // ./hostpolicy - the mock File.Copy( Path.Combine(_repoDirectories.Artifacts, "corehost_test", mockHostPolicyFileName), Path.Combine(testAppDir, hostPolicyFileName)); // ./SelfContainedApp.dll File.WriteAllText(Path.Combine(testAppDir, "SelfContainedApp.dll"), string.Empty); // ./SelfContainedApp.runtimeconfig.json File.WriteAllText(Path.Combine(testAppDir, "SelfContainedApp.runtimeconfig.json"), "{}"); // ./SelfContainedApp.exe string selfContainedAppExePath = Path.Combine(testAppDir, RuntimeInformationExtensions.GetExeFileNameForCurrentPlatform("SelfContainedApp")); File.Copy( Path.Combine(_repoDirectories.HostArtifacts, appHostFileName), selfContainedAppExePath); AppHostExtensions.BindAppHost(selfContainedAppExePath); return testApp; }
protected CommandResult RunTest( DotNetCli dotnet, TestApp app, TestSettings settings, Action <CommandResult> resultAction = null, bool multiLevelLookup = false) { using (DotNetCliExtensions.DotNetCliCustomizer dotnetCustomizer = settings.DotnetCustomizer == null ? null : dotnet.Customize()) { settings.DotnetCustomizer?.Invoke(dotnetCustomizer); if (settings.RuntimeConfigCustomizer != null) { settings.RuntimeConfigCustomizer(RuntimeConfig.Path(app.RuntimeConfigJson)).Save(); } settings.WithCommandLine(app.AppDll); Command command = dotnet.Exec(settings.CommandLine.First(), settings.CommandLine.Skip(1).ToArray()); if (settings.WorkingDirectory != null) { command = command.WorkingDirectory(settings.WorkingDirectory); } CommandResult result = command .EnableTracingAndCaptureOutputs() .MultilevelLookup(multiLevelLookup) .Environment(settings.Environment) .Execute(); resultAction?.Invoke(result); return(result); } }
protected void RunTest( DotNetCli dotnet, TestApp app, TestSettings settings, Action <CommandResult> resultAction, bool multiLevelLookup = false) { if (settings.RuntimeConfigCustomizer != null) { settings.RuntimeConfigCustomizer(RuntimeConfig.Path(app.RuntimeConfigJson)).Save(); } settings.WithCommandLine(app.AppDll); CommandResult result = dotnet.Exec(settings.CommandLine.First(), settings.CommandLine.Skip(1).ToArray()) .EnvironmentVariable("COREHOST_TRACE", "1") .EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", multiLevelLookup ? "1" : "0") .Environment(settings.Environment) .CaptureStdOut() .CaptureStdErr() .Execute(); resultAction(result); }
public async Task Shapes_Clone() { TestApp.RunSimpleApp(async app => { var node = app.RootNode.CreateChild(); var box = node.CreateComponent <Box>(); box.Color = Color.Cyan; var clone1 = node.Clone(); var clonedBox1 = clone1.GetComponent <Box>(); var clone2 = clone1.Clone(); var clonedBox2 = clone2.GetComponent <Box>(); var clone3 = clone2.Clone(); var clonedBox3 = clone3.GetComponent <Box>(); Assert.AreEqual(Color.Cyan, clonedBox1.Color); Assert.AreEqual(Color.Cyan, clonedBox2.Color); Assert.AreEqual(Color.Cyan, clonedBox3.Color); await app.Exit(); }); }
private void CheckForLocalAccounts() { if (!TestApp.GetInstance().isNoLocalAccounts) { ClearList(accountsRectTracker); accountsRectTracker = new List <GameObject>(); UserAccount[] allAccounts = TestApp.GetInstance().userAccounts.ToArray(); foreach (var item in allAccounts) { GameObject account = Instantiate(accountTemplateUi) as GameObject; accountsRectTracker.Add(account); account.transform.SetParent(rectParent); account.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); account.GetComponent <AccountTemplateUI>().accountUniqueId = item.uniqueId; account.GetComponent <AccountTemplateUI>().username.text = item.username; //TODO Add rest items } } else { Debug.Log("Create New account"); } }
private CommandResult RunMultiThreadedTest(TestApp componentOne, TestApp componentTwo) { return(RunMultiThreadedTest(componentOne.AppDll, componentTwo.AppDll)); }
public static TestSession CreateLocal(TestApp app, TestFramework framework, TestContext rootCtx) { return(new ReflectionTestSession(app, (ReflectionTestFramework)framework, rootCtx)); }
/// <summary> /// Initializes a new instance of the TestSpike class. /// </summary> /// <param name=""></param> public TestSpike() { this.app = new TestApp(); }
private void ShowMenuAction(object obj) { TestApp.Run(); MessagingCenter.Send(EventArgs.Empty, "OpenMenu"); }
private CommandResult RunTest(TestSettings testSettings, bool?multiLevelLookup, TestApp testApp) { return(RunTest( SharedState.DotNetMainHive, testApp, testSettings .WithEnvironment(Constants.TestOnlyEnvironmentVariables.GloballyRegisteredPath, SharedState.DotNetGlobalHive.BinPath) .WithEnvironment( // Redirect the default install location to an invalid location so that a machine-wide install is not used Constants.TestOnlyEnvironmentVariables.DefaultInstallPath, System.IO.Path.Combine(SharedState.DotNetMainHive.BinPath, "invalid")), // Must enable multi-level lookup otherwise multiple hives are not enabled multiLevelLookup: multiLevelLookup)); }
public void Route3(TestApp app, IManosContext ctx, String name, int age) { ctx.Response.Write("'{0}', you are '{1}'",name, age); ctx.Response.End(); }
public static void Main() { using var testApp = new TestApp(); testApp.Run(); }
public ComponentSharedTestState() { HostApp = CreateSelfContainedAppWithMockCoreClr("ComponentHostSelfContainedApp", "1.0.0"); }
protected TestArea() { _app = new TestApp(this); }
public void RouteWorksWithNamedParametersInModuleOnCustomApp() { var t = new TestApp(); var req = new MockHttpRequest(HttpMethod.HTTP_GET, "/TESTING/Route2a/29/Andrew"); var txn = new MockHttpTransaction(req, new MockHttpResponse()); t.HandleTransaction(t, txn); Assert.AreEqual("(R2a) Hello 'Andrew', you are '29'", txn.ResponseString); req = new MockHttpRequest(HttpMethod.HTTP_GET, "/TESTING/Route2b/Andrew/29"); txn = new MockHttpTransaction(req, new MockHttpResponse()); t.HandleTransaction(t, txn); Assert.AreEqual("(R2b) Hello 'Andrew', you are '29'", txn.ResponseString); }
public static AndConstraint <CommandResultAssertions> NotHaveResolvedNativeLibraryPath(this CommandResultAssertions assertion, string path, TestApp app = null) { return(assertion.NotHaveRuntimePropertyContaining(NATIVE_DLL_SEARCH_DIRECTORIES, RelativePathsToAbsoluteAppPaths(path, app))); }
public CommandResult RunComponentResolutionTest(TestApp component, Action <Command> commandCustomizer = null) { return(RunComponentResolutionTest(component.AppDll, FrameworkReferenceApp, DotNetWithNetCoreApp.GreatestVersionHostFxrPath, commandCustomizer)); }
public CommandResult RunComponentResolutionMultiThreadedTest(TestApp componentOne, TestApp componentTwo) { return(RunComponentResolutionMultiThreadedTest(componentOne.AppDll, componentTwo.AppDll, FrameworkReferenceApp, DotNetWithNetCoreApp.GreatestVersionHostFxrPath)); }
public void ImplicitRouteWorksWithModuleOnCustomApp() { var t = new TestApp(); var req = new MockHttpRequest(HttpMethod.HTTP_GET,"/TESTING/Route1"); var txn = new MockHttpTransaction(req); t.HandleTransaction(t,txn); Assert.AreEqual("Route1",txn.ResponseString); req = new MockHttpRequest(HttpMethod.HTTP_GET, "/TESTING/Route1/"); txn = new MockHttpTransaction(req); t.HandleTransaction(t,txn); Assert.AreEqual("Route1",txn.ResponseString); }
private void StartDispatcher() { app = new TestApp { ShutdownMode = ShutdownMode.OnExplicitShutdown }; app.Startup += (sender, args) => gate.Set(); app.Run(); }
public void Setup() { _testApp = new TestApp(); }
public ClientConnection(TestApp app, Stream stream, IServerConnection connection) : base(app, stream) { startTcs = new TaskCompletionSource <object> (); }
public CommandResult RunComponentResolutionMultiThreadedTest(string componentOnePath, string componentTwoPath, TestApp hostApp, string hostFxrFolder) { string[] args = { resolve_component_dependencies, run_app_and_resolve_multithreaded, Path.Combine(hostFxrFolder, RuntimeInformationExtensions.GetSharedLibraryFileNameForCurrentPlatform("hostfxr")), hostApp.AppDll, componentOnePath, componentTwoPath }; return(Command.Create(NativeHostPath, args) .EnableTracingAndCaptureOutputs() .MultilevelLookup(false) .Execute()); }
internal Connection(TestApp app, Stream stream) { this.app = app; this.stream = stream; cancelCts = new CancellationTokenSource(); }
public static int TestEntrypoint() { return(TestApp.RunAllTests()); }
public override void Initialize() { base.Initialize(); _testApp = new TestApp(); }
public TestSession(TestApp app) { App = app; }
public LauncherConnection(TestApp app, Stream stream, IServerConnection connection, ExternalProcess process) : base(app, stream, connection) { this.process = process; }
public void Route3(TestApp app, IManosContext ctx, String name, int age) { ctx.Response.Write("'{0}', you are '{1}'", name, age); ctx.Response.End(); }
private CommandResult RunTest(TestApp component, Action <Command> commandCustomizer = null) { return(RunTest(component.AppDll, commandCustomizer)); }
public override void InitApp() { // Bind App class to contex.You can ignore this if app class is useless. // 绑定App类到contex,如果app类无用,或者不需要做全局初始化,可忽略此步. BindApp(TestApp.Instance <TestApp>()); }
public static AndConstraint <CommandResultAssertions> NotHaveResolvedAssembly(this CommandResultAssertions assertion, string assemblyPath, TestApp app = null) { return(assertion.NotHaveRuntimePropertyContaining(TRUSTED_PLATFORM_ASSEMBLIES, RelativePathsToAbsoluteAppPaths(assemblyPath, app))); }
public void RouteWorksWithRegexParamsInModuleOnCustomApp() { var t = new TestApp(); var req = new MockHttpRequest(HttpMethod.HTTP_GET,"/TESTING/Route3/Andrew/29"); var txn = new MockHttpTransaction(req); t.HandleTransaction(t,txn); Assert.AreEqual("'Andrew', you are '29'",txn.ResponseString); req = new MockHttpRequest(HttpMethod.HTTP_GET,"/TESTING/Route3/Andrew/29/"); txn = new MockHttpTransaction(req); t.HandleTransaction(t,txn); Assert.AreEqual("'Andrew', you are '29'",txn.ResponseString); }
private static string[] RelativePathsToAbsoluteAppPaths(string relativePaths, TestApp app) { List <string> paths = new List <string>(); foreach (string relativePath in relativePaths.Split(';')) { string path = relativePath.Replace('/', Path.DirectorySeparatorChar); if (app != null) { path = Path.Combine(app.Location, path); } paths.Add(path); } return(paths.ToArray()); }
public void OneTimeSetUp() { Xamarin.Forms.Mocks.MockForms.Init(); this.App = new TestApp(new TestPlatformInitializer()); }
public static void Main() { TestApp test = new TestApp(); test.Start(); }