How to use xunit class

Best Atoum code snippet using xunit

Controller.cs

Source:Controller.cs Github

copy

Full Screen

1using FlowCalc.Mathematics;2using FlowCalc.PoolSystem;3using PdfSharp.Drawing;4using PdfSharp.Drawing.Layout;5using PdfSharp.Fonts;6using PdfSharp.Pdf;7using System;8using System.Collections.Generic;9using System.ComponentModel;10using System.Diagnostics;11using System.Drawing.Imaging;12using System.IO;13using System.Linq;14using System.Reflection;15using System.Runtime.CompilerServices;16using System.Text;17using System.Threading.Tasks;18namespace FlowCalc19{20 public class Controller : INotifyPropertyChanged21 {22 #region Constants23 const string PRESETS_PATH = "FlowCalc.settings";24 #endregion Constants25 /// <summary>26 /// Aktuell geladene Voreinstellungen27 /// </summary>28 public static CalcPresets CurrentPresets;29 #region Member30 #endregion Member31 #region Properties32 /// <summary>33 /// Benutzerdefinierter Anwendername34 /// </summary>35 public string Username { get; set; }36 /// <summary>37 /// Aktive Pumpe38 /// </summary>39 public Pump Pump { get; set; }40 /// <summary>41 /// Verfügbare Pumpe42 /// </summary>43 public List<Pump> Pumps { get; set; }44 /// <summary>45 /// Verfügbare Fittings46 /// </summary>47 public List<Fitting> Fittings { get; set; }48 /// <summary>49 /// Pfad zur aktuell verwendeten Pumpendefinition50 /// </summary>51 public string PumpDefinitionPath { get; set; }52 /// <summary>53 /// Aktueller Systemdruck54 /// in [bar]55 /// </summary>56 public double SystemPressure { get; set; }57 /// <summary>58 /// Aktueller Druck nach der Pumpe (Filterdruck)59 /// in [bar]60 /// </summary>61 public double FilterPressure { get; set; }62 /// <summary>63 /// Aktuelle Wassersäule64 /// in [m]65 /// berechnet aus dem aktuellen Systemdruck66 /// </summary>67 public double SystemHead68 {69 get70 {71 return SystemPressure / 0.0980665;72 }73 }74 /// <summary>75 /// Aktueller Systemvolumenstrom76 /// in [m³/h]77 /// </summary>78 public double SystemFlowRate { get; set; }79 public Pipe SuctionPipe { get; set; }80 public double SuctionPressureDrop { get; set; }81 public int SuctionPressureDropCalcIterations { get; set; }82 #endregion Properties83 #region Constructor84 /// <summary>85 /// Empty constructor for Controller86 /// </summary>87 public Controller()88 {89 if (File.Exists(PRESETS_PATH))90 CurrentPresets = CalcPresets.FromFile(PRESETS_PATH);91 else92 {93 CurrentPresets = CalcPresets.Default;94 CurrentPresets.ToFile(PRESETS_PATH);95 }96 GlobalFontSettings.FontResolver = new Report.BarlowFontResolver();97 }98 #endregion Constructor99 #region Services100 public void ApplyPresets(CalcPresets presets)101 {102 CurrentPresets = presets;103 CurrentPresets.ToFile(PRESETS_PATH);104 }105 /// <summary>106 /// Initialisiere neue Pumpe107 /// </summary>108 public void NewPump()109 {110 PumpDefinitionPath = null;111 Pump = new Pump();112 }113 /// <summary>114 /// Pumpendefinitionsdatei laden und in <see cref="Pump"/> ablegen115 /// </summary>116 /// <param name="path">Pafd zur Pumpendefinitionsdatei</param>117 /// <exception cref="InvalidDataException">Fehler beim laden der Pumpendefinitionsdatei</exception>118 public void LoadPump(string path)119 {120 Pump = Pump.FromFile(path);121 PumpDefinitionPath = path;122 NewPumpLoaded?.Invoke();123 }124 /// <summary>125 /// Alle Pumpen laden126 /// </summary>127 /// <param name="searchPath">Pfad in welchem Pumpen gesucht werden sollen</param>128 public void LoadPumps(string searchPath)129 {130 var pumps = new List<Pump>();131 if (Directory.Exists(searchPath))132 {133 var fileNames = Directory.GetFiles(searchPath);134 foreach (var fileName in fileNames)135 {136 if (fileName.EndsWith(".xml") &!fileName.EndsWith("Blanko.xml"))137 {138 Debug.WriteLine("Deserialize " + fileName);139 try140 {141 var pump = Pump.FromFile(fileName);142 pump.FilePath = fileName;143 pumps.Add(pump);144 }145 catch (Exception)146 {147 //Überspringen TODO: dirty148 }149 }150 }151 if (pumps.Count > 0)152 Pumps = pumps;153 }154 }155 public void LoadFittings(string searchPath)156 {157 var fittings = new List<Fitting>();158 if (Directory.Exists(searchPath))159 {160 var fileNames = Directory.GetFiles(searchPath);161 foreach (var fileName in fileNames)162 {163 if (fileName.EndsWith(".xml") & !fileName.EndsWith("Blanko.xml"))164 {165 Debug.WriteLine("Deserialize " + fileName);166 try167 {168 var fitting = Fitting.FromFile(fileName);169 fitting.FilePath = fileName;170 fittings.Add(fitting);171 }172 catch (Exception)173 {174 //Überspringen TODO: dirty175 }176 }177 }178 if (fittings.Count > 0)179 Fittings = fittings;180 }181 }182 public void CalcFlowRate(double pressure, int? rpm = null)183 {184 //for debugging only185 var sw = new Stopwatch();186 SystemPressure = pressure;187 if (SystemHead > Pump.GetMaxTotalHead(rpm))188 {189 ResetSystem();190 return;191 }192 var systemFlowRate = LinInterp.LinearInterpolation(Pump.GetPerformanceHeadValues(rpm), Pump.GetPerformanceFlowValues(rpm), SystemHead);193 if (SuctionPipe == null)194 {195 SystemFlowRate = systemFlowRate;196 }197 else198 {199 double pressureDrop = 0;200 double systemPressure = 0;201 //Iterative Berechnung, da Volumenstrom auch vom saugseitigen Druckverlust abhängt202 double s = -0.01; // Schrittweite für Antastung203 int i = 7; // Anzahl der Richtungswechsel204 double error = double.MaxValue;205 double lastError;206 sw.Start();207 while (i > 0)208 {209 lastError = error;210 systemFlowRate += s;211 pressureDrop = SuctionPipe.CalcPressureDrop(CurrentPresets.Medium, systemFlowRate);212 var performanceFlowValues = Pump.GetPerformanceFlowValues(rpm);213 var performanceHeadValues = Pump.GetPerformanceHeadValues(rpm);214 Array.Reverse(performanceFlowValues);215 Array.Reverse(performanceHeadValues);216 systemPressure = LinInterp.LinearInterpolation(performanceFlowValues, performanceHeadValues, systemFlowRate) * 0.0980665;217 error = systemPressure - pressureDrop - pressure;218 if (Math.Abs(error) >= Math.Abs(lastError))219 {220 s /= -10;221 i--;222 }223 SuctionPressureDropCalcIterations++;224 }225 sw.Stop();226 Debug.WriteLine($"SuctionPressureDropCalc Iterations: {SuctionPressureDropCalcIterations} Time: {sw.ElapsedMilliseconds} ms");227 //TODO: Pump.MaxTotalHead für VARIO Pumpe228 if (SystemHead > Pump.GetMaxTotalHead(rpm) || double.IsInfinity(systemPressure) || double.IsInfinity(systemFlowRate) || double.IsInfinity(pressureDrop))229 ResetSystem();230 else231 {232 SystemPressure = systemPressure;233 SystemFlowRate = systemFlowRate;234 SuctionPressureDrop = -pressureDrop;235 }236 }237 }238 public void ResetSystem()239 {240 SuctionPipe = null;241 SystemPressure = 0;242 SystemFlowRate = 0;243 SuctionPressureDrop = 0;244 SuctionPressureDropCalcIterations = 0;245 }246 public void GeneratePdfReport(string path, double poolVolume, double filterDiameter, int? _rpm = null)247 {248 var chartView = new ChartView("");249 chartView.Width = 1692;250 chartView.Height = 1005;251 var powerInput = Pump.GetInputPower(_rpm, SystemFlowRate);252 string pumpName = Pump.ModellName;253 if (_rpm is int rpm)254 {255 pumpName = pumpName + $" @ {rpm} min^-1";256 //powerInput = Pump.GetInputPower((int)rpm, SystemFlowRate);257 var performanceRange = Pump.GetPerformanceRange();258 chartView.AddRange(Pump.ModellName, performanceRange.Item1, performanceRange.Item2);259 }260 chartView.AddCurve(pumpName, Pump.GetPerformanceFlowValues(_rpm), Pump.GetPerformanceHeadValues(_rpm));261 chartView.PowerPoint = new Tuple<double, double>(SystemFlowRate, SystemHead);262 var pklImage = chartView.GetChartImage();263 var filterArea = Math.PI * Math.Pow(filterDiameter, 2) / 400;264 // Create a new PDF document265 var document = new PdfDocument();266 document.Info.CreationDate = DateTime.Now;267 document.Info.Creator = GetTitle();268 if (!CurrentPresets.DisableUserName)269 document.Info.Author = CurrentPresets.UserName;270 document.Info.Title = "FlowCalc Report";271 document.Info.Keywords = "FlowCalc Pumpenkennlinie Volumenstrom Filtergeschwindigkeit";272 document.Info.Subject = $"{Pump.ModellName} @ {SystemHead:f2} mWS";273 274 document.PageLayout = PdfPageLayout.SinglePage;275 276 var pageA4 = new PdfPage();277 var unit = XGraphicsUnit.Millimeter;278 pageA4.Width = new XUnit(210, unit);279 pageA4.Height = new XUnit(297, unit);280 pageA4.Orientation = PdfSharp.PageOrientation.Portrait;281 // Create an empty page282 var page = document.AddPage(pageA4);283 // Get an XGraphics object for drawing284 var gfx = XGraphics.FromPdfPage(page);285 var font = new XFont("Barlow", 11, XFontStyle.Regular);286 #region Frame287 var framePen = new XPen(XColors.Black, 0.7);288 var s = new XPoint(new XUnit(5, unit), new XUnit(5, unit));289 //background290 var headerLeft = new XRect(s, new XPoint(new XUnit(210 / 2, unit), new XUnit(30, unit)));291 var headerBrushLeft = new XLinearGradientBrush(292 new XPoint(new XUnit(5, unit), new XUnit(5, unit)),293 new XPoint(new XUnit(210 / 2, unit), new XUnit(5, unit)),294 XColor.FromArgb(0xff, 0x2e, 0x64),295 XColor.FromArgb(0xe1, 0x00, 0x72)296 );297 var headerRight = new XRect(298 new XPoint(new XUnit(210 / 2, unit), new XUnit(5, unit)),299 new XPoint(new XUnit(205, unit), new XUnit(30, unit))300 );301 var headerBrushRight = new XLinearGradientBrush(302 new XPoint(new XUnit(210 / 2, unit), new XUnit(5, unit)),303 new XPoint(new XUnit(205, unit), new XUnit(5, unit)),304 XColor.FromArgb(0xe1, 0x00, 0x72),305 XColor.FromArgb(0xfa, 0x00, 0x41)306 );307 gfx.DrawRectangle(headerBrushLeft, headerLeft);308 gfx.DrawRectangle(headerBrushRight, headerRight);309 var footer = new XRect(310 new XPoint(new XUnit(5, unit), new XUnit(276, unit)),311 new XPoint(new XUnit(205, unit), new XUnit(292, unit))312 );313 var footerBrush = new XSolidBrush(XColor.FromArgb(0xf7, 0xf8, 0xf9));314 gfx.DrawRectangle(footerBrush, footer);315 var outerFrame = new XRect(s, new XPoint(new XUnit(205, unit), new XUnit(292, unit)));316 gfx.DrawRectangle(framePen, outerFrame);317 gfx.DrawLine(framePen,318 new XPoint(new XUnit(5, unit), new XUnit(30, unit)),319 new XPoint(new XUnit(205, unit), new XUnit(30, unit)));320 gfx.DrawString("FlowCalc Report", new XFont("Barlow", 32, XFontStyle.Bold), XBrushes.White,321 new XRect(s, new XPoint(new XUnit(205, unit), new XUnit(30, unit))),322 XStringFormats.Center);323 int footerCol = 62;324 gfx.DrawLine(framePen,325 new XPoint(new XUnit(5, unit), new XUnit(276, unit)),326 new XPoint(new XUnit(205, unit), new XUnit(276, unit)));327 gfx.DrawLine(framePen,328 new XPoint(new XUnit(footerCol, unit), new XUnit(276, unit)),329 new XPoint(new XUnit(footerCol, unit), new XUnit(292, unit)));330 gfx.DrawLine(framePen,331 new XPoint(new XUnit(210 - footerCol, unit), new XUnit(276, unit)),332 new XPoint(new XUnit(210 - footerCol, unit), new XUnit(292, unit)));333 334 var footerTextBrush = new XSolidBrush(XColor.FromArgb(0x18, 0x19, 0x37));335 var footerArea1 = new XRect(336 new XPoint(new XUnit(5, unit), new XUnit(278, unit)),337 new XPoint(new XUnit(footerCol, unit), new XUnit(284, unit)));338 page.AddWebLink(new PdfRectangle(footerArea1), @"http://www.100prznt.de/");339 gfx.DrawString("www.100prznt.de", font, footerTextBrush,340 footerArea1,341 XStringFormats.Center);342 gfx.DrawString("Elias Ruemmler", font, footerTextBrush,343 new XRect(344 new XPoint(new XUnit(5, unit), new XUnit(284, unit)),345 new XPoint(new XUnit(footerCol, unit), new XUnit(290, unit))),346 XStringFormats.Center);347 gfx.DrawString(GetTitle(), new XFont("Barlow", 16, XFontStyle.Bold), footerTextBrush,348 new XRect(349 new XPoint(new XUnit(footerCol, unit), new XUnit(277, unit)),350 new XPoint(new XUnit(210 - footerCol, unit), new XUnit(284, unit))),351 XStringFormats.Center);352 var footerArea4 = new XRect(353 new XPoint(new XUnit(footerCol, unit), new XUnit(284, unit)),354 new XPoint(new XUnit(210 - footerCol, unit), new XUnit(291, unit)));355 page.AddWebLink(new PdfRectangle(footerArea4), @"http://www.github.com/100prznt/Flowcalc");356 gfx.DrawString("www.github.com/100prznt/FlowCalc", font, footerTextBrush,357 footerArea4,358 XStringFormats.Center);359 if (CurrentPresets.DisableUserName)360 {361 gfx.DrawString(DateTime.Now.ToString(), font, footerTextBrush,362 new XRect(363 new XPoint(new XUnit(210 - footerCol, unit), new XUnit(276, unit)),364 new XPoint(new XUnit(205, unit), new XUnit(292, unit))),365 XStringFormats.Center);366 }367 else368 {369 gfx.DrawString(DateTime.Now.ToString(), font, footerTextBrush,370 new XRect(371 new XPoint(new XUnit(210 - footerCol, unit), new XUnit(278, unit)),372 new XPoint(new XUnit(205, unit), new XUnit(284, unit))),373 XStringFormats.Center);374 gfx.DrawString(CurrentPresets.UserName, font, footerTextBrush,375 new XRect(376 new XPoint(new XUnit(210 - footerCol, unit), new XUnit(284, unit)),377 new XPoint(new XUnit(205, unit), new XUnit(290, unit))),378 XStringFormats.Center);379 }380 #endregion Frame381 var p0 = new XFont("Barlow", 9, XFontStyle.Regular);382 var p = new XFont("Barlow", 10.5, XFontStyle.Regular);383 var h2 = new XFont("Barlow", 17, XFontStyle.Bold);384 var h3 = new XFont("Barlow", 13, XFontStyle.Bold);385 var p3 = new XFont("Barlow", 13, XFontStyle.Regular);386 var t1 = new XUnit(10, unit);387 var t2 = new XUnit(13, unit);388 var t3 = new XUnit(20, unit);389 var t10 = new XUnit(72, unit);390 var t16 = new XUnit(140, unit);391 int yLineH3 = 7;392 int yOffsH3 = -1;393 int yBd = 40;394 gfx.DrawString("System", h2, XBrushes.Black, new XPoint(t1, new XUnit(yBd + yOffsH3, unit)));395 var lineIdx = 1;396 gfx.DrawString("Pumpe:", p3, XBrushes.Black, new XPoint(t2, new XUnit(yBd + yLineH3 * lineIdx++, unit)));397 if (Pump.IsVarioPump)398 gfx.DrawString("Drehzahl:", p3, XBrushes.Black, new XPoint(t2, new XUnit(yBd + yLineH3 * lineIdx++, unit)));399 gfx.DrawString("Filterkessel Durchmesser:", p3, XBrushes.Black, new XPoint(t2, new XUnit(yBd + yLineH3 * lineIdx++, unit)));400 gfx.DrawString("Poolvolumen:", p3, XBrushes.Black, new XPoint(t2, new XUnit(yBd + yLineH3 * lineIdx++, unit)));401 gfx.DrawString("Saugseitige Rohrleitung:", p3, XBrushes.Black, new XPoint(t2, new XUnit(yBd + yLineH3 * lineIdx++, unit)));402 gfx.DrawString("Systemdruck (Filterkessel):", p3, XBrushes.Black, new XPoint(t2, new XUnit(yBd + yLineH3 * lineIdx++, unit)));403 lineIdx = 1;404 if (string.IsNullOrEmpty(Pump.Manufacturer))405 gfx.DrawString($"{Pump.ModellName}", h3, XBrushes.Black, new XPoint(t10, new XUnit(yBd + yLineH3 * lineIdx++, unit)));406 else407 gfx.DrawString($"{Pump.ModellName} ({Pump.Manufacturer})", h3, XBrushes.Black, new XPoint(t10, new XUnit(yBd + yLineH3 * lineIdx++, unit)));408 if (Pump.IsVarioPump)409 gfx.DrawString($"{_rpm} min^-1 (P1 = {powerInput:f3} kW)", h3, XBrushes.Black, new XPoint(t10, new XUnit(yBd + yLineH3 * lineIdx++, unit)));410 gfx.DrawString($"{filterDiameter:f0} mm (A = {filterArea:f1} cm²)", h3, XBrushes.Black, new XPoint(t10, new XUnit(yBd + yLineH3 * lineIdx++, unit)));411 gfx.DrawString($"{poolVolume:f1} m³", h3, XBrushes.Black, new XPoint(t10, new XUnit(yBd + yLineH3 * lineIdx++, unit)));412 if (SuctionPipe != null)413 gfx.DrawString(SuctionPipe.ToString(), h3, XBrushes.Black, new XPoint(t10, new XUnit(yBd + yLineH3 * lineIdx++, unit)));414 else415 gfx.DrawString("nicht angegeben", p3, XBrushes.Black, new XPoint(t10, new XUnit(yBd + yLineH3 * lineIdx++, unit)));416 gfx.DrawString($"{FilterPressure:f2} bar", h3, XBrushes.Black, new XPoint(t10, new XUnit(yBd + yLineH3 * lineIdx++, unit)));417 int yCalc = 89;418 if (Pump.IsVarioPump)419 yCalc = 92;420 gfx.DrawString("Berechnung", h2, XBrushes.Black, new XPoint(t1, new XUnit(yCalc + yOffsH3, unit)));421 gfx.DrawString("Pumpenvordruck:", p3, XBrushes.Black, new XPoint(t2, new XUnit(yCalc + yLineH3, unit)));422 gfx.DrawString("Förderhöhe:", p3, XBrushes.Black, new XPoint(t2, new XUnit(yCalc + yLineH3 * 2, unit)));423 gfx.DrawString("Volumenstrom:", p3, XBrushes.Black, new XPoint(t2, new XUnit(yCalc + yLineH3 * 3, unit)));424 gfx.DrawString("Arbeitspunkt auf Pumpenkennlinie", p3, XBrushes.Black, new XPoint(t2, new XUnit(yCalc + yLineH3 * 4, unit)));425 if (SuctionPipe != null)426 gfx.DrawString($"{SuctionPressureDrop:f3} bar", h3, XBrushes.Black, new XPoint(t10, new XUnit(yCalc + yLineH3, unit)));427 else428 gfx.DrawString("0 bar (nicht berechnet)", p3, XBrushes.Black, new XPoint(t10, new XUnit(yCalc + yLineH3, unit)));429 gfx.DrawString($"{SystemHead:f2} mWS ({SystemPressure:f3} bar)", h3, XBrushes.Black, new XPoint(t10, new XUnit(yCalc + yLineH3 * 2, unit)));430 gfx.DrawString($"{SystemFlowRate:f2} m³/h", h3, XBrushes.Black, new XPoint(t10, new XUnit(yCalc + yLineH3 * 3, unit)));431 var stream = new MemoryStream();432 ImageCodecInfo pngEncoder = GetEncoder(ImageFormat.Png);433 System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality;434 EncoderParameters myEncoderParameters = new EncoderParameters(1);435 EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 100L);436 myEncoderParameters.Param[0] = myEncoderParameter;437 pklImage.Save(stream, pngEncoder, myEncoderParameters);438 stream.Position = 0;439 var pkl = XImage.FromStream(stream);440 var imageFrame = new XRect(441 new XPoint(t3, new XUnit(yCalc + 32, unit)),442 new XPoint(new XUnit(180, unit), new XUnit(yCalc + 127, unit)));443 gfx.DrawImage(pkl, imageFrame);444 var filter = new Pipe(1, filterDiameter, 0.01);445 var filterSpeed = filter.CalcFlowVelocity(SystemFlowRate) * 3600;446 var filterSpeedBrush = XBrushes.Green;447 if (Pump.IsVarioPump)448 filterSpeedBrush = XBrushes.DarkGray;449 else if (filterSpeed > 60 || filterSpeed < 40)450 filterSpeedBrush = XBrushes.Red;451 else if (filterSpeed > 55 || filterSpeed < 45)452 filterSpeedBrush = XBrushes.Orange;453 var tCycle1 = TimeSpan.FromHours(poolVolume / SystemFlowRate);454 var tCycle3 = TimeSpan.FromHours(poolVolume / SystemFlowRate *3);455 int yRes = 220;456 gfx.DrawString("Auswertung", h2, XBrushes.Black, new XPoint(t1, new XUnit(yRes + yOffsH3, unit)));457 gfx.DrawString("Umwälzzeiten", p3, XBrushes.Black, new XPoint(t2, new XUnit(yRes + yLineH3, unit)));458 gfx.DrawString("1-fach:", p3, XBrushes.Black, new XPoint(t10 - 50, new XUnit(yRes + yLineH3, unit)));459 gfx.DrawString("3-fach:", p3, XBrushes.Black, new XPoint(t10 - 50, new XUnit(yRes + yLineH3 * 2, unit)));460 gfx.DrawString("Filtergeschwindigkeit:", p3, XBrushes.Black, new XPoint(t2, new XUnit(yRes + yLineH3 * 3, unit)));461 if (tCycle1.TotalHours > 24)462 gfx.DrawString($"> 24 Stunden", h3, XBrushes.Red, new XPoint(t10, new XUnit(yRes + yLineH3, unit)));463 else464 {465 gfx.DrawString($"{tCycle1.Hours} Stunden {tCycle1.Minutes} Minuten", h3, XBrushes.Black, new XPoint(t10, new XUnit(yRes + yLineH3, unit)));466 if (powerInput > 0)467 gfx.DrawString($"({tCycle1.TotalHours * powerInput:f1} kWh)", h3, XBrushes.Black, new XPoint(t16, new XUnit(yRes + yLineH3, unit)));468 }469 if (tCycle3.TotalHours > 24)470 gfx.DrawString($"> 24 Stunden", h3, XBrushes.Red, new XPoint(t10, new XUnit(yRes + yLineH3 * 2, unit)));471 else472 {473 gfx.DrawString($"{tCycle3.Hours} Stunden {tCycle3.Minutes} Minuten", h3, XBrushes.Black, new XPoint(t10, new XUnit(yRes + yLineH3 * 2, unit)));474 if (powerInput > 0)475 gfx.DrawString($"({tCycle3.TotalHours * powerInput:f1} kWh)", h3, XBrushes.Black, new XPoint(t16, new XUnit(yRes + yLineH3 * 2, unit)));476 }477 gfx.DrawString($"{filterSpeed:f2} m/h", h3, filterSpeedBrush, new XPoint(t10, new XUnit(yRes + yLineH3 * 3, unit)));478 var tf = new XTextFormatter(gfx);479 tf.DrawString("Im privaten Poolbereich sollte die Filtergeschwindigkeit nicht über 50 m/h betragen.\r\n" + 480 "Mit einer langsameren Filtergeschwindigkeit von rund 30 m/h würde das Ergebnis der Filtration zwar verbessert werden. " +481 "Jedoch sind für Rückspülung (Reinigung des Filters) Spülgeschwindigkeiten von 50-60 m/h erforderlich. Da die Filterpumpe " +482 "in privaten Pool für Filtration und Rückspülung ausgelegt wird, wählt man als Kompromiss eine Filtergeschwindigkeit um 50 m/h.\r\n" +483 "Bei der tatsächlichen Laufzeit der Pumpe gilt es zu beachten, dass das Poolwasser am Tag eine gewisse Zeit bewegt werden sollte. Ein "+484 "guter Richtwert für eine Untergrenze wären 8 Stunden, unabhängig von der berechneten Umwälzzeit.",485 p0, XBrushes.Black,486 new XRect(487 new XPoint(t2, new XUnit(yRes + yLineH3 * 4, unit)),488 new XPoint(new XUnit(200, unit), new XUnit(276, unit))),489 XStringFormats.TopLeft);490 // Save the document491 document.Save(path);492 // Start a viewer.493 Process.Start(path);494 }495 #endregion Services496 #region Internal services497 public string GetTitle()498 {499#if DEBUG500 return typeof(MainView).Assembly.GetName().Name + " [DEBUG]";501#else502 var versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location);503 return string.Concat(typeof(MainView).Assembly.GetName().Name, " ", versionInfo.ProductVersion);504#endif505 }506 private ImageCodecInfo GetEncoder(ImageFormat format)507 {508 ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();509 foreach (ImageCodecInfo codec in codecs)510 {511 if (codec.FormatID == format.Guid)512 {513 return codec;514 }515 }516 return null;517 }518 #endregion Internal services519 #region Events520 public Action NewPumpLoaded;521 #endregion Events522 #region INotifyPropertyChanged Member523 /// <summary>524 /// Helpmethod, to call the <see cref="PropertyChanged"/> event525 /// </summary>526 /// <param name="propName">Name of changed property</param>527 protected void PropChanged([CallerMemberName] string propName = null)528 {529 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));530 }531 /// <summary>532 /// Updated property values available533 /// </summary>534 public event PropertyChangedEventHandler PropertyChanged;535 #endregion536 }537}...

Full Screen

Full Screen

XUnit.cs

Source:XUnit.cs Github

copy

Full Screen

1#region PDFsharp - A .NET library for processing PDF2//3// Authors:4// Stefan Lange (mailto:Stefan.Lange@pdfsharp.com)5//6// Copyright (c) 2005-2009 empira Software GmbH, Cologne (Germany)7//8// http://www.pdfsharp.com9// http://sourceforge.net/projects/pdfsharp10//11// Permission is hereby granted, free of charge, to any person obtaining a12// copy of this software and associated documentation files (the "Software"),13// to deal in the Software without restriction, including without limitation14// the rights to use, copy, modify, merge, publish, distribute, sublicense,15// and/or sell copies of the Software, and to permit persons to whom the16// Software is furnished to do so, subject to the following conditions:17//18// The above copyright notice and this permission notice shall be included19// in all copies or substantial portions of the Software.20//21// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR22// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,23// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL24// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER25// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING26// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 27// DEALINGS IN THE SOFTWARE.28#endregion29using System;30using System.Diagnostics;31using System.Globalization;32namespace PdfSharp.Drawing33{34 /// <summary>35 /// Represents a value and its unit of measure. The structure converts implicitly from and to36 /// double with a value measured in point.37 /// </summary>38 public struct XUnit : IFormattable39 {40 internal const double PointFactor = 1;41 internal const double InchFactor = 72;42 internal const double MillimeterFactor = 72 / 25.4;43 internal const double CentimeterFactor = 72 / 2.54;44 internal const double PresentationFactor = 72 / 96.0;45 internal const double PointFactorWpf = 96 / 72.0;46 internal const double InchFactorWpf = 96;47 internal const double MillimeterFactorWpf = 96 / 25.4;48 internal const double CentimeterFactorWpf = 96 / 2.54;49 internal const double PresentationFactorWpf = 1;50 /// <summary>51 /// Initializes a new instance of the XUnit class with type set to point.52 /// </summary>53 public XUnit(double point)54 {55 this.value = point;56 this.type = XGraphicsUnit.Point;57 }58 /// <summary>59 /// Initializes a new instance of the XUnit class.60 /// </summary>61 public XUnit(double value, XGraphicsUnit type)62 {63 if (!Enum.IsDefined(typeof(XGraphicsUnit), type))64#if !SILVERLIGHT65 throw new System.ComponentModel.InvalidEnumArgumentException("type");66#else67 throw new ArgumentException("type");68#endif69 this.value = value;70 this.type = type;71 }72 /// <summary>73 /// Gets the raw value of the object without any conversion.74 /// To determine the XGraphicsUnit use property <code>Type</code>.75 /// To get the value in point use the implicit conversion to double.76 /// </summary>77 public double Value78 {79 get { return this.value; }80 }81 /// <summary>82 /// Gets the unit of measure.83 /// </summary>84 public XGraphicsUnit Type85 {86 get { return this.type; }87 }88 /// <summary>89 /// Gets or sets the value in point.90 /// </summary>91 public double Point92 {93 get94 {95 switch (type)96 {97 case XGraphicsUnit.Point:98 return this.value;99 case XGraphicsUnit.Inch:100 return this.value * 72;101 case XGraphicsUnit.Millimeter:102 return this.value * 72 / 25.4;103 case XGraphicsUnit.Centimeter:104 return this.value * 72 / 2.54;105 case XGraphicsUnit.Presentation:106 return this.value * 72 / 96;107 default:108 throw new InvalidCastException();109 }110 }111 set112 {113 this.value = value;114 this.type = XGraphicsUnit.Point;115 }116 }117 /// <summary>118 /// Gets or sets the value in inch.119 /// </summary>120 public double Inch121 {122 get123 {124 switch (type)125 {126 case XGraphicsUnit.Point:127 return this.value / 72;128 case XGraphicsUnit.Inch:129 return this.value;130 case XGraphicsUnit.Millimeter:131 return this.value / 25.4;132 case XGraphicsUnit.Centimeter:133 return this.value / 2.54;134 case XGraphicsUnit.Presentation:135 return this.value / 96;136 default:137 throw new InvalidCastException();138 }139 }140 set141 {142 this.value = value;143 this.type = XGraphicsUnit.Inch;144 }145 }146 /// <summary>147 /// Gets or sets the value in millimeter.148 /// </summary>149 public double Millimeter150 {151 get152 {153 switch (this.type)154 {155 case XGraphicsUnit.Point:156 return this.value * 25.4 / 72;157 case XGraphicsUnit.Inch:158 return this.value * 25.4;159 case XGraphicsUnit.Millimeter:160 return this.value;161 case XGraphicsUnit.Centimeter:162 return this.value * 10;163 case XGraphicsUnit.Presentation:164 return this.value * 25.4 / 96;165 default:166 throw new InvalidCastException();167 }168 }169 set170 {171 this.value = value;172 this.type = XGraphicsUnit.Millimeter;173 }174 }175 /// <summary>176 /// Gets or sets the value in centimeter.177 /// </summary>178 public double Centimeter179 {180 get181 {182 switch (type)183 {184 case XGraphicsUnit.Point:185 return this.value * 2.54 / 72;186 case XGraphicsUnit.Inch:187 return this.value * 2.54;188 case XGraphicsUnit.Millimeter:189 return this.value / 10;190 case XGraphicsUnit.Centimeter:191 return this.value;192 case XGraphicsUnit.Presentation:193 return this.value * 2.54 / 96;194 default:195 throw new InvalidCastException();196 }197 }198 set199 {200 this.value = value;201 this.type = XGraphicsUnit.Centimeter;202 }203 }204 /// <summary>205 /// Gets or sets the value in presentation units (1/96 inch).206 /// </summary>207 public double Presentation208 {209 get210 {211 switch (type)212 {213 case XGraphicsUnit.Point:214 return this.value * 96 / 72;215 case XGraphicsUnit.Inch:216 return this.value * 96;217 case XGraphicsUnit.Millimeter:218 return this.value * 96 / 25.4;219 case XGraphicsUnit.Centimeter:220 return this.value * 96 / 2.54;221 case XGraphicsUnit.Presentation:222 return this.value;223 default:224 throw new InvalidCastException();225 }226 }227 set228 {229 this.value = value;230 this.type = XGraphicsUnit.Point;231 }232 }233 /// <summary>234 /// Returns the object as string using the format information.235 /// The unit of measure is appended to the end of the string.236 /// </summary>237 public string ToString(IFormatProvider formatProvider)238 {239 string valuestring;240 valuestring = this.value.ToString(formatProvider) + GetSuffix();241 return valuestring;242 }243 /// <summary>244 /// Returns the object as string using the specified format and format information.245 /// The unit of measure is appended to the end of the string.246 /// </summary>247 string IFormattable.ToString(string format, IFormatProvider formatProvider)248 {249 string valuestring;250 valuestring = this.value.ToString(format, formatProvider) + GetSuffix();251 return valuestring;252 }253 /// <summary>254 /// Returns the object as string. The unit of measure is appended to the end of the string.255 /// </summary>256 public override string ToString()257 {258 string valuestring;259 valuestring = this.value.ToString(CultureInfo.InvariantCulture) + GetSuffix();260 return valuestring;261 }262 /// <summary>263 /// Returns the unit of measure of the object as a string like 'pt', 'cm', or 'in'.264 /// </summary>265 string GetSuffix()266 {267 switch (type)268 {269 case XGraphicsUnit.Point:270 return "pt";271 case XGraphicsUnit.Inch:272 return "in";273 case XGraphicsUnit.Millimeter:274 return "mm";275 case XGraphicsUnit.Centimeter:276 return "cm";277 case XGraphicsUnit.Presentation:278 return "pu";279 //case XGraphicsUnit.Pica:280 // return "pc";281 //case XGraphicsUnit.Line:282 // return "li";283 default:284 throw new InvalidCastException();285 }286 }287 /// <summary>288 /// Returns an XUnit object. Sets type to point.289 /// </summary>290 public static XUnit FromPoint(double value)291 {292 XUnit unit;293 unit.value = value;294 unit.type = XGraphicsUnit.Point;295 return unit;296 }297 /// <summary>298 /// Returns an XUnit object. Sets type to inch.299 /// </summary>300 public static XUnit FromInch(double value)301 {302 XUnit unit;303 unit.value = value;304 unit.type = XGraphicsUnit.Inch;305 return unit;306 }307 /// <summary>308 /// Returns an XUnit object. Sets type to millimeters.309 /// </summary>310 public static XUnit FromMillimeter(double value)311 {312 XUnit unit;313 unit.value = value;314 unit.type = XGraphicsUnit.Millimeter;315 return unit;316 }317 /// <summary>318 /// Returns an XUnit object. Sets type to centimeters.319 /// </summary>320 public static XUnit FromCentimeter(double value)321 {322 XUnit unit;323 unit.value = value;324 unit.type = XGraphicsUnit.Centimeter;325 return unit;326 }327 /// <summary>328 /// Returns an XUnit object. Sets type to Presentation.329 /// </summary>330 public static XUnit FromPresentation(double value)331 {332 XUnit unit;333 unit.value = value;334 unit.type = XGraphicsUnit.Presentation;335 return unit;336 }337#if deferred338 ///// <summary>339 ///// Returns an XUnit object. Sets type to pica.340 ///// </summary>341 //public static XUnit FromPica(double val)342 //{343 // XUnit unit;344 // unit.val = val;345 // unit.type = XGraphicsUnit.Pica;346 // return unit;347 //}348 //349 ///// <summary>350 ///// Returns an XUnit object. Sets type to line.351 ///// </summary>352 //public static XUnit FromLine(double val)353 //{354 // XUnit unit;355 // unit.val = val;356 // unit.type = XGraphicsUnit.Line;357 // return unit;358 //}359#endif360 /// <summary>361 /// Converts a string to an XUnit object.362 /// If the string contains a suffix like 'cm' or 'in' the object will be converted363 /// to the appropriate type, otherwise point is assumed.364 /// </summary>365 public static implicit operator XUnit(string value)366 {367 XUnit unit;368 value = value.Trim();369 // HACK for Germans...370 value = value.Replace(',', '.');371 int count = value.Length;372 int valLen = 0;373 for (; valLen < count; )374 {375 char ch = value[valLen];376 if (ch == '.' || ch == '-' || ch == '+' || Char.IsNumber(ch))377 valLen++;378 else379 break;380 }381 try382 {383 unit.value = Double.Parse(value.Substring(0, valLen).Trim(), CultureInfo.InvariantCulture);384 }385 catch (Exception ex)386 {387 unit.value = 1;388 string message = String.Format("String '{0}' is not a valid value for structure 'XUnit'.", value);389 throw new ArgumentException(message, ex);390 }391 string typeStr = value.Substring(valLen).Trim().ToLower();392 unit.type = XGraphicsUnit.Point;393 switch (typeStr)394 {395 case "cm":396 unit.type = XGraphicsUnit.Centimeter;397 break;398 case "in":399 unit.type = XGraphicsUnit.Inch;400 break;401 case "mm":402 unit.type = XGraphicsUnit.Millimeter;403 break;404 //case "pc":405 // unit.type = XGraphicsUnit.Pica;406 // break;407 //408 //case "li":409 // unit.type = XGraphicsUnit.Line;410 // break;411 case "":412 case "pt":413 unit.type = XGraphicsUnit.Point;414 break;415 case "pu": // presentation units416 unit.type = XGraphicsUnit.Presentation;417 break;418 default:419 throw new ArgumentException("Unknown unit type: '" + typeStr + "'");420 }421 return unit;422 }423 /// <summary>424 /// Converts an int to an XUnit object with type set to point.425 /// </summary>426 public static implicit operator XUnit(int value)427 {428 XUnit unit;429 unit.value = value;430 unit.type = XGraphicsUnit.Point;431 return unit;432 }433 /// <summary>434 /// Converts a double to an XUnit object with type set to point.435 /// </summary>436 public static implicit operator XUnit(double value)437 {438 XUnit unit;439 unit.value = value;440 unit.type = XGraphicsUnit.Point;441 return unit;442 }443 /// <summary>444 /// Returns a double value as point.445 /// </summary>446 public static implicit operator double(XUnit value)447 {448 return value.Point;449 }450 /// <summary>451 /// Memberwise comparison. To compare by value, 452 /// use code like Math.Abs(a.Pt - b.Pt) &lt; 1e5.453 /// </summary>454 public static bool operator ==(XUnit value1, XUnit value2)455 {456 return value1.type == value2.type && value1.value == value2.value;457 }458 /// <summary>459 /// Memberwise comparison. To compare by value, 460 /// use code like Math.Abs(a.Pt - b.Pt) &lt; 1e5.461 /// </summary>462 public static bool operator !=(XUnit value1, XUnit value2)463 {464 return !(value1 == value2);465 }466 /// <summary>467 /// Calls base class Equals.468 /// </summary>469 public override bool Equals(Object obj)470 {471 if (obj is XUnit)472 return this == (XUnit)obj;473 return false;474 }475 /// <summary>476 /// Returns the hash code for this instance.477 /// </summary>478 public override int GetHashCode()479 {480 return this.value.GetHashCode() ^ this.type.GetHashCode();481 }482 /// <summary>483 /// This member is intended to be used by XmlDomainObjectReader only.484 /// </summary>485 public static XUnit Parse(string value)486 {487 XUnit unit = value;488 return unit;489 }490 /// <summary>491 /// Converts an existing object from one unit into another unit type.492 /// </summary>493 public void ConvertType(XGraphicsUnit type)494 {495 if (this.type == type)496 return;497 switch (type)498 {499 case XGraphicsUnit.Point:500 this.value = Point;501 this.type = XGraphicsUnit.Point;502 break;503 case XGraphicsUnit.Inch:504 this.value = Inch;505 this.type = XGraphicsUnit.Inch;506 break;507 case XGraphicsUnit.Centimeter:508 this.value = Centimeter;509 this.type = XGraphicsUnit.Centimeter;510 break;511 case XGraphicsUnit.Millimeter:512 this.value = Millimeter;513 this.type = XGraphicsUnit.Millimeter;514 break;515 case XGraphicsUnit.Presentation:516 this.value = Presentation;517 this.type = XGraphicsUnit.Presentation;518 break;519 // case XGraphicsUnit.Pica:520 // this.value = this.Pc;521 // this.type = XGraphicsUnit.Pica;522 // break;523 // 524 // case XGraphicsUnit.Line:525 // this.value = this.Li;526 // this.type = XGraphicsUnit.Line;527 // break;528 default:529 throw new ArgumentException("Unknown unit type: '" + type + "'");530 }531 }532 /// <summary>533 /// Represents a unit with all values zero.534 /// </summary>535 public static readonly XUnit Zero;536 double value;537 XGraphicsUnit type;538#if true_539 /// <summary>540 /// Some test code.541 /// </summary>542 [Conditional("DEBUG")]543 public static void TestIt()544 {545 double v;546 XUnit u1 = 1000;547 v = u1;548 v = u1.Point;549 v = u1.Inch;550 v = u1.Millimeter;551 v = u1.Centimeter;552 v = u1.Presentation;553 u1 = "10cm";554 v = u1.Point;555 v.GetType();556 }557#endif558 }559}...

Full Screen

Full Screen

MatrixDecompositionTest.cs

Source:MatrixDecompositionTest.cs Github

copy

Full Screen

1using MyX3DParser.Generated;2using MyX3DParser.Generated.Model.DataTypes;3using System;4using System.Collections.Generic;5using System.Diagnostics;6using System.Globalization;7using Xunit;8using Xunit.Abstractions;9using Xunit.Sdk;10namespace MyX3DParser.Tests11{12 public class MatrixDecompositionTest13 {14 private const int Precision = 1;15 private static readonly float PrecisionEps = (float)(1.0 / Math.Pow(10, Precision));16 private ITestOutputHelper output;17 public MatrixDecompositionTest(ITestOutputHelper output)18 {19 this.output = output;20 }21 [Theory(Skip ="Decomposer does not give valid data when mirror is in place")]22 [MemberData(nameof(RegressionData))]23 public void Test(string _,XunitVector3 rotation1, XunitVector3 scaleOrientation1, XunitVector3 scale1)24 {25 var matrix1 = GetMatrix(Quaternion.Euler(rotation1.x, rotation1.y, rotation1.z), Quaternion.Euler(scaleOrientation1.x, scaleOrientation1.y, scaleOrientation1.z), new Vec3f(scale1.x, scale1.y, scale1.z));26 var (translation2,rotation2, scale2, scaleOrientation2) = matrix1.Decompose();27 var matrix2 = GetMatrix(rotation2, scaleOrientation2, scale2);28 try29 {30 AssertEqual(Vec3f.ConstantValue_0_0_0, translation2);31 AssertEqual(matrix1, matrix2);32 }33 catch (EqualException)34 {35 output.WriteLine($"rotation IN {Quaternion.Euler(rotation1.x, rotation1.y, rotation1.z)}");36 output.WriteLine($"rotation OUT {rotation2}");37 output.WriteLine($"scaleOrientation IN {Quaternion.Euler(scaleOrientation1.x, scaleOrientation1.y, scaleOrientation1.z)}");38 output.WriteLine($"scaleOrientation OUT {scaleOrientation2}");39 output.WriteLine($"scale IN {scale1}");40 output.WriteLine($"scale OUT {scale2}");41 output.WriteLine($"translation IN {Vec3f.ConstantValue_0_0_0}");42 output.WriteLine($"translation OUT {translation2}");43 throw;44 }45 //AssertEqual(new Vec3f(1, 2, 3), translation);46 //AssertEqual(new Vec3f(0.5f, 0.25f, -0.1f), scale);47 //AssertEqual(Quaternion.Euler(210, 232, 270), rotation);48 //AssertEqual(Quaternion.Identity, scaleOrientation);49 //Assert.Equal(-1f, determinant);50 }51 public static IEnumerable<object[]> RegressionData52 {53 get54 {55 yield return new object[] {"identity",new XunitVector3(0f, 0f, 0f), new XunitVector3(0f, 0f, 0f), new XunitVector3(1f, 1f, 1f) };56 yield return new object[] {"mirrorX",new XunitVector3(0f, 0f, 0f), new XunitVector3 (0f, 0f, 0f), new XunitVector3 (-1f, 1f, 1f) };57 yield return new object[] {"RS",new XunitVector3(0f, 45f, 0f), new XunitVector3(0f, 0f, 0f), new XunitVector3(0.5f, 0.25f, 0.1f) };58 yield return new object[] { "ScaledOrientation", new XunitVector3(0f, 0f, 0f), new XunitVector3(0, 32, 0), new XunitVector3(0.5f, 0.25f, 0.1f) };59 yield return new object[] { "ScaledOrientation+mirrorX", new XunitVector3(0f, 0f, 0f), new XunitVector3(1, 32, 0), new XunitVector3(-0.5f, 0.25f, 0.1f) };60 yield return new object[] {"RS+mirrorZ",new XunitVector3(10f, 32f, 70f), new XunitVector3 (0f, 0f, 0f), new XunitVector3(0.5f, 0.25f, -0.1f) };61 yield return new object[] {"RS+mirrorY",new XunitVector3(10f, 32f, 70f), new XunitVector3 (0f, 0f, 0f), new XunitVector3(0.5f, -0.25f, 0.1f) };62 yield return new object[] {"RS+mirrorX",new XunitVector3(10f, 32f, 70f), new XunitVector3 (0f, 0f, 0f), new XunitVector3(-0.5f, 0.25f, 0.1f) };63 yield return new object[] {"RS+mirrorXY",new XunitVector3(10f, 32f, 70f), new XunitVector3 (0f, 0f, 0f), new XunitVector3(-0.5f, -0.25f, 0.1f) };64 yield return new object[] {"RS+mirrorYZ",new XunitVector3(10f, 32f, 70f), new XunitVector3 (0f, 0f, 0f), new XunitVector3(0.5f, -0.25f, -0.1f) };65 yield return new object[] {"RS+mirrorXZ",new XunitVector3(10f, 32f, 70f), new XunitVector3 (0f, 0f, 0f), new XunitVector3(-0.5f, 0.25f, -0.1f) };66 yield return new object[] { "RS+mirrorXYZ", new XunitVector3(10f, 32f, 70f), new XunitVector3(0f, 0f, 0f), new XunitVector3(-0.5f, -0.25f, -0.1f) };67 yield return new object[] { "R+mirrorX", new XunitVector3(0f, 32f, 0f), new XunitVector3(0f, 0f, 0f), new XunitVector3(-1f, 1f, 1f) };68 yield return new object[] {"Rotation>180",new XunitVector3(210f, 232f, 270f),new XunitVector3 (0f, 0f, 0f), new XunitVector3(0.5f, 0.25f, 0.1f) };69 var rand = new Random(1213);70 for (int i = 0; i < 50; i++)71 {72 yield return new object[] { $"randRot_{i}", new XunitVector3(GetRandAngle(rand), GetRandAngle(rand), GetRandAngle(rand)), new XunitVector3(1, 1, 1), new XunitVector3(0, 0, 0) };73 }74 rand = new Random(1213);75 for (int i = 0; i < 50; i++)76 {77 yield return new object[] { $"randScale_{i}", new XunitVector3(0, 0, 0), new XunitVector3(0, 0, 0), new XunitVector3(GetRandScale(rand), GetRandScale(rand), GetRandScale(rand)) };78 }79 rand = new Random(1213);80 for (int i = 0; i < 50; i++)81 {82 yield return new object[] { $"randOrientedScale_{i}", new XunitVector3(0, 0, 0), new XunitVector3(GetRandAngle(rand), GetRandAngle(rand), GetRandAngle(rand)), new XunitVector3(GetRandScale(rand), GetRandScale(rand), GetRandScale(rand)) };83 }84 rand = new Random(1213);85 for (int i = 0; i < 50; i++)86 {87 yield return new object[] { $"rand_{i}", new XunitVector3(GetRandAngle(rand), GetRandAngle(rand), GetRandAngle(rand)), new XunitVector3(GetRandAngle(rand), GetRandAngle(rand), GetRandAngle(rand)), new XunitVector3(GetRandScale(rand), GetRandScale(rand), GetRandScale(rand)) };88 }89 }90 }91 private static float GetRandAngle(Random rand)92 {93 return (float)Math.Round((rand.NextDouble() - 0.5) * 720, 2);94 }95 private static float GetRandScale(Random rand)96 {97 return (float)Math.Round((rand.NextDouble() - 0.5) * 10, 2);98 }99 public class XunitVector3: IXunitSerializable100 {101 public float x;102 public float y;103 public float z;104 public XunitVector3()105 {106 }107 public XunitVector3(float x, float y, float z)108 {109 this.x = x;110 this.y = y;111 this.z = z;112 }113 public void Deserialize(IXunitSerializationInfo info)114 {115 x = info.GetValue<float>(nameof(x));116 y = info.GetValue<float>(nameof(y));117 z = info.GetValue<float>(nameof(z));118 }119 public void Serialize(IXunitSerializationInfo info)120 {121 info.AddValue(nameof(x), x);122 info.AddValue(nameof(y), y);123 info.AddValue(nameof(z), z);124 }125 public override string ToString()126 {127 return $"{x}; {y}; {z}";128 }129 }130 private void AssertEqual(Vec3f expectedValue, Vec3f result)131 {132 try133 {134 Assert.Equal(expectedValue.X, result.X, Precision);135 Assert.Equal(expectedValue.Y, result.Y, Precision);136 Assert.Equal(expectedValue.Z, result.Z, Precision);137 }138 catch (EqualException)139 {140 throw new EqualException($"{ToRoundedString(expectedValue.X)},{ToRoundedString(expectedValue.Y)},{ToRoundedString(expectedValue.Z)} (rounded from {expectedValue})", $"{ToRoundedString(result.X)},{ToRoundedString(result.Y)},{ToRoundedString(result.Z)} (rounded from {result})");141 }142 }143 private void AssertEqual(Quaternion expectedValue, Quaternion result)144 {145 try146 {147 Assert.Equal(expectedValue.X, result.X, Precision);148 Assert.Equal(expectedValue.Y, result.Y, Precision);149 Assert.Equal(expectedValue.Z, result.Z, Precision);150 Assert.Equal(expectedValue.W, result.W, Precision);151 }152 catch (EqualException)153 {154 throw new EqualException($"{ToRoundedString(Quaternion.ToEulerAngles(expectedValue))} (rounded from {expectedValue})", $"{ToRoundedString(Quaternion.ToEulerAngles(result))} (rounded from {result})");155 }156 }157 private void AssertEqual(Matrix4f expectedValue, Matrix4f result)158 {159 try160 {161 var diff = Diff(expectedValue, result);162 Assert.True(diff< PrecisionEps);163 }164 catch (EqualException)165 {166 throw new EqualException($"~{expectedValue}", $"~{result}");167 }168 }169 private static float Diff(Matrix4f mat1, Matrix4f mat2)170 {171 var sum = 0f;172 sum += Math.Abs(mat1.M00 - mat2.M00);173 sum += Math.Abs(mat1.M01 - mat2.M01);174 sum += Math.Abs(mat1.M02 - mat2.M02);175 sum += Math.Abs(mat1.M03 - mat2.M03);176 sum += Math.Abs(mat1.M10 - mat2.M10);177 sum += Math.Abs(mat1.M11 - mat2.M11);178 sum += Math.Abs(mat1.M12 - mat2.M12);179 sum += Math.Abs(mat1.M13 - mat2.M13);180 sum += Math.Abs(mat1.M20 - mat2.M20);181 sum += Math.Abs(mat1.M21 - mat2.M21);182 sum += Math.Abs(mat1.M22 - mat2.M22);183 sum += Math.Abs(mat1.M23 - mat2.M23);184 sum += Math.Abs(mat1.M30 - mat2.M30);185 sum += Math.Abs(mat1.M31 - mat2.M31);186 sum += Math.Abs(mat1.M32 - mat2.M32);187 sum += Math.Abs(mat1.M33 - mat2.M33);188 return sum;189 }190 private static string ToRoundedString(Vec3f value)191 {192 return $"{ToRoundedString(value.X)},{ToRoundedString(value.Y)},{ToRoundedString(value.Z)}";193 }194 private static string ToRoundedString(float v)195 {196 return Math.Round(v, Precision).ToString(CultureInfo.InvariantCulture);197 }198 private Matrix4f GetMatrix(Quaternion rotation, Quaternion scaleOrientation, Vec3f scale)199 {200 var rotationMat = Matrix4f.Rotate(rotation);201 var scaleOrientationMat = Matrix4f.Rotate(scaleOrientation);202 var scaleOrientationInverseMat = Matrix4f.Rotate(Quaternion.Inverse(scaleOrientation));203 var scaleMat = Matrix4f.Scale(scale);204 return rotationMat * scaleOrientationMat * scaleMat * scaleOrientationInverseMat ;205 }206 }207}...

Full Screen

Full Screen

TestFrameworkExecutor.cs

Source:TestFrameworkExecutor.cs Github

copy

Full Screen

1// Licensed to Elasticsearch B.V under one or more agreements.2// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.3// See the LICENSE file in the project root for more information4using System;5using System.Collections.Generic;6using System.Linq;7using System.Reflection;8using Elastic.Elasticsearch.Managed;9using Xunit.Abstractions;10using Xunit.Sdk;11namespace Elastic.Elasticsearch.Xunit.Sdk12{13 internal class TestFrameworkExecutor : XunitTestFrameworkExecutor14 {15 public TestFrameworkExecutor(AssemblyName a, ISourceInformationProvider sip, IMessageSink d) : base(a, sip, d)16 {17 }18 public ElasticXunitRunOptions Options { get; set; }19 public override void RunAll(IMessageSink executionMessageSink, ITestFrameworkDiscoveryOptions discoveryOptions,20 ITestFrameworkExecutionOptions executionOptions)21 {22 discoveryOptions.SetValue(nameof(ElasticXunitRunOptions.Version), Options.Version);23 discoveryOptions.SetValue(nameof(ElasticXunitRunOptions.RunIntegrationTests), Options.RunIntegrationTests);24 discoveryOptions.SetValue(nameof(ElasticXunitRunOptions.IntegrationTestsMayUseAlreadyRunningNode),25 Options.IntegrationTestsMayUseAlreadyRunningNode);26 discoveryOptions.SetValue(nameof(ElasticXunitRunOptions.RunUnitTests), Options.RunUnitTests);27 discoveryOptions.SetValue(nameof(ElasticXunitRunOptions.TestFilter), Options.TestFilter);28 discoveryOptions.SetValue(nameof(ElasticXunitRunOptions.ClusterFilter), Options.ClusterFilter);29 executionOptions.SetValue(nameof(ElasticXunitRunOptions.Version), Options.Version);30 executionOptions.SetValue(nameof(ElasticXunitRunOptions.RunIntegrationTests), Options.RunIntegrationTests);31 executionOptions.SetValue(nameof(ElasticXunitRunOptions.IntegrationTestsMayUseAlreadyRunningNode),32 Options.IntegrationTestsMayUseAlreadyRunningNode);33 executionOptions.SetValue(nameof(ElasticXunitRunOptions.RunUnitTests), Options.RunUnitTests);34 executionOptions.SetValue(nameof(ElasticXunitRunOptions.TestFilter), Options.TestFilter);35 executionOptions.SetValue(nameof(ElasticXunitRunOptions.ClusterFilter), Options.ClusterFilter);36 base.RunAll(executionMessageSink, discoveryOptions, executionOptions);37 }38 public override void RunTests(IEnumerable<ITestCase> testCases, IMessageSink executionMessageSink,39 ITestFrameworkExecutionOptions executionOptions)40 {41 executionOptions.SetValue(nameof(ElasticXunitRunOptions.Version), Options.Version);42 executionOptions.SetValue(nameof(ElasticXunitRunOptions.RunIntegrationTests), Options.RunIntegrationTests);43 executionOptions.SetValue(nameof(ElasticXunitRunOptions.IntegrationTestsMayUseAlreadyRunningNode),44 Options.IntegrationTestsMayUseAlreadyRunningNode);45 executionOptions.SetValue(nameof(ElasticXunitRunOptions.RunUnitTests), Options.RunUnitTests);46 executionOptions.SetValue(nameof(ElasticXunitRunOptions.TestFilter), Options.TestFilter);47 executionOptions.SetValue(nameof(ElasticXunitRunOptions.ClusterFilter), Options.ClusterFilter);48 base.RunTests(testCases, executionMessageSink, executionOptions);49 }50 protected override async void RunTestCases(IEnumerable<IXunitTestCase> testCases, IMessageSink sink,51 ITestFrameworkExecutionOptions options)52 {53 options.SetValue(nameof(ElasticXunitRunOptions.Version), Options.Version);54 options.SetValue(nameof(ElasticXunitRunOptions.RunIntegrationTests), Options.RunIntegrationTests);55 options.SetValue(nameof(ElasticXunitRunOptions.IntegrationTestsMayUseAlreadyRunningNode),56 Options.IntegrationTestsMayUseAlreadyRunningNode);57 options.SetValue(nameof(ElasticXunitRunOptions.RunUnitTests), Options.RunUnitTests);58 options.SetValue(nameof(ElasticXunitRunOptions.TestFilter), Options.TestFilter);59 options.SetValue(nameof(ElasticXunitRunOptions.ClusterFilter), Options.ClusterFilter);60 try61 {62 using (var runner =63 new TestAssemblyRunner(TestAssembly, testCases, DiagnosticMessageSink, sink, options))64 {65 Options.OnBeforeTestsRun();66 await runner.RunAsync().ConfigureAwait(false);67 Options.OnTestsFinished(runner.ClusterTotals, runner.FailedCollections);68 }69 }70 catch (Exception e)71 {72 if (e is ElasticsearchCleanExitException || e is AggregateException ae &&73 ae.Flatten().InnerException is ElasticsearchCleanExitException)74 sink.OnMessage(new TestAssemblyCleanupFailure(Enumerable.Empty<ITestCase>(), TestAssembly,75 new ElasticsearchCleanExitException("Node failed to start", e)));76 else77 sink.OnMessage(new TestAssemblyCleanupFailure(Enumerable.Empty<ITestCase>(), TestAssembly, e));78 throw;79 }80 }81 }82}...

Full Screen

Full Screen

TestNameProviderTests.cs

Source:TestNameProviderTests.cs Github

copy

Full Screen

1namespace TeamCity.VSTest.TestLogger.Tests2{3 using Shouldly;4 using Xunit;5 public class TestNameProviderTests6 {7 [Theory]8 // NUnit9 [InlineData("NUnit.Tests.Test1", "Test1", "NUnit.Tests.Test1")]10 // NUnit with parameters11 [InlineData("NUnit.Tests.Test2(\"Aa\", \"Bb\")", "Test2(\"Aa\", \"Bb\")", "NUnit.Tests.Test2(\"Aa\", \"Bb\")")]12 [InlineData("NUnit.Tests.Test2(\"A.a\", \"Bb\")", "Test2(\"A.a\", \"Bb\")", "NUnit.Tests.Test2(\"A.a\", \"Bb\")")]13 // NUnit with parameters and short name14 [InlineData("A.Test2(\"A.a\", \"Bb\")", "Test2(\"A.a\", \"Bb\")", "A.Test2(\"A.a\", \"Bb\")")]15 // XUnit16 [InlineData("XUnit.Tests.Test1", "XUnit.Tests.Test1", "XUnit.Tests.Test1")]17 // XUnit with type args18 [InlineData("XUnit.Tests.Test1", "XUnit.Tests.Test1<int>", "XUnit.Tests.Test1<int>")]19 // XUnit [Fact(DisplayName = "Abc")]20 [InlineData("XUnit.Tests.Test1", "Abc", "XUnit.Tests.Test1")]21 // XUnit [Fact(DisplayName = "Abc")] with type args22 [InlineData("XUnit.Tests.Test1", "Abc<int, String>", "XUnit.Tests.Test1<int, String>")]23 // XUnit with parameters24 [InlineData("XUnit.Tests.Test2", "XUnit.Tests.Test2 (str1: \"Aaa\", str2: \"Bb\")", "XUnit.Tests.Test2(str1: \"Aaa\", str2: \"Bb\")")]25 [InlineData("XUnit.Tests.Test2", "XUnit.Tests.Test2(str1: \"Aaa<string, Int>\", str2: \"Bb...", "XUnit.Tests.Test2(str1: \"Aaa<string, Int>\", str2: \"Bb...)")]26 // XUnit with parameters with type args27 [InlineData("XUnit.Tests.Test2", "XUnit.Tests.Test2<int, String>(str1: \"Aaa\", str2: \"Bb\")", "XUnit.Tests.Test2<int, String>(str1: \"Aaa\", str2: \"Bb\")")]28 // XUnit with long parameters29 [InlineData("XUnit.Tests.Test2", "XUnit.Tests.Test2 (str1: \"Aaa\", str2: \"Bb...", "XUnit.Tests.Test2(str1: \"Aaa\", str2: \"Bb...)")]30 // XUnit with long parameters with type args31 [InlineData("XUnit.Tests.Test2", "XUnit.Tests.Test2<string, Int>(str1: \"Aaa\", str2: \"Bb...", "XUnit.Tests.Test2<string, Int>(str1: \"Aaa\", str2: \"Bb...)")]32 // [Theory(DisplayName = "Abc")]33 [InlineData("XUnit.Tests.Test2", "Abc (str1: \"Aaa\", str2: \"Bb\")", "XUnit.Tests.Test2(str1: \"Aaa\", str2: \"Bb\")")]34 [InlineData("XUnit.Tests.Test2", "Abc (str1: \"Aaa\", str2: \"Bb\") ", "XUnit.Tests.Test2(str1: \"Aaa\", str2: \"Bb\")")]35 [InlineData("XUnit.Tests.Test2", "Abc ()", "XUnit.Tests.Test2()")]36 // MSTest37 [InlineData("MSTest.Tests.Test1", "Test1", "MSTest.Tests.Test1")]38 // MSTest [TestMethod("Abc")]39 [InlineData("MSTest.Tests.Test1", "Abc", "MSTest.Tests.Test1")]40 // MSTest with parameters41 [InlineData("MSTest.Tests.Test2", "Test2(Aa,Bb)", "MSTest.Tests.Test2(Aa,Bb)")]42 [InlineData("MSTest.Tests.Test2", "Test2 (Aa,Bb)", "MSTest.Tests.Test2(Aa,Bb)")]43 [InlineData("MSTest.Tests.Test2", "Test2 ()", "MSTest.Tests.Test2()")]44 [InlineData("MSTest.Tests.Test2", "Test3 (Aa,Bb)", "MSTest.Tests.Test2(Aa,Bb)")]45 [InlineData("MSTest.Tests.Test2", "Test2 (Aa,", "MSTest.Tests.Test2(Aa,)")]46 [InlineData("A.Test2", "Test2 (Aa,Bb)", "A.Test2(Aa,Bb)")]47 [InlineData("A...Test2.", "Test2 (Aa,Bb)", "A...Test2.(Aa,Bb)")]48 [InlineData("Abc", null, "Abc")]49 [InlineData("Abc", "", "Abc")]50 [InlineData("Abc", " ", "Abc")]51 [InlineData(null, "Abc", "Abc")]52 [InlineData("", "Abc", "Abc")]53 [InlineData(" ", "Abc", "Abc")]54 [InlineData(null, null, "")]55 public void ShouldProvideName(string fullyQualifiedName, string displayName, string expected)56 {57 // Given58 var nameFactory = CreateInstance();59 // When60 var actual = nameFactory.GetTestName(fullyQualifiedName, displayName);61 // Then62 actual.ShouldBe(expected);63 }64 private TestNameProvider CreateInstance() =>65 new TestNameProvider();66 }67}...

Full Screen

Full Screen

GodotXUnitEvents.cs

Source:GodotXUnitEvents.cs Github

copy

Full Screen

1using System;2using System.Collections.Generic;3using Xunit.Runners;4namespace GodotXUnitApi5{6 [Serializable]7 public class GodotXUnitSummary8 {9 public int testsDiscovered;10 public int testsExpectedToRun;11 public List<GodotXUnitTestResult> skipped = new List<GodotXUnitTestResult>();12 public List<GodotXUnitTestResult> passed = new List<GodotXUnitTestResult>();13 public List<GodotXUnitTestResult> failed = new List<GodotXUnitTestResult>();14 public List<GodotXUnitOtherDiagnostic> diagnostics = new List<GodotXUnitOtherDiagnostic>();15 public int completed => passed.Count + failed.Count;16 public GodotXUnitTestResult AddSkipped(TestSkippedInfo message)17 {18 var result = new GodotXUnitTestResult19 {20 testCaseClass = message.TypeName,21 testCaseName = message.MethodName,22 result = "skipped"23 };24 skipped.Add(result);25 return result;26 }27 public GodotXUnitTestResult AddPassed(TestPassedInfo message)28 {29 var result = new GodotXUnitTestResult30 {31 testCaseClass = message.TypeName,32 testCaseName = message.MethodName,33 output = message.Output,34 time = (float) message.ExecutionTime,35 result = "passed"36 };37 passed.Add(result);38 return result;39 }40 public GodotXUnitTestResult AddFailed(TestFailedInfo message)41 {42 var result = new GodotXUnitTestResult43 {44 testCaseClass = message.TypeName,45 testCaseName = message.MethodName,46 output = message.Output,47 time = (float) message.ExecutionTime,48 result = "failed",49 exceptionType = message.ExceptionType,50 exceptionMessage = message.ExceptionMessage,51 exceptionStackTrace = message.ExceptionStackTrace,52 };53 failed.Add(result);54 return result;55 }56 public GodotXUnitOtherDiagnostic AddDiagnostic(Exception ex)57 {58 var result = new GodotXUnitOtherDiagnostic59 {60 message = ex.Message,61 exceptionType = ex.GetType().ToString(),62 exceptionStackTrace = ex.StackTrace63 };64 diagnostics.Add(result);65 return result;66 }67 public GodotXUnitOtherDiagnostic AddDiagnostic(string message)68 {69 var result = new GodotXUnitOtherDiagnostic70 {71 message = message72 };73 diagnostics.Add(result);74 return result;75 }76 }77 [Serializable]78 public class GodotXUnitTestResult79 {80 public string testCaseClass;81 public string testCaseName;82 public string output;83 public float time;84 public string result;85 public string exceptionType;86 public string exceptionMessage;87 public string exceptionStackTrace;88 public string FullName => $"{testCaseClass}.{testCaseName}";89 }90 [Serializable]91 public class GodotXUnitTestStart92 {93 public string testCaseClass;94 public string testCaseName;95 }96 [Serializable]97 public class GodotXUnitOtherDiagnostic98 {99 public string message;100 public string exceptionType;101 public string exceptionStackTrace;102 }103}...

Full Screen

Full Screen

XUnitTestsGenerator.cs

Source:XUnitTestsGenerator.cs Github

copy

Full Screen

1namespace SpecFirst.TestGenerator.xUnit2{3 using System;4 using System.Collections.Generic;5 using HandlebarsDotNet;6 using SpecFirst.Core;7 using SpecFirst.Core.DecisionTable;8 using SpecFirst.Core.Setting;9 using SpecFirst.TestGenerator.xUnit.Template;10 public class XUnitTestsGenerator : ITestsGenerator11 {12 private readonly XUnitTemplateDataProvider _templateDataProvider;13 public XUnitTestsGenerator()14 {15 _templateDataProvider = new XUnitTemplateDataProvider();16 }17 public IEnumerable<string> Generate(18 SpecFirstSettings settings,19 IEnumerable<DecisionTable> decisionTables)20 {21 IEnumerable<object> templateData = _templateDataProvider.GetTemplateData(decisionTables);22 var data = new23 {24 namespace_name = settings.TestProject.TestNameSpace,25 list_of_fixtures = templateData26 };27 string testSources = GenerateTestMethods(data);28 string implementationSources = GenerateTestImplementations(data);29 return new[] { testSources, implementationSources };30 }31 private string GenerateTestMethods(dynamic data)32 {33 Handlebars.RegisterTemplate("TEST_METHOD_TEMPLATE", XUnitTemplate.TEST_METHOD_TEMPLATE);34 Handlebars.RegisterTemplate("ASSERT_STATEMENT_TEMPLATE", XUnitTemplate.ASSERT_STATEMENT_TEMPLATE);35 Handlebars.RegisterTemplate("TEST_DATA_TEMPLATE", XUnitTemplate.TEST_DATA_TEMPLATE);36 Handlebars.RegisterTemplate("TEST_NAME_TEMPLATE", XUnitTemplate.TEST_NAME_TEMPLATE);37 Handlebars.RegisterTemplate("CLASS_VARIABLE_TEMPLATE", XUnitTemplate.CLASS_VARIABLE_TEMPLATE);38 Handlebars.RegisterTemplate("IMPL_METHOD_CALL_EXPRESSION_TEMPLATE", XUnitTemplate.IMPL_METHOD_CALL_EXPRESSION_TEMPLATE);39 Handlebars.RegisterTemplate("IMPL_METHOD_DECLARATION_TEMPLATE", XUnitTemplate.IMPL_METHOD_DECLARATION_TEMPLATE);40 Handlebars.RegisterTemplate("DECORATION_METHOD_TEMPLATE", XUnitTemplate.DECORATION_METHOD_TEMPLATE);41 Handlebars.RegisterTemplate("CLASS_VARIABLE_TEMPLATE", XUnitTemplate.CLASS_VARIABLE_TEMPLATE);42 Handlebars.RegisterTemplate("DECORATION_VARIABLE_TEMPLATE", XUnitTemplate.DECORATION_VARIABLE_TEMPLATE);43 Func<object, string> compiled = Handlebars.Compile(XUnitTemplate.TEST_TEMPLATE);44 return compiled(data);45 }46 private string GenerateTestImplementations(object data)47 {48 Handlebars.RegisterTemplate("TEST_NAME_TEMPLATE", XUnitTemplate.TEST_NAME_TEMPLATE);49 Handlebars.RegisterTemplate("IMPL_METHOD_TEMPLATE", XUnitTemplate.IMPL_METHOD_TEMPLATE);50 Func<object, string> compiled = Handlebars.Compile(XUnitTemplate.IMPLEMENTATION_TEMPLATE);51 return compiled(data);52 }53 }54}...

Full Screen

Full Screen

ClassicXUnitMiscTests.cs

Source:ClassicXUnitMiscTests.cs Github

copy

Full Screen

1using System.Runtime.CompilerServices;2using System.Threading;3using Xunit;4using Xunit.Abstractions;5namespace Classic.XUnit.Tests.Misc6{7 public class ClassicXUnitMiscTests8 {9 private readonly ITestOutputHelper output;10 public ClassicXUnitMiscTests(ITestOutputHelper output)11 {12 this.output = output;13 }14 [Fact]15 public void ClassicXUnitMisc_Uncategorized_Passed() => Passed();16 [Fact]17 public void ClassicXUnitMisc_Uncategorized_Failed() => Failed();18 [Fact]19 public void ClassicXUnitMisc_Uncategorized_Passed_Long()20 {21 Thread.Sleep(5000);22 Passed();23 }24 [Fact(DisplayName = "CustomDisplayName")]25 public void ClassicXUnitMisc_Uncategorized_Passed_CustomDisplayName() => Passed();26 [Trait("Category", "CategoryA")]27 [Fact]28 public void ClassicXUnitMisc_CategoryA_Passed() => Passed();29 [Trait("Category", "CategoryB")]30 [Fact]31 public void ClassicXUnitMisc_CategoryB_Failed() => Failed();32 [Trait("Category", "CategoryA")]33 [Trait("Category", "CategoryB")]34 [Fact]35 public void ClassicXUnitMisc_CategoryAB_Passed() => Passed();36 [Trait("Category", "CategoryA")]37 [Trait("Category", "CategoryC")]38 [Fact]39 public void ClassicXUnitMisc_CategoryAC_Passed() => Passed();40 [Fact(Skip = "SkipMessage1")]41 public void ClassicXUnitMisc_Uncategorized_Skipped()42 {43 }44 [Fact(Skip = "SkipMessage2")]45 [Trait("Category", "CategoryB")]46 [Trait("Category", "CategoryC")]47 public void ClassicXUnitMisc_CategoryBC_Skipped()48 {49 }50 [Theory]51 [InlineData(3)]52 [InlineData(5)]53 public void ClassicXUnitMisc_Theory_Passed(int value)54 {55 output.WriteLine("Output: ClassicXUnitMisc_Theory_Passed, value = " + value);56 Assert.True(value % 2 == 1);57 }58 [Theory]59 [InlineData(3)]60 [InlineData(5)]61 [InlineData(6)]62 public void ClassicXUnitMisc_Theory_Failed(int value)63 {64 output.WriteLine("Output: ClassicXUnitMisc_Theory_Failed, value = " + value);65 Assert.True(value % 2 == 1);66 }67 private void Passed([CallerMemberName] string caller = null)68 {69 output.WriteLine("Output: " + caller);70 Assert.Equal(true, true);71 }72 private void Failed([CallerMemberName] string caller = null)73 {74 output.WriteLine("Output: " + caller);75 Assert.Equal(true, false);76 }77 }78}...

Full Screen

Full Screen

xunit

Using AI Code Generation

copy

Full Screen

1require_once 'atoum.php';2require_once 'atoum.php';3require_once 'atoum.php';4require_once 'atoum.php';5require_once 'atoum.php';6require_once 'atoum.php';7require_once 'atoum.php';8require_once 'atoum.php';9require_once 'atoum.php';10require_once 'atoum.php';11require_once 'atoum.php';12require_once 'atoum.php';13require_once 'atoum.php';14require_once 'atoum.php';15require_once 'atoum.php';16require_once 'atoum.php';17require_once 'atoum.php';18require_once 'atoum.php';19require_once 'atoum.php';

Full Screen

Full Screen

xunit

Using AI Code Generation

copy

Full Screen

1require_once 'atoum.php';2require_once 'phpunit.php';3require_once 'simpletest.php';4require_once 'phpunit.php';5require_once 'simpletest.php';6require_once 'phpunit.php';7require_once 'simpletest.php';8require_once 'phpunit.php';9require_once 'simpletest.php';10require_once 'phpunit.php';11require_once 'simpletest.php';12require_once 'phpunit.php';13require_once 'simpletest.php';14require_once 'phpunit.php';15require_once 'simpletest.php';16require_once 'phpunit.php';17require_once 'simpletest.php';18require_once 'phpunit.php';19require_once 'simpletest.php';20require_once 'phpunit.php';21require_once 'simpletest.php';22require_once 'phpunit.php';23require_once 'simpletest.php';24require_once 'phpunit.php';25require_once 'simpletest.php';26require_once 'phpunit.php';27require_once 'simpletest.php';28require_once 'phpunit.php';29require_once 'simpletest.php';

Full Screen

Full Screen

xunit

Using AI Code Generation

copy

Full Screen

1use \mageekguy\atoum;2{3 public function test1()4 {5 ->if($a = 1)6 ->integer($a)7 ->isEqualTo(1);8 }9}10use \mageekguy\atoum;11{12 public function test1()13 {14 ->if($a = 1)15 ->integer($a)16 ->isEqualTo(1);17 }18}19PHP 1. {main}() /usr/bin/atoum:020PHP 2. mageekguy\atoum\scripts\runner->run() /usr/bin/atoum:721PHP 3. mageekguy\atoum\scripts\runner->run() /usr/share/php/mageekguy/atoum/scripts/runner.php:9922PHP 4. mageekguy\atoum\scripts\runner->run() /usr/share/php/mageekguy/atoum/scripts/runner.php:9923PHP 5. mageekguy\atoum\scripts\runner->run() /usr/share/php/mageekguy/atoum/scripts/runner.php:9924PHP 6. mageekguy\atoum\scripts\runner->run() /usr/share/php/mageekguy/atoum/scripts/runner.php:9925PHP 7. mageekguy\atoum\scripts\runner->run() /usr/share/php/mageekguy/atoum/scripts/runner.php:9926PHP 8. mageekguy\atoum\scripts\runner->run() /usr/share/php/mageekguy/atoum/scripts/runner

Full Screen

Full Screen

xunit

Using AI Code Generation

copy

Full Screen

1$test = new \mageekguy\atoum\test();2$test->addTestClasses(array('test1.php'));3$test->run();4{5 public function test1()6 {7 $this->assert->integer(1)->isEqualTo(1);8 $this->assert->integer(1)->isEqualTo(2);9 }10}11mageekguy\atoum\test\engines\concurrent::run(): Undefined index: test1 in /var/www/1.php on line 712mageekguy\atoum\test\engines\concurrent::run(): Undefined index: test1 in /var/www/1.php on line 713mageekguy\atoum\test\engines\concurrent::run(): Undefined index: test1 in /var/www/1.php on line 714mageekguy\atoum\test\engines\concurrent::run(): Undefined index: test1 in /var/www/1.php on line 715mageekguy\atoum\test\engines\concurrent::run(): Undefined index: test1 in /var/www/1.php on line 716mageekguy\atoum\test\engines\concurrent::run(): Undefined index: test1 in /var/www/1.php on line 717mageekguy\atoum\test\engines\concurrent::run(): Undefined index: test1 in /var/www/1.php on line 718mageekguy\atoum\test\engines\concurrent::run(): Undefined index: test1 in /var/www/1.php on line 719mageekguy\atoum\test\engines\concurrent::run(): Undefined index: test1 in /var/www/1.php on line 720mageekguy\atoum\test\engines\concurrent::run(): Undefined index: test1 in /var/www/1

Full Screen

Full Screen

xunit

Using AI Code Generation

copy

Full Screen

1require_once 'atoum.phar';2require_once 'class.php';3require_once 'tests.php';4require_once 'tests2.php';5require_once 'tests3.php';6require_once 'tests4.php';7require_once 'tests5.php';8require_once 'tests6.php';9require_once 'tests7.php';10require_once 'tests8.php';11require_once 'tests9.php';12require_once 'tests10.php';13require_once 'tests11.php';14require_once 'tests12.php';15require_once 'tests13.php';16require_once 'tests14.php';17require_once 'tests15.php';18require_once 'tests16.php';19require_once 'tests17.php';20require_once 'tests18.php';21require_once 'tests19.php';22require_once 'tests20.php';23require_once 'tests21.php';24require_once 'tests22.php';25require_once 'tests23.php';26require_once 'tests24.php';27require_once 'tests25.php';28require_once 'tests26.php';29require_once 'tests27.php';30require_once 'tests28.php';31require_once 'tests29.php';32require_once 'tests30.php';33require_once 'tests31.php';34require_once 'tests32.php';35require_once 'tests33.php';36require_once 'tests34.php';

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful