public bool RunTests(string workingPath) { var result = true; var testOutput = new TestOutput(); var testAssemblies = GetTestAssemblies(workingPath); testAssemblies = testAssemblies.GroupBy(x => Path.GetFileName(x)).Select(group => group.First()); if (testAssemblies.Count() == 0) return result; var testRunnerPath = Directory.GetFiles(workingPath, testRunnerExecutableName, SearchOption.AllDirectories).FirstOrDefault(); if (String.IsNullOrEmpty(testRunnerPath)) { result = false; return result; } int numberOfTestsFailed = 0; foreach (string testAssembly in testAssemblies) { var processOutput = RunProcess(testRunnerPath, testAssembly); var specificationResults = ParseResultsFromTest(processOutput); if (numberOfTestsFailed > 0) { notificationService.Notify(String.Format("(NUnit) - {0} contains failing tests", Path.GetFileName(testAssembly)), message: String.Format("{0} tests failed", numberOfTestsFailed), notificationType: NotificationType.Error); } foreach (var specificationResult in specificationResults) { result = false; numberOfTestsFailed++; notificationService.Notify(String.Format("{0} - {1}", specificationResult.Context, specificationResult.Specification), message: specificationResult.Detail, notificationType: NotificationType.Error); } numberOfTestsFailed = 0; } return result; }
public StartingANewGame() { var output = new TestOutput(); _app = new ChessApp(output); _app.Handle(new CreateGameAppCommand()); _latestGameName = output.LatestGameName; _newGame = _app.GetGame(_latestGameName); }
public void RunHeadless_Echo() { var output = new TestOutput(); var engine = new EngineBuilder() .SetupHandlers(h => h.UseHandlerTypes(typeof(EchoHandler))) .SetupOutput(o => o.DoNotUseConsole().Add(output)) .Build(); engine.RunHeadless("echo 'test'"); output.Lines.Count.Should().Be(1); output.Lines[0].Should().Be("test"); }
public void DataOutputSomeData() { //--Arrange TestOutput TestOutput2 = new TestOutput(); string expectedOutput2 = "IPhoneHeadset sound"; //--Act TestOutput2.DataOutput(expectedOutput2); //--Assert Assert.AreEqual(expectedOutput2, TestOutput2.DataOutputTest); }
public void DataOutputEmptyData() { //--Arrange TestOutput TestOutput = new TestOutput(); string expectedOutput = null; //--Act TestOutput.DataOutput(expectedOutput); //--Assert Assert.AreEqual(expectedOutput, TestOutput.DataOutputTest); }
public static TestOutput Map(this TestOutputDto testOutputDto) { var name = NamesProvider.GetTestOutputFileName(testOutputDto.TestOutputInfo.Date); var testOutput = new TestOutput { SuiteOutput = testOutputDto.SuiteOutput, Output = testOutputDto.Output, TestOutputInfo = testOutputDto.TestOutputInfo.MapSimpleItemInfo(name) }; return(testOutput); }
/// <summary> /// /// </summary> /// <param name="simulationOutput"></param> public void Update(TestOutput result) { var viewModel = new BobsGraphViewModel(); viewModel.UpdateSize( (float)GraphArea.ActualWidth, (float)GraphArea.ActualHeight, 2); viewModel.UpdateData(result); DataContext = viewModel; }
public static string Save(this TestOutput testOutput, string path) { path.Create(); var fullPath = Path.Combine(path, NamesProvider.GetTestOutputFileName(testOutput.TestOutputInfo.Date)); using (var file = File.CreateText(fullPath)) { var serializer = new JsonSerializer(); serializer.Serialize(file, testOutput); } return(fullPath); }
public void TestOutput(TestOutput testOutput) { if (!String.IsNullOrEmpty(testOutput.Text)) { string kind = testOutput.Type.ToString(); foreach (string l in testOutput.Text.Split('\n')) { Writer.Write(" {0}: ", kind); Writer.WriteLine(l); } } }
/// <summary> /// Writes to the console an error message describing the operation that caused an assert operation to fail. /// </summary> /// <param name="expression"> /// The generated expression. /// </param> /// <param name="property"> /// The property accessed by the expression. /// </param> /// <param name="value"> /// The value used by the expression to compare. /// </param> protected void WriteErrorMessage(LambdaExpression expression, string property, object value) { if (!(value is string) && value is IEnumerable valueCollection) { var valueList = valueCollection.Cast <object>().ToList(); value = valueList.Select(t => string.Concat("'", t?.ToString() ?? "$!NULL!$", "'")); } TestOutput.WriteLine($"Expression: {expression}"); TestOutput.WriteLine($"Property: {property}"); TestOutput.WriteLine($"Value: {value}"); }
public void WriteLine(string value) { Guard.AgainstNull(value, nameof(value)); lock (locker) { ThrowIfFlushed(); if (Builder == null && TestOutput == null) { if (Filters.ShouldFilterOut(value)) { return; } Builder = new StringBuilder(); Builder.AppendLine(value); logMessages.Add(value); return; } if (Builder != null && TestOutput != null) { Builder.AppendLine(value); var message = Builder.ToString(); Builder = null; if (Filters.ShouldFilterOut(message)) { return; } logMessages.Add(message); TestOutput.WriteLine(message); return; } if (Builder == null && TestOutput != null) { if (Filters.ShouldFilterOut(value)) { return; } logMessages.Add(value); TestOutput.WriteLine(value); return; } if (Builder != null && TestOutput == null) { Builder.AppendLine(value); } } }
/// <summary> /// Emit a log entry. /// </summary> /// <param name="level"> /// The log entry's level. /// </param> /// <param name="eventId"> /// The log entry's associated event Id. /// </param> /// <param name="state"> /// The log entry to be written. Can be also an object. /// </param> /// <param name="exception"> /// The exception (if any) related to the log entry. /// </param> /// <param name="formatter"> /// A function that creates a <c>string</c> log message from the <paramref name="state"/> and <paramref name="exception"/>. /// </param> public void Log <TState>(LogLevel level, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter) { if (formatter == null) { throw new ArgumentNullException(nameof(formatter)); } TestOutput.WriteLine(String.Format("[{0}] {1}: {2}", level, LoggerCategory, formatter(state, exception) )); }
public void Instance_Test() { var output = new TestOutput(); var engine = new EngineBuilder() .SetupHandlers(h => h.UseHandlerTypes(typeof(TestEnvironmentHandler))) .SetupOutput(o => o.DoNotUseConsole().Add(output)) .SetupEnvironments(e => e.UseInstance(new TestEnvironment("Single"))) .Build(); engine.RunHeadless("test"); output.Lines.Count.Should().Be(1); output.Lines[0].Should().Be("Single"); }
public void TestOutput(TestOutput testOutput) { if (_reportConsole && _testId != null) { Bridge.Service.AddLogItem(new AddLogItemRequest { TestItemId = _testId, Time = DateTime.UtcNow, Level = LogLevel.Info, Text = testOutput.Text }); } }
public void TestOutput(TestOutput output) { switch (output.Type) { case TestOutputType.Out: outWriter.Write(output.Text); break; case TestOutputType.Error: errorWriter.Write(output.Text); break; } }
public void TestMethod2() { TestOutput output = new TestOutput(); DisplayConsole displayConsole = new DisplayConsole(output, 15); displayConsole.WriteLine("uno-due"); displayConsole.WriteLine("tre"); string expected = "uno-due" + Environment.NewLine + "tre"; string actual = output.currentText; Assert.AreEqual(expected, actual); }
public void Git(string command, string workingDirectory = null) { TestOutput.WriteLine($"Executing Git command -- {command}"); var result = GitProcess.InvokeProcess(workingDirectory ?? RepoRoot, command); if (result.ExitCode != 0) { TestOutput.WriteLine($"Failed executing Git command -- {command}"); TestOutput.WriteLine(result.Output); TestOutput.WriteLine(result.Errors); Assert.Equal(0, result.ExitCode); } }
/// <summary> /// A test has produced some text output /// </summary> /// <param name="testOutput">A TestOutput object holding the text that was written</param> public void TestOutput(TestOutput testOutput) { if (_displayBeforeOutput) { _textUI.DisplayTestLabel(_currentTestName); } var style = testOutput.Type == TestOutputType.Error ? ColorStyle.Error : ColorStyle.Output; _writer.Write(style, testOutput.Text); }
/// <summary> /// /// </summary> /// <param name="data"></param> public void UpdateData(TestOutput data) { _data = data; Clear(); EvaluateData(); SetColors(); SetVisibility(); SetGraphPoints(); SetTieLethal(); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("")); }
public void InstanceMethods_Help() { var output = new TestOutput("help"); var engine = new EngineBuilder() .SetupHandlers(h => h.UsePublicMethodsAsHandlers(new MyObject())) .SetupOutput(o => o.DoNotUseConsole().Add(output)) .Build(); engine.RunInteractively(); output.Lines.Should().Contain("testa"); output.Lines.Should().Contain("testb"); output.Lines.Should().Contain("testc"); }
public void WhenBadInputIsEnteredThenErrorMessageIsShown(string inputString, string expected) { var applicationFactory = new ApplicationFactory(); var input = new TestInput(inputString); var output = new TestOutput(); applicationFactory .Create(input, output) .Execute(); var actual = output.Outputs.Last(); Assert.That(actual, Is.EqualTo(expected)); }
public void Test() { var output = new TestOutput(); var engine = new EngineBuilder() .SetupHandlers(h => h.UseHandlerTypes(typeof(TestHandler))) .SetupOutput(o => o.DoNotUseConsole().Add(output)) .Build(); engine.RunHeadless("test x y z"); output.Lines.Count.Should().Be(3); output.Lines[0].Should().Be("x"); output.Lines[1].Should().Be("y"); output.Lines[2].Should().Be("z"); }
public void PerformComputerMove(int Move) { TestOutput.ForeColor = SystemColors.WindowText; TestOutput.Text += "Engine: " + PerfectChess.Move.Details(Move) + "\n"; TestOutput.SelectionStart = TestOutput.TextLength; TestOutput.ScrollToCaret(); //BoardPanel.Restore(); PerformMove(Move); BoardPanel.DeleteEffects(false); BoardPanel.ShowLastMove(Square.Get(PerfectChess.Move.FromSquare(Move)), Square.Get(PerfectChess.Move.ToSquare(Move))); BoardPanel.Refresh(); }
public void TimeBlockEnumerableSerializeToJSON(TimeBlockEnumerableTestData inTestData) { #if DEBUG TestOutput.WriteLine("Starting " + nameof(TimeBlockEnumerableSerializeToJSON)); #endif foreach (var e in inTestData.E) { #if DEBUG TestOutput.WriteLine("SerializedTestData is:" + e.SerializedTestData); TestOutput.WriteLine("Serialized ObjTestData is:" + Fixture.Serializer.Serialize(e.ObjTestData)); #endif Fixture.Serializer.Serialize(e.ObjTestData).Should().Be(e.SerializedTestData); } }
public async Task TestConvertFileSystemToGraphAsyncTaskWithoutHashWithoutPersistenceToDigraph() { var asyncFileReadBlockSize = 4096; var enableHash = false; //var partitionInfoEx = new PartitionInfoEx(Hardware.Enumerations.PartitionFileSystem.NTFS, new UnitsNet.Information(1.2m, UnitsNet.Units.InformationUnit.Terabyte), new List<char>() { 'E' }, new Philote.Philote<IPartitionInfoEx>().Now()); //var root = partitionInfoEx.DriveLetters.First(); var root = 'E'; // In Windows, root is a single letter, but in *nix, root is a string. Convert the single char to a string // ToDo: replace with ATAP.Utilities RunTimeKind, and make it *nix friendly var rootstring = root.ToString() + ":/"; // Create storage for the results and progress var convertFileSystemToGraphProgress = new ConvertFileSystemToGraphProgress(); // Cancellation token for the task var cancellationTokenSource = new CancellationTokenSource(); var cancellationTokenSourceId = new IdAsStruct <CancellationTokenSource>(Guid.NewGuid()); var cancellationToken = cancellationTokenSource.Token; ConvertFileSystemToGraphResult convertFileSystemToGraphResult; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { Func <Task <ConvertFileSystemToGraphResult> > run = () => StaticExtensions.ConvertFileSystemToGraphAsyncTask(rootstring, asyncFileReadBlockSize, enableHash, convertFileSystemToGraphProgress, null, null, cancellationToken); convertFileSystemToGraphResult = await run.Invoke().ConfigureAwait(false); } catch (Exception) { throw; } finally { cancellationTokenSource.Dispose(); } stopWatch.Stop(); var digraph = new StringBuilder(); digraph.Append("digraph G {"); digraph.Append(Environment.NewLine); foreach (var e in (convertFileSystemToGraphResult.FSEntityAdjacencyGraph.Edges .Select(edge => { string fs = edge.Source.GetFullName(); string ts = edge.Target.GetFullName(); var tu = (fs, ts); return(tu); })).ToList <(string, string)>()) { digraph.Append($"\"{e.Item1.Replace("\\", "\\\\")}\" -> \"{e.Item2.Replace("\\", "\\\\")}\""); digraph.Append(Environment.NewLine); } digraph.Append("}"); #if DEBUG TestOutput.WriteLine($"{digraph}"); #endif convertFileSystemToGraphResult.FSEntityAdjacencyGraph.VertexCount.Should().Be(15); }
public void PrintPermutations_PermuteThree() { var output = new TestOutput(); var strPerm = new StringPermutation("ABC", output); strPerm.PrintPermutations(); Assert.AreEqual(6, output.Container.Count); Assert.IsTrue(output.Container.Contains("ABC")); Assert.IsTrue(output.Container.Contains("ACB")); Assert.IsTrue(output.Container.Contains("BAC")); Assert.IsTrue(output.Container.Contains("BCA")); Assert.IsTrue(output.Container.Contains("CAB")); Assert.IsTrue(output.Container.Contains("CBA")); }
public TestOutputDto GetTestOutput(TestRunDto test) { TestOutput testOutput = null; if (test != null) { var fullPath = _locationsProvider.GetTestOutputFullPath(test.TestInfo.Guid, test.TestInfo.Finish); if (File.Exists(fullPath)) { testOutput = fullPath.LoadTestOutput(); } } return(testOutput?.ToDto()); }
public void TestOutput(TestOutput testOutput) { if (testOutput == null || String.IsNullOrEmpty(testOutput.Text)) { return; } string kind = testOutput.Type.ToString(); foreach (string l in testOutput.Text.Split('\n')) { Logger.OnInfo($" {kind}: {l}"); } }
public void Instance_Test() { var kernel = new StandardKernel(); var output = new TestOutput(); var engine = new EngineBuilder() .SetupHandlers(h => h.UseNinjectHandlerSource(kernel)) .SetupOutput(o => o.DoNotUseConsole().Add(output)) .SetupEnvironments(e => e.UseInstance(new TestEnvironment("Single"))) .Build(); engine.RunHeadless("test-environment"); output.Lines.Count.Should().Be(1); output.Lines[0].Should().Be("Single"); }
public void UseParser_Null() { var output = new TestOutput(); var engine = new EngineBuilder() .SetupHandlers(h => h.UseHandlerTypes(typeof(TestHandler))) .SetupOutput(o => o.DoNotUseConsole().Add(output)) .SetupArguments(a => a.UseParser(null)) .Build(); engine.RunHeadless("test a b=x -c"); output.Lines.Count.Should().Be(3); output.Lines[0].Should().Be("a"); output.Lines[1].Should().Be("x"); output.Lines[2].Should().Be("True"); }
public void Instance_Test() { var output = new TestOutput(); var container = new Container(); container.SetupEngine <TestEnvironment>(builder => builder .SetupOutput(o => o.DoNotUseConsole().Add(output)) .SetupEnvironments(e => e.UseInstance(new TestEnvironment("Single"))) ); var engine = container.GetInstance <Engine>(); engine.RunHeadless("test-environment"); output.Lines.Count.Should().Be(1); output.Lines[0].Should().Be("Single"); }
private void NotifyAgent(ITestOutputHelper outputHelper, string serializedMessage) { var type = outputHelper.GetType(); var testMember = type.GetField("test", BindingFlags.Instance | BindingFlags.NonPublic); var test = testMember.GetValue(outputHelper); var messageBusMember = type.GetField("messageBus", BindingFlags.Instance | BindingFlags.NonPublic); var messageBusValue = messageBusMember.GetValue(outputHelper); var messageBusType = messageBusValue.GetType(); var m = messageBusType.GetMethod("QueueMessage", BindingFlags.Instance | BindingFlags.Public); TestOutput mmm = new TestOutput((ITest)test, serializedMessage); m.Invoke(messageBusValue, new object[] { mmm }); }
public JoiningAGameFullOfPlayers() { _output = new TestOutput(); var app = new ChessApp(_output); app.Handle(new CreateGameAppCommand()); var latestGameName = _output.LatestGameName; var newGame = app.GetGame(latestGameName); app.Handle(new JoinGameAppCommand(latestGameName, "denise", PlayerColour.Black)); app.Handle(new JoinGameAppCommand(latestGameName, "derek", PlayerColour.White)); _existingBlackPlayer = newGame.GetPlayer(PlayerColour.Black); _existingWhitePlayer = newGame.GetPlayer(PlayerColour.White); app.Handle(new JoinGameAppCommand(latestGameName, "gary", PlayerColour.Black)); }
public void TestOutput( TestOutput testOutput ) { //log.Debug( "Test output: " + testOutput.Text ); }
public static TestOutput CorrectColour(ForeGroundStrucuture[] foregorungRGB_CPU, BackGroundStrucuture[] BackgroundXYZ_CPU) { //set these to constant if you want testing //rgb = System.Drawing.Color.FromArgb(65, 108, 20); //X = 0.613829950099918; //Y = 0.938638756488747; //Z = 1.08019833591292; const int image_size = 960 * 540; //cuda intializer CudafyModule km = CudafyModule.TryDeserialize(); if (km == null || !km.TryVerifyChecksums()) { // km = CudafyTranslator.Cudafy((typeof(ForeGroundStrucuture)), (typeof(BackGroundStrucuture)), typeof(Color)); km = CudafyTranslator.Cudafy(typeof(ProfileStrucuture),typeof(ForeGroundStrucuture), typeof(BackGroundStrucuture), typeof(bf)); km.TrySerialize(); } CudafyTranslator.GenerateDebug = true; // cuda or emulator GPGPU gpu = CudafyHost.GetDevice(CudafyModes.Target, CudafyModes.DeviceId); //sGPGPU gpu = CudafyHost.GetDevice(eGPUType.Emulator); gpu.LoadModule(km); Console.WriteLine("Running brute force correction using {0}", gpu.GetDeviceProperties(false).Name); ForeGroundStrucuture[] output_image_CPU = new ForeGroundStrucuture[image_size]; // allocate memory on the GPU for the bitmap (same size as ptr) DataTable profile = new DataTable(); try { // add the csv bin file using (GenericParserAdapter parser = new GenericParserAdapter(@"C:\lev\STColorCorrection\Data\PROFILE\p3700.csv")) { System.Data.DataSet dsResult = parser.GetDataSet(); profile = dsResult.Tables[0]; } } catch(Exception ex) {Console.WriteLine(ex); } // allocate temp memory, initialize it, copy to constant memory on the GPU // L 0-21 A 0-41 B 0-45 ProfileStrucuture[ , , ] profiles_CPU = new ProfileStrucuture[21,41,45]; //ForeGroundStrucuture[] foregorungRGB_CPU = new ForeGroundStrucuture[image_size]; //BackGroundStrucuture[] BackgroundXYZ_CPU = new BackGroundStrucuture[image_size]; for (int indexL = 0; indexL < 21; indexL++) { for (int indexA = 0; indexA < 41; indexA++) { for (int indexB = 0; indexB < 45; indexB++) { profiles_CPU[indexL, indexA, indexB].L = indexL; profiles_CPU[indexL, indexA, indexB].A = indexA; profiles_CPU[indexL, indexA, indexB].B = indexB; profiles_CPU[indexL, indexA, indexB].Given_R = 0; profiles_CPU[indexL, indexA, indexB].Given_G = 0; profiles_CPU[indexL, indexA, indexB].Given_B = 0; profiles_CPU[indexL, indexA, indexB].ML = 0; profiles_CPU[indexL, indexA, indexB].MA = 0; profiles_CPU[indexL, indexA, indexB].MB = 0; profiles_CPU[indexL, indexA, indexB].MX = 0; profiles_CPU[indexL, indexA, indexB].MY = 0; profiles_CPU[indexL, indexA, indexB].MZ = 0; profiles_CPU[indexL, indexA, indexB].isempty = TRUE; profiles_CPU[indexL, indexA, indexB].isMoreAccurateThanOrigin = -1; } } } int lvalue, avalue, bvalue; try { for (int i = 1; i < profile.Rows.Count; i++) { lvalue=Convert.ToInt32 (profile.Rows[i][0].ToString()); avalue = Convert.ToInt32(profile.Rows[i][1].ToString()); bvalue= Convert.ToInt32(profile.Rows[i][2].ToString()); lvalue=(int)(lvalue*0.2); avalue=(int)(avalue*0.2)+20; bvalue=(int)(bvalue*0.2)+22; profiles_CPU[lvalue, avalue, bvalue].L = lvalue; profiles_CPU[lvalue, avalue, bvalue].A = avalue; profiles_CPU[lvalue, avalue, bvalue].B = bvalue; profiles_CPU[lvalue, avalue, bvalue].Given_R = (byte)Convert.ToByte(profile.Rows[i][9].ToString()); profiles_CPU[lvalue, avalue, bvalue].Given_G = (byte)Convert.ToByte(profile.Rows[i][10].ToString()); profiles_CPU[lvalue, avalue, bvalue].Given_B = (byte)Convert.ToByte(profile.Rows[i][11].ToString()); profiles_CPU[lvalue, avalue, bvalue].ML = (double)Convert.ToDouble(profile.Rows[i][3].ToString()); profiles_CPU[lvalue, avalue, bvalue].MA = (double)Convert.ToDouble(profile.Rows[i][4].ToString()); profiles_CPU[lvalue, avalue, bvalue].MB = (double)Convert.ToDouble(profile.Rows[i][5].ToString()); profiles_CPU[lvalue, avalue, bvalue].MX = (double)Convert.ToDouble(profile.Rows[i][6].ToString()); profiles_CPU[lvalue, avalue, bvalue].MY = (double)Convert.ToDouble(profile.Rows[i][7].ToString()); profiles_CPU[lvalue, avalue, bvalue].MZ = (double)Convert.ToDouble(profile.Rows[i][8].ToString()); profiles_CPU[lvalue, avalue, bvalue].isempty = FALSE; } } catch (Exception ex) { Console.WriteLine(ex); } //foreground and background image inicialization #region //try //{ // for (int i = 0; i < 1; i++) // { // foregorungRGB_CPU[i].R = rgb.R; // foregorungRGB_CPU[i].G = rgb.G; // foregorungRGB_CPU[i].B = rgb.B; // BackgroundXYZ_CPU[i].X = X; // BackgroundXYZ_CPU[i].Y = Y; // BackgroundXYZ_CPU[i].Z = Z; // } //} //catch (Exception ex) //{ Console.WriteLine(ex); } #endregion ProfileStrucuture[, ,] profile_GPU = gpu.CopyToDevice(profiles_CPU); // capture the start time gpu.StartTimer(); ForeGroundStrucuture[] foregorungRGB_GPU = gpu.CopyToDevice(foregorungRGB_CPU); BackGroundStrucuture[] BackgroundXYZ_GPU = gpu.CopyToDevice(BackgroundXYZ_CPU); //out put ForeGroundStrucuture[] distance_GPU = gpu.Allocate(output_image_CPU); // generate a bitmap from our sphere data //Image size: 1024 x 768 //dim3 grids = new dim3(1, 1); //dim3 threads = new dim3(1,1); dim3 grids = new dim3(24, 675); dim3 threads = new dim3(8, 4); gpu.Launch(grids, threads, ((Action<GThread, ProfileStrucuture[, ,], ForeGroundStrucuture[], BackGroundStrucuture[], ForeGroundStrucuture[]>)Bruteforce), profile_GPU, foregorungRGB_GPU, BackgroundXYZ_GPU, distance_GPU); //gpu.Launch(grids, threads, ((Action<GThread, ForeGroundStrucuture[], BackGroundStrucuture[], double[]>)Bruteforce), foregorungRGB_GPU, BackgroundXYZ_GPU, distance_GPU); // copy our bitmap back from the GPU for display gpu.CopyFromDevice(distance_GPU, output_image_CPU); // get stop time, and display the timing results double elapsedTime = gpu.StopTimer(); TestOutput to_return = new TestOutput(); to_return.output_image = output_image_CPU; to_return.timeTaken = elapsedTime; //encapsulte the output image into a class //output_image_CPU[0].execution_time = elapsedTime; Console.WriteLine("Time to generate: {0} ms", elapsedTime); gpu.Free(foregorungRGB_GPU); gpu.Free(BackgroundXYZ_GPU); gpu.Free(distance_GPU); gpu.FreeAll(); return to_return; }
public InputtingCommands() { var output = new TestOutput(); _app = new ChessApp(output); }
/// <summary> /// Called when a test produces output for immediate display /// </summary> /// <param name="output">A TestOutput object containing the text to display</param> public void TestOutput(TestOutput output) { _textUI.TestOutput(output); }
public void TestOutput(TestOutput testOutput) { }
private void SaveTestOutput() { try { TestOutput testOutput = new TestOutput(_context.TestOutputParameters); testOutput.Status = _context.Status; _context.ReplayClient.OnTestCompleted(testOutput); } catch(Exception ex) { _context.UserLogger.Error("Could not save test output", ex); } }
public static TestOutput CorrectColour(ForeGroundStrucuture[] foregorungRGB_CPU, BackGroundStrucuture[] BackgroundXYZ_CPU) { //rgb = System.Drawing.Color.FromArgb(69, 77, 217); //X = 0.0630982813175294; //Y = 0.616476271122916; //Z = 0.667048468232457; const int image_size = 960 * 540; //cuda intializer CudafyModule km = CudafyModule.TryDeserialize(); if (km == null || !km.TryVerifyChecksums()) { // km = CudafyTranslator.Cudafy((typeof(ForeGroundStrucuture)), (typeof(BackGroundStrucuture)), typeof(Color)); km = CudafyTranslator.Cudafy((typeof(ProfileStrucuture)), (typeof(ForeGroundStrucuture)), (typeof(BackGroundStrucuture)), (typeof(SampleStructure)), typeof(snake)); km.TrySerialize(); } CudafyTranslator.GenerateDebug = true; // cuda or emulator GPGPU gpu = CudafyHost.GetDevice(CudafyModes.Target, CudafyModes.DeviceId); //GPGPU gpu = CudafyHost.GetDevice(eGPUType.Emulator); Console.WriteLine("Running quick correction using {0}", gpu.GetDeviceProperties(false).Name); gpu.LoadModule(km); ForeGroundStrucuture[] distance_CPU = new ForeGroundStrucuture[image_size]; // allocate memory on the GPU for the bitmap (same size as ptr) #region DataTable profile = new DataTable(); try { // add the csv bin file using (GenericParserAdapter parser = new GenericParserAdapter(@"C:\lev\STColorCorrection\Data\PROFILE\p3700.csv")) { System.Data.DataSet dsResult = parser.GetDataSet(); profile = dsResult.Tables[0]; } } catch (Exception ex) { Console.WriteLine(ex); } #endregion // allocate temp memory, initialize it, copy to constant memory on the GPU // L 0-21 A 0-41 B 0-45 ProfileStrucuture[, ,] profiles_CPU = new ProfileStrucuture[21, 41, 45]; SampleStructure[,] samples_CPU = new SampleStructure[image_size, 6]; //profile inicialization #region for (int indexL = 0; indexL < 21; indexL++) { for (int indexA = 0; indexA < 41; indexA++) { for (int indexB = 0; indexB < 45; indexB++) { profiles_CPU[indexL, indexA, indexB].L = indexL; profiles_CPU[indexL, indexA, indexB].A = indexA; profiles_CPU[indexL, indexA, indexB].B = indexB; profiles_CPU[indexL, indexA, indexB].Given_R = 0; profiles_CPU[indexL, indexA, indexB].Given_G = 0; profiles_CPU[indexL, indexA, indexB].Given_B = 0; profiles_CPU[indexL, indexA, indexB].ML = 0; profiles_CPU[indexL, indexA, indexB].MA = 0; profiles_CPU[indexL, indexA, indexB].MB = 0; profiles_CPU[indexL, indexA, indexB].MX = 0; profiles_CPU[indexL, indexA, indexB].MY = 0; profiles_CPU[indexL, indexA, indexB].MZ = 0; profiles_CPU[indexL, indexA, indexB].distance = -1.0; profiles_CPU[indexL, indexA, indexB].weight = -1.0; profiles_CPU[indexL, indexA, indexB].isempty = TRUE; profiles_CPU[indexL, indexA, indexB].isMoreAccurateThanOrigin = FALSE; } } } int lvalue, avalue, bvalue; try { for (int i = 1; i < profile.Rows.Count; i++) { lvalue = Convert.ToInt32(profile.Rows[i][0].ToString()); avalue = Convert.ToInt32(profile.Rows[i][1].ToString()); bvalue = Convert.ToInt32(profile.Rows[i][2].ToString()); lvalue = (int)(lvalue * 0.2); avalue = (int)(avalue * 0.2) + 20; bvalue = (int)(bvalue * 0.2) + 22; profiles_CPU[lvalue, avalue, bvalue].L = lvalue; profiles_CPU[lvalue, avalue, bvalue].A = avalue; profiles_CPU[lvalue, avalue, bvalue].B = bvalue; profiles_CPU[lvalue, avalue, bvalue].Given_R = (byte)Convert.ToByte(profile.Rows[i][9].ToString()); profiles_CPU[lvalue, avalue, bvalue].Given_G = (byte)Convert.ToByte(profile.Rows[i][10].ToString()); profiles_CPU[lvalue, avalue, bvalue].Given_B = (byte)Convert.ToByte(profile.Rows[i][11].ToString()); profiles_CPU[lvalue, avalue, bvalue].ML = (double)Convert.ToDouble(profile.Rows[i][3].ToString()); profiles_CPU[lvalue, avalue, bvalue].MA = (double)Convert.ToDouble(profile.Rows[i][4].ToString()); profiles_CPU[lvalue, avalue, bvalue].MB = (double)Convert.ToDouble(profile.Rows[i][5].ToString()); profiles_CPU[lvalue, avalue, bvalue].MX = (double)Convert.ToDouble(profile.Rows[i][6].ToString()); profiles_CPU[lvalue, avalue, bvalue].MY = (double)Convert.ToDouble(profile.Rows[i][7].ToString()); profiles_CPU[lvalue, avalue, bvalue].MZ = (double)Convert.ToDouble(profile.Rows[i][8].ToString()); profiles_CPU[lvalue, avalue, bvalue].isempty = FALSE; } } catch (Exception ex) { Console.WriteLine(ex); } #endregion //grab the colors ProfileStrucuture[, ,] profile_GPU = gpu.CopyToDevice(profiles_CPU); SampleStructure[,] samples_GPU = gpu.CopyToDevice(samples_CPU); //begin execution // capture the start time gpu.StartTimer(); ForeGroundStrucuture[] foregorungRGB_GPU = gpu.CopyToDevice(foregorungRGB_CPU); BackGroundStrucuture[] BackgroundXYZ_GPU = gpu.CopyToDevice(BackgroundXYZ_CPU); //out put ForeGroundStrucuture[] distance_GPU = gpu.Allocate(distance_CPU); // generate a bitmap from our sphere data //Image size: 1024 x 768 dim3 grids = new dim3(24, 675); dim3 threads = new dim3(8, 4); //dim3 grids = new dim3(1, 1); //dim3 threads = new dim3(1, 1); //quick_correct //gpu.Launch(grids, threads, ((Action<GThread, ProfileStrucuture[, ,], ForeGroundStrucuture[], BackGroundStrucuture[], ProfileStrucuture[], SampleStructure[,]>)QuickCorr), profile_GPU, foregorungRGB_GPU, BackgroundXYZ_GPU, distance_GPU, samples_GPU); //quick correct - testing gpu.Launch(grids, threads, ((Action<GThread, ProfileStrucuture[, ,], ForeGroundStrucuture[], BackGroundStrucuture[], ForeGroundStrucuture[], SampleStructure[,]>)Snake), profile_GPU, foregorungRGB_GPU, BackgroundXYZ_GPU, distance_GPU, samples_GPU); // copy our bitmap back from the GPU for display gpu.CopyFromDevice(distance_GPU, distance_CPU); // get stop time, and display the timing results double elapsedTime = gpu.StopTimer(); TestOutput to_return = new TestOutput(); to_return.output_image = distance_CPU; to_return.timeTaken = elapsedTime; Console.WriteLine("Time to generate: {0} ms", elapsedTime); gpu.Free(foregorungRGB_GPU); gpu.Free(BackgroundXYZ_GPU); gpu.Free(distance_GPU); gpu.FreeAll(); return to_return; }
public void TestOutput(TestOutput testOutput) { if (testOutput.Type != TestOutputType.Trace) { WriteTrace("TestOutput {0}: '{1}'", testOutput.Type, testOutput.Text); } }
public void TestOutput(TestOutput testOutput) { foreach( EventListener listener in Extensions ) listener.TestOutput( testOutput ); }
/// <summary> /// Called when a test produces output for immediate display /// </summary> /// <param name="output">A TestOutput object containing the text to display</param> public void TestOutput(TestOutput output) { _testOutputCount++; }
void EventListener.TestOutput(TestOutput testOutput) { // Debug.Log("Test Output " + testOutput.Text); }
public StoppingChessApp() { _output = new TestOutput(); _app = new ChessApp(_output); }