/// <summary> /// Private method to return a test case, optionally ignored on the Linux platform. /// We use this since the Platform attribute is not supported on TestCaseData. /// </summary> private TestCaseData GetTestCase(MethodInfo method, ResultState resultState, int assertionCount, bool ignoreOnLinux) { var data = new TestCaseData(method, resultState, assertionCount); if (ON_LINUX && ignoreOnLinux) data = data.Ignore("Intermittent failure on Linux"); return data; }
/// <summary> /// Test case 6 /// </summary> private static TestCaseData StraightLineChartWithCustomDataPoints() { var testData = GetTestDataSet1(); var chart = new LineChart(testData.series, testData.labels) { Height = 500, Width = 800, LineType = LineType.Straight, ChartArea = { SeriesStyles = new[] { new LineSeriesStyle() { ElementStyle = { StrokeColor = "#3454D1" }, MarkerStyle = { StrokeWidth = 0 }, LabelStyle = { Size = 9, StrokeColor = "black" }, DataPointLabelPosition = Position.Centre }, new LineSeriesStyle() { ElementStyle = { StrokeColor = "#34D1BF" }, MarkerStyle = { StrokeWidth = 0 }, LabelStyle = { Size = 9, StrokeColor = "black" }, DataPointLabelPosition = Position.Centre }, } } }; var testCase = new TestCaseData(chart); testCase.SetName("TestCase 6 - Test custom series style."); testCase.SetDescription("Test case 6 : Straight line chart with custom data points, only dataPoint labels are drawn in centre position"); testCase.ExpectedResult = GetExpectedResults("TestCase-6.xml"); return(testCase); }
public static IEnumerable <TestCaseData> TestCases() { var testCases = new List <TestCaseData>(); using (var fs = System.IO.File.OpenRead("C:/Users/olesm/source/repos/GoogleDriveApi/data.csv")) using (var sr = new StreamReader(fs)) { string line = string.Empty; while (line != null) { line = sr.ReadLine(); if (line != null) { string[] split = line.Split(new char[] { ',' }, StringSplitOptions.None); string expectedNumber = Convert.ToString(split[0]); var testCase = new TestCaseData(expectedNumber); testCases.Add(testCase); } } return(testCases); } }
public void Tessellate_WithAsset_ReturnsExpectedTriangulation(TestCaseData data) { var pset = _loader.GetAsset(data.AssetName).Polygons; var tess = new Tess(); PolyConvert.ToTess(pset, tess); tess.Tessellate(data.Winding, ElementType.Polygons, data.ElementSize); var resourceName = Assembly.GetExecutingAssembly().GetName().Name + ".TestData." + data.AssetName + ".testdat"; var testData = ParseTestData(data.Winding, data.ElementSize, Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)); Assert.IsNotNull(testData); Assert.AreEqual(testData.ElementSize, data.ElementSize); var indices = new List <int>(); for (int i = 0; i < tess.ElementCount; i++) { for (int j = 0; j < data.ElementSize; j++) { int index = tess.Elements[i * data.ElementSize + j]; indices.Add(index); } } Assert.AreEqual(testData.Indices, indices.ToArray()); }
private static IEnumerable <TestCaseData> GetTestCasesFromFile() { using (var testData = File.OpenText(PulseEncoderTestCases)) { while (!testData.EndOfStream) { var line = testData.ReadLine(); if (line == null) { yield break; } var parts = line.Split(';'); int message; bool isOk = int.TryParse(parts[0].Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out message); if (!isOk) { throw new InvalidOperationException( string.Format("Invalid test case data. {0} is not a hexadecimal number.", parts[0])); } var testCaseData = new TestCaseData((ushort)message).Returns(parts[2]); yield return(testCaseData); } } }
private static TestCaseData GetTestCaseData(string name) { var asm = Assembly.GetExecutingAssembly(); var originalStream = asm.GetManifestResourceStream(typeof(_Dummy), name + ".txt"); var goldStream = asm.GetManifestResourceStream(typeof(_Dummy), name + ".gold"); Debug.Assert(originalStream != null, "originalStream != null"); Debug.Assert(goldStream != null, "goldStream != null"); string original; string gold; using (var streamReader = new StreamReader(originalStream, Encoding.UTF8)) original = streamReader.ReadToEnd(); using (var streamReader = new StreamReader(goldStream, Encoding.UTF8)) gold = streamReader.ReadToEnd(); var testCaseData = new TestCaseData(original); testCaseData.SetName(name); testCaseData.Returns(gold.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)); return(testCaseData); }
/// <summary> /// Test case 4 /// </summary> private static TestCaseData CurvedLineChartWithDataPoints() { //TODO : DataPoints are not drawn at the correct position var testData = GetTestDataSet2(); var chart = new LineChart(testData.series, testData.labels) { Height = 500, Width = 800, LineType = LineType.Curved, }; var testCase = new TestCaseData(chart); testCase.SetName("TestCase 4 - Test data markers"); testCase.SetDescription("Test case 4 : line chart with 1 series and the following all elements draw :\r\n" + "- curved lines\r\n" + "- DataPoints drawn\r\n" + "- X axis with labels, and major ticks\r\n" + "- Y axis with labels, and major ticks\r\n" + "- Legend with label and circle icon\r\n"); testCase.ExpectedResult = GetExpectedResults("TestCase-4.xml"); return(testCase); }
public async Task When_job_succeeded_builds_approval_event_for_new_and_removed_price_episodes( ICurrentPriceEpisodeForJobStore currentContext, IReceivedDataLockEventStore receivedContext, PriceEpisodesReceivedService sut, TestCaseData testCaseData, CurrentPriceEpisode removed) { testCaseData.CommonSetup(); await testCaseData.AddDataLockEventToContext(receivedContext); removed.AssociateWith(testCaseData.earning); await currentContext.Add(removed); var changeMessages = await sut.GetPriceEpisodeChanges(testCaseData.earning.JobId, testCaseData.earning.Ukprn, testCaseData.earning.CollectionYear); changeMessages.Should().ContainEquivalentOf( new { DataLock = new { PriceEpisodeIdentifier = testCaseData.earning.PriceEpisodes[0].Identifier, Status = PriceEpisodeStatus.New, }, }); changeMessages.Should().ContainEquivalentOf( new { DataLock = new { removed.PriceEpisodeIdentifier, Status = PriceEpisodeStatus.Removed, }, }); }
static IEnumerable <TestCaseData> SupplyComposition_ThrowsArgumentException_IfCompositionHasBadParameters_TestCaseSource() { var testCaseData = new TestCaseData( CreateLayerType(5, 5, 10), // Cobweb(5) layer type new Composition[] { CreateComposition(1, 1, 1, 1, 1), // Expecting CompositionParameters (Sum = 10, NumTerms = 5) }); yield return(testCaseData); yield return(new TestCaseData( CreateLayerType(5, 5, 10), // Cobweb(5) layer type new Composition[] { CreateComposition(2, 2, 2, 2, 2), // One pair for each vertex CreateComposition(1, 1, 1, 1, 1, 1, 1, 1, 1, 1) // Expecting (Sum = 15, NumTerms = 10); correct number of terms })); yield return(new TestCaseData( CreateLayerType(5, 5, 10), // Cobweb(5) layer type new Composition[] { CreateComposition(2, 2, 2, 2, 2), // One pair for each vertex CreateComposition(3, 3, 3, 3, 3) // Expecting (Sum = 15, NumTerms = 10); correct sum })); }
/// <summary> /// Test case 22 /// </summary> private static TestCaseData DocumentationSample3() { var testData = DocumentationSampleDataSet1(); var chart = new LineChart(testData.series, testData.labels) { Height = 300, Width = 1500, LineType = LineType.Curved, PaddingRight = 15, XAxis = { StartOnMajor = true }, ChartArea = { SeriesStyles = new[] { new LineSeriesStyle() { ElementStyle = { StrokeColor = "none", StrokeWidth = 1, Fill = "#4674C5", FillOpacity = 0.4 }, MarkerStyle = { StrokeWidth = 2, StrokeColor = "white", Fill = "#4674C5", Radius = 3 }, LabelStyle = { Size = 0, StrokeColor = "#3D3D3D" }, DataPointLabelPosition = Position.Centre } } }, DrawDebug = false }; var testCase = new TestCaseData(chart); testCase.SetName("TestCase 22 - Documentation sample 3."); testCase.SetDescription("Test case 22 : Curved line with a fill, where the min value is 0"); testCase.ExpectedResult = GetExpectedResults("TestCase-22.xml"); return(testCase); }
public static IEnumerable <TestCaseData> GetCallTestCases() { foreach (Type scenario in typeof(TestHelpers.Rpc).GetNestedTypes()) { Type calleeToDealer = scenario.GetNestedType("CallerToDealer"); PropertyInfo callsProperty = calleeToDealer.GetProperty("Calls", BindingFlags.Static | BindingFlags.Public); IEnumerable <WampMessage <MockRaw> > calls = callsProperty.GetValue(null, null) as IEnumerable <WampMessage <MockRaw> >; IEnumerable <Call> callsToCall = calls.Where(x => x.MessageType == WampMessageType.v2Call) .Select(x => new Call(x)); foreach (Call call in callsToCall) { TestCaseData testCase = new TestCaseData(call); testCase.SetName(scenario.Name); yield return(testCase); } } }
public static TestCaseData CreateTestCaseData(string name, params object[] arguments) { var data = new TestCaseData(arguments); data.SetName(name); return(data); }
public static IEnumerable <ITestCaseData> GetTestCases() { const string prefix = "MongoDB.Driver.Tests.Specifications.command_monitoring.tests."; var testDocuments = Assembly .GetExecutingAssembly() .GetManifestResourceNames() .Where(path => path.StartsWith(prefix) && path.EndsWith(".json")) .Select(path => ReadDocument(path)); foreach (var testDocument in testDocuments) { var data = testDocument["data"].AsBsonArray.Cast <BsonDocument>().ToList(); var databaseName = testDocument["database_name"].ToString(); var collectionName = testDocument["collection_name"].ToString(); foreach (BsonDocument definition in testDocument["tests"].AsBsonArray) { foreach (var async in new[] { false, true }) { var testCase = new TestCaseData(data, databaseName, collectionName, definition, async); testCase.Categories.Add("Specifications"); testCase.Categories.Add("command-monitoring"); testCase.SetName($"{definition["description"]}({async})"); yield return(testCase); } } } }
/// <summary> /// Reads the data drive file and set test name. /// </summary> /// <param name="folder">Full path to XML DataDriveFile file</param> /// <param name="testData">Name of the child element in xml file.</param> /// <param name="diffParam">Values of listed parameters will be used in test case name.</param> /// <param name="testName">Name of the test, use as prefix for test case name.</param> /// <returns> /// IEnumerable TestCaseData /// </returns> /// <exception cref="System.ArgumentNullException">Exception when element not found in file</exception> /// <exception cref="DataDrivenReadException">Exception when parameter not found in row</exception> /// <example>How to use it: <code> /// public static IEnumerable Credentials /// { /// get { return DataDrivenHelper.ReadDataDriveFile(ProjectBaseConfiguration.DataDrivenFile, "credential", new[] { "user", "password" }, "credential"); } /// } /// </code></example> public static IEnumerable <TestCaseData> ReadDataDriveFile(string folder, string testData, string[] diffParam, [Optional] string testName) { var doc = XDocument.Load(folder); if (!doc.Descendants(testData).Any()) { throw new ArgumentNullException(string.Format(" Exception while reading Data Driven file\n row '{0}' not found \n in file '{1}'", testData, folder)); } foreach (XElement element in doc.Descendants(testData)) { var testParams = element.Attributes().ToDictionary(k => k.Name.ToString(), v => v.Value); var testCaseName = string.IsNullOrEmpty(testName) ? testData : testName; try { testCaseName = TestCaseName(diffParam, testParams, testCaseName); } catch (DataDrivenReadException e) { throw new DataDrivenReadException( string.Format( " Exception while reading Data Driven file\n test data '{0}' \n test name '{1}' \n searched key '{2}' not found in row \n '{3}' \n in file '{4}'", testData, testName, e.Message, element, folder)); } var data = new TestCaseData(testParams); data.SetName(testCaseName); yield return(data); } }
protected static IEnumerable MixFilterData() { TestCaseData result; var filter = new MovieSearchCriteria { Genres = new List <Genres> { Genres.Action }, YearOfRelease = 1999 }; result = new TestCaseData(filter, 4); yield return(result); filter = new MovieSearchCriteria { Title = "test", YearOfRelease = 2000 }; result = new TestCaseData(filter, 2); yield return(result); filter = new MovieSearchCriteria { Title = "test", Genres = new List <Genres> { Genres.Horror } }; result = new TestCaseData(filter, 1); yield return(result); }
private static TestCaseData prepareTestData(Tuple <int, int, int>[] input, Tuple <int, int>[] output, string name_ext) { var data = new TestCaseData(input, output); data.TestName = $"{nameof(DijksgraGraphTest.DijkstraShortestPath_Test)}_{name_ext}"; return(data); }
private static List <TestCaseData> GetUtilizationTestData() { var testCaseDatas = new List <TestCaseData>(); var dllPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); var jsonPath = Path.Combine(dllPath, "CrossAgentTests", "Utilization", "utilization_json.json"); var jsonString = File.ReadAllText(jsonPath); var settings = new JsonSerializerSettings { TypeNameHandling = Newtonsoft.Json.TypeNameHandling.Auto, Error = (sender, args) => { if (System.Diagnostics.Debugger.IsAttached) { System.Diagnostics.Debugger.Break(); } } }; var testList = JsonConvert.DeserializeObject <List <UtilizationTestData> >(jsonString, settings); foreach (var testData in testList) { var testCase = new TestCaseData(testData); testCase.SetName("UtilizationCrossAgentTests: " + testData.Testname); testCaseDatas.Add(testCase); } return(testCaseDatas); }
static IEnumerable <TestCaseData> TestCases() { string testCasesPath = Path.Combine(ProjectRoot, "TestCases"); foreach (var file in Directory.GetFiles(testCasesPath)) { var content = File.ReadAllText(file); int textEnd = content.IndexOf("\n## WRAP_", StringComparison.InvariantCulture); if (textEnd < 1) { continue; } bool isUnixLineEnding = content[textEnd - 1] != '\r'; int maxLength; if (int.TryParse(content.Substring(textEnd + 9, 3), out maxLength)) { var testCase = new TestCase { Name = Path.GetFileNameWithoutExtension(file), Input = content.Substring(0, textEnd - (isUnixLineEnding ? 0 : 1)), MaxLength = maxLength, Expect = content.Substring(textEnd + (isUnixLineEnding ? 16 : 17)) }; var testCaseData = new TestCaseData(testCase); testCaseData.SetName(testCase.Name); yield return(testCaseData); } } }
private static IEnumerable <TestCaseData> BulkCreateCombineApplicationFieldTestCasesData() { var failedCases = new string[] { InputType.Date.ToString(), InputType.Age.ToString(), "Option" }; foreach (var entry in Enum.GetValues(typeof(Entries))) { foreach (ResourceId resource in Utils.Resources()) { var item = FieldsDictionary[resource]; for (var i = 0; i < ApplicationFields.Count; i++) { for (var j = i + 1; j < ApplicationFields.Count; j++) { var firstFieldName = ApplicationFields.Keys.ElementAt(i).ToString(); var secondFieldName = ApplicationFields.Keys.ElementAt(j).ToString(); var firstFieldType = BulkCombineFields.GetFieldTypeByFieldName(resource, firstFieldName); var secondFieldType = BulkCombineFields.GetFieldTypeByFieldName(resource, secondFieldName); var testCaseData = new TestCaseData(entry, resource, firstFieldName, secondFieldName).SetDescription($"Bulk create with {resource} resource and {firstFieldName},{secondFieldName} fields"); if (firstFieldType.ToString().ContainsStrings(failedCases) || secondFieldType.ToString().ContainsStrings(failedCases)) { testCaseData.Bug("45167,45169"); } if (resource == ResourceId.Contract || resource == ResourceId.Activity || resource == ResourceId.Sales) { testCaseData.Bug("45172"); } yield return(testCaseData); } } } } }
private static TestCaseData GetTestCaseData(SearchRequest request, ResourceId resource, SearchFilterType searchType, string op, PrivateApiResponseCode expectedCode) { var testCaseData = new TestCaseData(request, resource, searchType, op, expectedCode); var nullApplicableOperators = new List <string> { "=", "!=" }; if (searchType == SearchFilterType.BoolAndOr || searchType == SearchFilterType.BoolNot) { testCaseData.Bug("39352"); } if (searchType == SearchFilterType.Subquery || searchType == SearchFilterType.FreeWord || searchType == SearchFilterType.DateMinMax || searchType == SearchFilterType.NumMinMax) { testCaseData.Bug("39354"); } if ((searchType == SearchFilterType.Text && !nullApplicableOperators.Contains(op)) || (searchType == SearchFilterType.DateIn && !nullApplicableOperators.Contains(op)) || (searchType == SearchFilterType.NumOperator && !nullApplicableOperators.Contains(op)) || (searchType == SearchFilterType.Date && !nullApplicableOperators.Contains(op))) { testCaseData.Bug("39355"); } return(testCaseData); }
/// <summary> /// テストケースデータを生成します. /// 主にダウンロードスクリプトを含んだコンパイル手順を含んだテストケースの生成で使用されます. /// </summary> /// <param name="dirName">ソースコードを配置するディレクトリ名</param> /// <param name="deploySource">指定したディレクトリにソースコードを配置するアクション</param> /// <param name="compileActionWithWorkDirPath">作業ディレクトリと</param> /// <param name="relativePathsForBinaryFiles">バイナリファイルが存在するディレクトリの相対パスのリスト</param> /// <returns>テストケースデータのシーケンス(ソースコードの配置に失敗した場合は空)</returns> protected IEnumerable <TestCaseData> SetUpTestCaseData( string dirName, Func <string, bool> deploySource, Action <string> compileActionWithWorkDirPath, params string[] relativePathsForBinaryFiles) { var deployPath = FixtureUtil.GetDownloadPath(LanguageName, dirName); // relativePathsForBinaryFilesの正規化 if (relativePathsForBinaryFiles == null || relativePathsForBinaryFiles.Length == 0) { relativePathsForBinaryFiles = new[] { dirName }; } var testCase = new TestCaseData( deployPath, relativePathsForBinaryFiles, compileActionWithWorkDirPath ?? (workDirPath => { })); if (Directory.Exists(deployPath) && Directory.EnumerateFiles( deployPath, "*" + Extension, SearchOption.AllDirectories).Any()) { yield return(testCase); yield break; } Directory.CreateDirectory(deployPath); // ソースコードの配置に成功した場合のみテストケースデータを生成する if (deploySource(deployPath)) { yield return(testCase); } }
static TestCaseData CreateNUnitTestCase(TestCase testCase, string displayName) { var data = new TestCaseData(testCase); data.SetName(displayName); return(data); }
private static List <TestCaseData> GetDistributedTraceTestData() { var testCaseDatas = new List <TestCaseData>(); var dllPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); var jsonPath = Path.Combine(dllPath, "CrossAgentTests", "DistributedTracing", "distributed_tracing.json"); var jsonString = File.ReadAllText(jsonPath); var settings = new JsonSerializerSettings { Error = (sender, args) => { if (System.Diagnostics.Debugger.IsAttached) { System.Diagnostics.Debugger.Break(); } } }; var testList = JsonConvert.DeserializeObject <List <DistributedTraceTestData> >(jsonString, settings); foreach (var testData in testList) { var testCase = new TestCaseData(testData); testCase.SetName("DistributedTraceCrossAgentTests: " + testData.Name); testCaseDatas.Add(testCase); } return(testCaseDatas); }
public async Task When_job_succeeded_builds_approval_event_for_removed_price_episode( [Frozen] Mock <IApprenticeshipRepository> apprenticeshipRepo, ICurrentPriceEpisodeForJobStore currentContext, IReceivedDataLockEventStore receivedContext, TestCaseData testCaseData, PriceEpisodesReceivedService sut, CurrentPriceEpisode priceEpisode) { testCaseData.CommonSetup(); await testCaseData.AddDataLockEventToContext(receivedContext); priceEpisode.AssociateWith(testCaseData.earning); await currentContext.Add(priceEpisode); var changeMessages = await sut.GetPriceEpisodeChanges(testCaseData.earning.JobId, testCaseData.earning.Ukprn, testCaseData.earning.CollectionYear); changeMessages.Should().ContainEquivalentOf( new { DataLock = new { priceEpisode.PriceEpisodeIdentifier, Status = PriceEpisodeStatus.Removed, }, }); }
public static IEnumerable <ITestCaseData> GetTestCases() { const string prefix = "MongoDB.Driver.Specifications.read_write_concern.tests.document."; return(Assembly .GetExecutingAssembly() .GetManifestResourceNames() .Where(path => path.StartsWith(prefix) && path.EndsWith(".json")) .SelectMany(path => { var definition = ReadDefinition(path); var tests = (BsonArray)definition["tests"]; var fullName = path.Remove(0, prefix.Length); var list = new List <TestCaseData>(); foreach (BsonDocument test in tests) { var data = new TestCaseData(test); data.Categories.Add("Specifications"); if (test.Contains("readConcern")) { data.Categories.Add("ReadConcern"); } else { data.Categories.Add("WriteConcern"); } var testName = fullName.Remove(fullName.Length - 5) + ": " + test["description"]; list.Add(data.SetName(testName)); } return list; })); }
private static IEnumerable <ITestCaseData> GetTestCases() { const string testCasesDir = @"Pcre\TestCases"; for (var fileIndex = 0; fileIndex < InputFiles.GetLength(0); ++fileIndex) { var testFileName = InputFiles[fileIndex, 0]; using (var inputFs = File.OpenRead(Path.Combine(testCasesDir, testFileName))) using (var outputFs = File.OpenRead(Path.Combine(testCasesDir, InputFiles[fileIndex, 1]))) using (var inputReader = new TestInputReader(inputFs)) using (var outputReader = new TestOutputReader(outputFs)) { var tests = inputReader.ReadTestCases().Zip(outputReader.ReadTestOutputs(), (i, o) => new { testCase = i, expectedResult = o }); foreach (var test in tests) { var testCase = new TestCaseData(test.testCase, test.expectedResult) .SetCategory(testFileName) .SetName(String.Format("{0} line {1:0000}", testFileName, test.testCase.Pattern.LineNumber)) .SetDescription(test.testCase.Pattern.Pattern); yield return(testCase); } } } }
public static IEnumerable <TestCaseData> GetData() { foreach (Goto gotoItem in CurrentConfiguration.Gotos) { // Go through each of the browser enum. For example: gotoItem.Browser might be ALL foreach (Browser browser in Enum.GetValues(typeof(Browser))) { // Skip the all enum: We only want to see the individual ones if (browser == Browser.ALL) { continue; } // If specified IEXPLORE but flag looking at is CHROME, don't create a test for it // However, if specified ALL, ALL has CHROME, create a test for it, and one for IEXPLORE too if (!gotoItem.Browser.HasFlag(browser)) { continue; } TestCaseData tcd = new TestCaseData(gotoItem); tcd.SetCategory(browser.ToString()); yield return(tcd); } } }
/// <summary> /// Test case 8 /// </summary> private static TestCaseData BasicLineChartWithDashedAndDottedGridlines() { var testData = GetTestDataSet2(); var chart = new LineChart(testData.series, testData.labels) { Height = 500, Width = 800, DrawDebug = false, PaddingRight = 15, ChartArea = { YGridLineStyle = { MajorLineStyle = { StrokeWidth = 0.7, StrokeStyle = LineStyle.Dashed }, MinorLineStyle = { StrokeWidth = 0.5, StrokeStyle = LineStyle.Dotted } } } }; var testCase = new TestCaseData(chart); testCase.SetName("TestCase 8 - Test path stroke style"); testCase.SetDescription("Test case 8 : Basic line chart with dashed major and dotted minor gridlines"); testCase.ExpectedResult = GetExpectedResults("TestCase-8.xml"); return(testCase); }
public static IEnumerable <ITestCaseData> GetTestCases() { const string prefix = "MongoDB.Driver.Specifications.connection_string.tests."; return(Assembly .GetExecutingAssembly() .GetManifestResourceNames() .Where(path => path.StartsWith(prefix) && path.EndsWith(".json")) .SelectMany(path => { var definition = ReadDefinition(path); var tests = (BsonArray)definition["tests"]; var fullName = path.Remove(0, prefix.Length); var list = new List <TestCaseData>(); foreach (BsonDocument test in tests) { var data = new TestCaseData(test); data.SetCategory("Specifications"); data.SetCategory("ConnectionString"); var testName = fullName.Remove(fullName.Length - 5) + ": " + test["description"]; if (_ignoredTestNames.Contains(testName)) { data = data.Ignore("Does not apply"); } list.Add(data.SetName(testName)); } return list; })); }
public async Task PaymentRule_FullProduction_Audio_GreaterThan_50000(TestCaseData caseDate) { // Arrange InitData( isAipe: false, stageKey: caseDate.Stage, budgetRegion: caseDate.BudgetRegion, items: new List <CostLineItemView> { new CostLineItemView { TemplateSectionName = Constants.CostSection.Production, ValueInDefaultCurrency = 50000 }, new CostLineItemView { TemplateSectionName = "WHATEVERELSE", ValueInDefaultCurrency = 100 } }, contentType: Constants.ContentType.Audio, productionType: Constants.ProductionType.FullProduction ); // Act var receipt = await _purchaseOrderService.GetPurchaseOrder(_costApprovedEvent); // Assert // payment calculation according to the rule: // 100% of cost total receipt.PaymentAmount.ShouldBeEquivalentTo(50100 * caseDate.Percent); }
/// <summary> /// Test case 20 /// </summary> private static TestCaseData DocumentationSample1() { var testData = DocumentationSampleDataSet1(); var chart = new LineChart(testData.series, testData.labels) { Height = 500, Width = 800, LineType = LineType.Straight, ChartArea = { SeriesStyles = new[] { new LineSeriesStyle() { ElementStyle = { StrokeColor = "#4674C5", StrokeWidth = 3, StrokeOpacity = 1 }, MarkerStyle = { StrokeWidth = 0 }, LabelStyle = { Size = 9, StrokeColor = "#3D3D3D" },DataPointLabelPosition = Position.Centre }, }, YGridLineStyle = { MajorLineStyle = { StrokeWidth = 0.7 },MinorLineStyle = { StrokeWidth = 0.1 } } }, DrawDebug = false }; var testCase = new TestCaseData(chart); testCase.SetName("TestCase 20 - Documentation sample 1."); testCase.SetDescription("Test case 20 : Straight line chart with custom data points, only dataPoint labels are drawn in centre position"); testCase.ExpectedResult = GetExpectedResults("TestCase-20.xml"); return(testCase); }
private bool OnDiscoveryMessage(ITestCaseDiscoveryMessage testCaseDiscovered) { var testCase = testCaseDiscovered.TestCase; var testCaseData = new TestCaseData( testCase.DisplayName, testCaseDiscovered.TestAssembly.Assembly.AssemblyPath, testCase.Traits); _writer.Write(TestDataKind.Value); _writer.Write(testCaseData); return _writer.IsConnected; }
/// <summary> /// Get files to compare. /// </summary> /// <param name="type">Files type</param> /// <returns> /// Pairs of files to compare <see cref="IEnumerable"/>. /// </returns> private static IEnumerable<TestCaseData> FindFiles(FileType type) { Logger.Info("Get Files {0}:", type); var liveFiles = FilesHelper.GetFilesOfGivenType(ProjectBaseConfiguration.DownloadFolderPath, type, "live"); if (liveFiles != null) { foreach (FileInfo liveFile in liveFiles) { Logger.Trace("liveFile: {0}", liveFile); var fileNameBranch = liveFile.Name.Replace("live", "branch"); var testCaseName = liveFile.Name.Replace("_" + "live", string.Empty); TestCaseData data = new TestCaseData(liveFile.Name, fileNameBranch); data.SetName(Regex.Replace(testCaseName, @"[.]+|\s+", "_")); Logger.Trace("file Name Short: {0}", testCaseName); yield return data; } } }
/// <summary> /// Reads the data drive file and set test name. /// </summary> /// <param name="folder">Full path to XML DataDriveFile file</param> /// <param name="testData">Name of the child element in xml file.</param> /// <param name="diffParam">Values of listed parameters will be used in test case name.</param> /// <param name="testName">Name of the test, use as prefix for test case name.</param> /// <returns> /// IEnumerable TestCaseData /// </returns> /// <exception cref="System.ArgumentNullException">Exception when element not found in file</exception> /// <exception cref="DataDrivenReadException">Exception when parameter not found in row</exception> /// <example>How to use it: <code> /// public static IEnumerable Credentials /// { /// get { return DataDrivenHelper.ReadDataDriveFile(ProjectBaseConfiguration.DataDrivenFile, "credential", new[] { "user", "password" }, "credential"); } /// } /// </code></example> public static IEnumerable<TestCaseData> ReadDataDriveFile(string folder, string testData, string[] diffParam, [Optional] string testName) { var doc = XDocument.Load(folder); if (!doc.Descendants(testData).Any()) { throw new ArgumentNullException(string.Format(" Exception while reading Data Driven file\n row '{0}' not found \n in file '{1}'", testData, folder)); } foreach (XElement element in doc.Descendants(testData)) { var testParams = element.Attributes().ToDictionary(k => k.Name.ToString(), v => v.Value); var testCaseName = string.IsNullOrEmpty(testName) ? testData : testName; try { testCaseName = TestCaseName(diffParam, testParams, testCaseName); } catch (DataDrivenReadException e) { throw new DataDrivenReadException( string.Format( " Exception while reading Data Driven file\n test data '{0}' \n test name '{1}' \n searched key '{2}' not found in row \n '{3}' \n in file '{4}'", testData, testName, e.Message, element, folder)); } var data = new TestCaseData(testParams); data.SetName(testCaseName); yield return data; } }
private TestCaseData LoadTestCaseData(int testCaseId) { var rv = new TestCaseData(); Assembly assembly = Assembly.GetExecutingAssembly(); using (Stream str = assembly.GetManifestResourceStream(string.Format("Tangra.Astrometry.Tests.MotionFitting.TestCasesData.TestCase{0}.xml", testCaseId))) using (TextReader rdr = new StreamReader(str)) { string xmlStr = rdr.ReadToEnd(); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlStr); var tcSer = new XmlSerializer(typeof (TestCaseConfiguration)); var mcSer = new XmlSerializer(typeof(FlybyMeasurementContext)); var fcSer = new XmlSerializer(typeof(FittingContext)); var smfmSer = new XmlSerializer(typeof(SingleMultiFrameMeasurement)); rv.TestConfig = (TestCaseConfiguration)tcSer.Deserialize(new StringReader(xmlDoc.DocumentElement["TestCaseConfiguration"].OuterXml)); rv.MeasurementContext = (FlybyMeasurementContext)mcSer.Deserialize(new StringReader(xmlDoc.DocumentElement["FlybyMeasurementContext"].OuterXml)); rv.FittingContext = (FittingContext)fcSer.Deserialize(new StringReader(xmlDoc.DocumentElement["FittingContext"].OuterXml)); foreach (XmlElement node in xmlDoc.DocumentElement["Mesurements"]) { rv.Measurements.Add((SingleMultiFrameMeasurement)smfmSer.Deserialize(new StringReader(node.OuterXml))); } } return rv; }
/// <summary> /// Private method to return a test case, optionally ignored on the Linux platform. /// We use this since the Platform attribute is not supported on TestCaseData. /// </summary> private static TestCaseData GetTestCase(IMethodInfo method, ResultState resultState, int assertionCount, bool ignoreThis) { var data = new TestCaseData(method, resultState, assertionCount); if (PLATFORM_IGNORE && ignoreThis) data = data.Ignore("Intermittent failure on Linux and under Portable build"); return data; }
public void Write(TestCaseData testCaseData) { WriteCore(() => testCaseData.WriteTo(_writer)); }