private static void Test3() { var generatorConfig = new InputGeneratorConfig { Seed = 1337, InputLength = 10 * 1024 * 1024, //SentenceLength = new MinMaxPair(int.MaxValue, int.MaxValue), SentenceLength = new MinMaxPair(5, 10), PhraseCount = new MinMaxPair(2048), WordLength = new MinMaxPair(6, 10), PhraseLength = new MinMaxPair(3, 6) }; var generator = new InputGenerator(generatorConfig); var pair = generator.Generate(); //Console.WriteLine(pair.Input); Console.WriteLine(pair.Input.Length); Console.WriteLine(); //Console.WriteLine(pair.Solution); Console.WriteLine(pair.Solution.Length); Console.WriteLine(); var solver = new SampleSubmission(); var result = solver.Solve(pair.Input); //Console.WriteLine(result); Console.WriteLine(result == pair.Solution); }
// ===== Update Functions. ===== /// <summary> /// Performs conversion of each stored string key in the current instance to KeyCode. /// Used for in-editor changes. /// </summary> public void UpdateSettings() { // Determining the function used to generate an output value. inputGenerator = stepSize == 1 ? (InputGenerator)GetSnappedInput : (InputGenerator)GetLerpedInput; // inputChecker = canHoldInput ? (InputChecker)Input.GetKey : (InputChecker)Input.GetKeyDown; // snapThreshold = stepSize * 0.5f; // Resetting the positive and negative key values to activate the // setter string>KeyCode conversion. foreach (Key k in keys) { k.UpdateKey(); } }
public void InputGeneratorCreatesMultipleHooks() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "@f1@f2 @f3", "@f4", "Feature: my new feature", "", "@s1@s2 @s3", "@s4", "Scenario: my new scenario" }; var features = generator.Load(contents); Assert.AreEqual(4, features[0].Hooks.Count, "feature hook count mismatch"); Assert.AreEqual("f1", features[0].Hooks[0].Name); Assert.AreEqual("f2", features[0].Hooks[1].Name); Assert.AreEqual("f3", features[0].Hooks[2].Name); Assert.AreEqual("f4", features[0].Hooks[3].Name); Assert.AreEqual(8, features[0].Scenarios[0].Hooks.Count, "feature hook count mismatch"); Assert.AreEqual("f1", features[0].Scenarios[0].Hooks[0].Name); Assert.AreEqual("f2", features[0].Scenarios[0].Hooks[1].Name); Assert.AreEqual("f3", features[0].Scenarios[0].Hooks[2].Name); Assert.AreEqual("f4", features[0].Scenarios[0].Hooks[3].Name); Assert.AreEqual("s1", features[0].Scenarios[0].Hooks[4].Name); Assert.AreEqual("s2", features[0].Scenarios[0].Hooks[5].Name); Assert.AreEqual("s3", features[0].Scenarios[0].Hooks[6].Name); Assert.AreEqual("s4", features[0].Scenarios[0].Hooks[7].Name); }
private async Task TestInput() { // Start a process to test against using (var process = Process.Start("notepad.exe")) { // Make sure it's started Assert.NotNull(process); // Wait until the process started it's message pump (listening for input) process.WaitForInputIdle(); // Find the belonging window var notepadWindow = await WindowsEnumerator.EnumerateWindowsAsync() .Where(interopWindow => { int processId; User32Api.GetWindowThreadProcessId(interopWindow.Handle, out processId); return(processId == process.Id); }) .FirstOrDefaultAsync(); Assert.NotNull(notepadWindow); // Send input var sentInputs = InputGenerator.KeyPress(VirtualKeyCodes.KEY_R, VirtualKeyCodes.KEY_O, VirtualKeyCodes.KEY_B, VirtualKeyCodes.KEY_I, VirtualKeyCodes.KEY_N); // Test if we indead sent 10 inputs (5 x down & up) Assert.Equal((uint)10, sentInputs); // Kill the process process.Kill(); } }
public void WhenIPostInValidCustomerListWebApiGetUserCustomerListRequest(string invalidAccessToken) { string accessToken = InputGenerator.GetValue(invalidAccessToken); ResponseString = RestClientUtil.DoInvalidHttpRequest(CustomerListConfig.CustomerListWebAPI, HeaderSettings.GetMethod, accessToken, HeaderSettings.JsonMediaType, null, HttpStatusCode.Unauthorized, HeaderSettings.BearerType, HeaderSettings.JsonMediaType); }
private void TestMouseInput() { InputGenerator.MoveMouse(new NativePoint(10, 10)); Thread.Sleep(1000); InputGenerator.MoveMouse(new NativePoint(100, 100)); Thread.Sleep(1000); }
static void Main(string[] args) { var agency = new Agency(); var inputGenerator = new InputGenerator(); List <Invoice> invoices = inputGenerator.GenerateInvoices(10000); foreach (var inv in invoices) { agency.Create(inv); } var mostOccur = inputGenerator.MostOccur(invoices, x => x.DueDate); DateTime mostOccurDueDate = mostOccur.Key; DateTime minDueDate = mostOccurDueDate.AddYears(-1); DateTime maxDueDate = mostOccurDueDate.AddYears(1); var watch = new Stopwatch(); watch.Start(); try { agency.ThrowInvoiceInPeriod(minDueDate, maxDueDate); } catch (ArgumentException ignored) { } watch.Stop(); long elapsedTime = watch.ElapsedMilliseconds; System.Console.WriteLine(elapsedTime); }
public static CLL <int> TakeInputList_CLL(bool isRandom = true, int MinContentLegth = 10, int MaxContentLength = 20, int MaxValue = 20) { if (!isRandom) { CLL <int> meList = new CLL <int>(); Console.WriteLine("Enter the number of elements in List"); int numbers = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter elements of List\n "); int i = 1; while (i <= numbers) { meList.Insert(Convert.ToInt32(Console.ReadLine()), false); i++; } return(meList); } else { InputGenerator ioGenerator = new InputGenerator(); ioGenerator.MaxContentLength = MaxContentLength; ioGenerator.MinContentLength = MinContentLegth; var meList = InputStream.ReadFileAsCLL(ioGenerator.GenerateIntegerInputFile(MaxValue)); return(meList); } }
static void Main(string[] args) { //Connect Service injector Get concrete class of service interfaces ServiceProvider serviceProvider = ServiceInjector.Register(); IRoverService roverService = serviceProvider.GetService <IRoverService>(); CommandInvoker commandInvoker = new CommandInvoker(); //Get Inputs List <string> inputs = InputGenerator.GetInputs(); //Get Rovers by sending input parameters set commands of each rover List <Rover> rovers = roverService.GetRoversByInput(inputs); //Invoke Rover Commands foreach (var rover in rovers) { foreach (var command in rover.Commands) { //Set each rover commands commandInvoker.SetCommand(command); commandInvoker.Invoke(); } } //Show Output OutputHelper(rovers); }
public void GenerateMinMaxPairs() { int[,] minMaxPairs = InputGenerator.GenerateRandomMinMaxPairs(1000, 1, 1000); Assert.AreEqual(1000, minMaxPairs.GetLength(0)); for (int p = 0; p < 1000; ++p) { int min = minMaxPairs[p, 0]; int max = minMaxPairs[p, 1]; Assert.IsTrue(min <= max); Assert.IsTrue(min >= 1 && min <= 1000); Assert.IsTrue(max >= 1 && max <= 1000); } minMaxPairs = InputGenerator.GenerateRandomMinMaxPairs(1000, 0, 1); Assert.AreEqual(1000, minMaxPairs.GetLength(0)); for (int p = 0; p < 1000; ++p) { int min = minMaxPairs[p, 0]; int max = minMaxPairs[p, 1]; Assert.IsTrue(min <= max); Assert.IsTrue(min >= 0 && min <= 1); Assert.IsTrue(max >= 0 && max <= 1); } }
public HeapsTestSuite() { _startingValuesSmall = InputGenerator.GenerateRandomInts(_startingValuesCountSmall); _startingKeyValuePairsSmall = _startingValuesSmall .Select(v => new KeyValuePair <int, int>(++_key, v)) .ToList(); _key = 0; _startingValuesBig = InputGenerator.GenerateRandomInts(_startingValuesCountBig); _startingKeyValuePairsBig = _startingValuesBig .Select(v => new KeyValuePair <int, int>(++_key, v)) .ToList(); _randomOperations = InputGenerator.GenerateRandomInts(_randomOperationsCount, 1, 4); _randomValues = InputGenerator.GenerateRandomInts(_randomOperationsCount); var randomPrimOperations = new List <Tuple <int, int> >(); int extractOperationCount = 0; var rand = InputGenerator.Rand; while (extractOperationCount != _startingValuesCountBig) { int operation = rand.Next(1, 6 + 1); if (operation == 1) { ++extractOperationCount; randomPrimOperations.Add(null); } else { randomPrimOperations.Add(Tuple.Create(rand.Next(1, _startingValuesCountBig + 1), rand.Next())); } } _randomPrimOperations = randomPrimOperations; }
public void InputGeneratorCreatesOneExamplesTable() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature", "", "Scenario Outline: my new scenario outline", "\tGiven I have a step", "", "Examples:", "\t| a | b | c |", "\t| 1 | 2 | 3 |" }; var features = generator.Load(contents); Assert.AreEqual(1, features[0].Scenarios.Count, "scenario count mismatch"); Assert.IsNotNull(((NodeScenarioOutline)features[0].Scenarios[0]).Examples); Assert.AreEqual(2, ((NodeScenarioOutline)features[0].Scenarios[0]).Examples.Rows.Count, "examples row count mismatch"); Assert.AreEqual("a", ((NodeScenarioOutline)features[0].Scenarios[0]).Examples.Rows[0][0]); Assert.AreEqual("b", ((NodeScenarioOutline)features[0].Scenarios[0]).Examples.Rows[0][1]); Assert.AreEqual("c", ((NodeScenarioOutline)features[0].Scenarios[0]).Examples.Rows[0][2]); Assert.AreEqual("1", ((NodeScenarioOutline)features[0].Scenarios[0]).Examples.Rows[1][0]); Assert.AreEqual("2", ((NodeScenarioOutline)features[0].Scenarios[0]).Examples.Rows[1][1]); Assert.AreEqual("3", ((NodeScenarioOutline)features[0].Scenarios[0]).Examples.Rows[1][2]); }
/// <summary> /// Go to the previous "page" /// </summary> /// <returns>bool if this worked</returns> public bool Previous() { var result = false; ScrollInfo scrollInfoBefore; var hasScrollInfo = TryRetrievePosition(out scrollInfoBefore); switch (ScrollMode) { case ScrollModes.KeyboardPageUpDown: result = InputGenerator.KeyPress(VirtualKeyCodes.PRIOR) == 2; break; case ScrollModes.WindowsMessage: result = SendScrollMessage(ScrollBarCommands.SB_PAGEUP); break; case ScrollModes.AbsoluteWindowMessage: if (!hasScrollInfo) { return(false); } // Calculate previous position, clone the scrollInfoBefore var scrollInfoForPrevious = scrollInfoBefore; scrollInfoForPrevious.Position = Math.Max(scrollInfoBefore.Minimum, scrollInfoBefore.Position - (int)scrollInfoBefore.PageSize); result = ApplyPosition(ref scrollInfoForPrevious); break; case ScrollModes.MouseWheel: var bounds = ScrollingWindow.GetInfo().Bounds; var middlePoint = new NativePoint(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2); result = InputGenerator.MoveMouseWheel(WheelDelta, middlePoint) == 1; break; } return(result); }
/// <summary> /// Set the window as foreground window /// </summary> /// <param name="interopWindow">The window to bring to the foreground</param> /// <param name="workaround">bool with true to use a trick (press Alt) to really bring the window to the foreground</param> public static async Task ToForegroundAsync(this IInteropWindow interopWindow, bool workaround = true) { // Nothing we can do if it's not visible! if (!interopWindow.IsVisible()) { return; } // Window is already the foreground window if (User32Api.GetForegroundWindow() == interopWindow.Handle) { return; } if (interopWindow.IsMinimized()) { interopWindow.Restore(); while (interopWindow.IsMinimized()) { await Task.Delay(50).ConfigureAwait(false); } } // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms633539(v=vs.85).aspx if (workaround) { // Simulate an "ALT" key press, make it double to remove menu activation InputGenerator.KeyPress(VirtualKeyCodes.MENU, VirtualKeyCodes.MENU); } // Show window in forground. User32Api.BringWindowToTop(interopWindow.Handle); User32Api.SetForegroundWindow(interopWindow.Handle); }
private void ParseMouseEvent(string mouseEvent) { string[] words = mouseEvent.Split('+'); if (words[0] == "LEFTDOWN") { InputGenerator.SendLeftDown(int.Parse(words[1]), int.Parse(words[2])); } if (words[0] == "LEFTUP") { InputGenerator.SendLeftUp(int.Parse(words[1]), int.Parse(words[2])); } if (words[0] == "MOVE") { InputGenerator.SendMove(int.Parse(words[1]), int.Parse(words[2])); } if (words[0] == "RIGHTUP") { InputGenerator.SendRightUp(int.Parse(words[1]), int.Parse(words[2])); } if (words[0] == "RIGHTDOWN") { InputGenerator.SendRightDown(int.Parse(words[1]), int.Parse(words[2])); } if (words[0] == "WHEEL") { InputGenerator.SendWheel(int.Parse(words[1]), int.Parse(words[2]), int.Parse(words[3])); } }
public void InputGeneratorCreatesSecondFeatureWithHook() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "@f1", "Feature: feature1", "", "@s1", "Scenario: scenario1", "", "@f2", "Feature: feature2", "", "@s2", "Scenario: scenario2", }; var features = generator.Load(contents); Assert.AreEqual(2, features.Count, "feature count mismatch"); VerifyFeature(features[0], "1"); VerifyFeature(features[1], "2"); }
public void ComputeActive() { var cortex = new Cortex( new CortexCreationOptions { CortexShape = new int[] { 32, 32 }, InputShape = new int[] { 20, 20 }, ConnectedPermanenceThreshold = 0.5, PotentialSynapsePercent = 0.75 } ); var sp = new SpatialPooler( new SpatialPoolerCreationOptions { ActivationsPerInhibitionRegion = 10, StimulusThreshold = 1.0, SynapticPermanenceInc = 0.1, SynapticPermanenceDec = 0.02, BoostStrength = 100, DutyCycleLength = 1000 }, cortex ); var inputs = InputGenerator <double> .SinWave(1, 0, Math.PI, 50); foreach (var input in inputs) { sp.ProcessAndLearn(input); } }
public void SetUp() { wascalled = false; inputReader = new InputReader(); generator = Substitute.For <InputGenerator> (); inputReader.SetGenerator(generator); }
public void MergeSortedArrays() { CollectionAssert.AreEqual(new int[0], IEnumerableHelper.MergeSortedArrays(new int[0], new int[0])); CollectionAssert.AreEqual(new[] { 1 }, IEnumerableHelper.MergeSortedArrays(new[] { 1 }, new int[0])); CollectionAssert.AreEqual(new[] { 1 }, IEnumerableHelper.MergeSortedArrays(new int[0], new[] { 1 })); CollectionAssert.AreEqual(new[] { 1, 1 }, IEnumerableHelper.MergeSortedArrays(new int[0], new[] { 1, 1 })); CollectionAssert.AreEqual(new[] { 1, 1, 1 }, IEnumerableHelper.MergeSortedArrays(new[] { 1 }, new[] { 1, 1 })); CollectionAssert.AreEqual(new[] { 1, 1, 2, 2, 3, 3, 4, 4 }, IEnumerableHelper.MergeSortedArrays(new[] { 1, 1, 2, 3, 4, 4 }, new[] { 2, 3 })); for (int i = 0; i < 100; ++i) { for (int j = 0; j < 100; ++j) { var firstArray = InputGenerator.GenerateRandomInts(i); var secondArray = InputGenerator.GenerateRandomInts(i); Array.Sort(firstArray); Array.Sort(secondArray); CollectionAssert.AreEqual(firstArray.Concat(secondArray).OrderBy(v => v).ToArray(), IEnumerableHelper.MergeSortedArrays(firstArray, secondArray)); } } }
public void InputGeneratorParameterizesFromExampleTable() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature", "", "Scenario Outline: my new scenario outline", "\tGiven I have a step with example data '<a>'", "\tGiven I have a step with example data <b>", "", "Examples:", "\t| a | b | c |", "\t| 1 | 2 | 3 |" }; var features = generator.Load(contents); Assert.AreEqual(1, features[0].Scenarios[0].Steps[0].Parameters.Count, "parameter count mismatch"); Assert.IsTrue(features[0].Scenarios[0].Steps[0].Parameters[0].IsFromExampleTable, "parameter not from example table"); Assert.AreEqual("p0", features[0].Scenarios[0].Steps[0].Parameters[0].Name); Assert.AreEqual("a", features[0].Scenarios[0].Steps[0].Parameters[0].Value); Assert.AreEqual(1, features[0].Scenarios[0].Steps[1].Parameters.Count, "parameter count mismatch"); Assert.IsTrue(features[0].Scenarios[0].Steps[1].Parameters[0].IsFromExampleTable, "parameter not from example table"); Assert.AreEqual("p0", features[0].Scenarios[0].Steps[1].Parameters[0].Name); Assert.AreEqual("b", features[0].Scenarios[0].Steps[1].Parameters[0].Value); }
public TriesTestSuite() { var rand = InputGenerator.Rand; _seedRandomStrings = new string[_stringCount]; for (int i = 0; i < _stringCount; ++i) { _seedRandomStrings[i] = InputGenerator.GenerateRandomString(rand.Next(1, _stringMaxLength + 1), 'A', 'Z'); } _searchRandomStrings = new string[_stringCount]; for (int i = 0; i < _stringCount; ++i) { _searchRandomStrings[i] = InputGenerator.GenerateRandomString(rand.Next(1, _stringMaxLength + 1), 'A', 'Z'); } _searchRandomPrefixGroupedStrings = new string[_stringCount]; for (int i = 0; i < _prefixGroupCount; ++i) { string prefix = InputGenerator.GenerateRandomString(_prefixLength, 'A', 'Z'); for (int j = 0; j < _prefixGroupSize; ++j) { _searchRandomPrefixGroupedStrings[i * _prefixGroupSize + j] = prefix + InputGenerator.GenerateRandomString(rand.Next(1, _stringMaxLength + 1 - _prefixLength), 'A', 'z'); } } }
public void GenerateEvenOddPairs() { int[,] evenOddPairs = InputGenerator.GenerateRandomEvenOddPairs(1000, 1, 100); Assert.AreEqual(1000, evenOddPairs.GetLength(0)); for (int p = 0; p < 1000; ++p) { int even = evenOddPairs[p, 0]; int odd = evenOddPairs[p, 1]; Assert.IsTrue(even % 2 == 0); Assert.IsTrue(odd % 2 == 1); Assert.IsTrue(even >= 1 && even <= 1000); Assert.IsTrue(odd >= 1 && odd <= 1000); } evenOddPairs = InputGenerator.GenerateRandomEvenOddPairs(1000, 0, 1); Assert.AreEqual(1000, evenOddPairs.GetLength(0)); for (int p = 0; p < 1000; ++p) { int even = evenOddPairs[p, 0]; int odd = evenOddPairs[p, 1]; Assert.AreEqual(0, even); Assert.AreEqual(1, odd); } }
public void CompareEulerTours() { var randomTree = InputGenerator.GenerateRandomRootedTree(1000, 1, 3); CollectionAssert.AreEqual( randomTree.GetEulerTourUsingStack().ToArray(), randomTree.GetEulerTourUsingRecursion()); }
public void SetUp() { inputReader = new InputReader(); generator = Substitute.For <InputGenerator> (); inputReader.SetGenerator(generator); recognizer = new RayCastGenerator(); }
public void InputGeneratorHandlesLeadingNumbersInFeatureName() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: 123:Abc123_-~!@#$%^&*()[].," }; var features = generator.Load(contents); Assert.AreEqual("_23Abc123", features[0].Name); }
public void InputGeneratorHandlesInvalidCharactersInFeatureName() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: :Abc123_-~!@#$%^&*()[].," }; var features = generator.Load(contents); Assert.AreEqual("Abc123", features[0].Name); }
private void prepare() { WriteLine("3"); Thread.Sleep(1000); WriteLine("2"); Thread.Sleep(1000); WriteLine("1"); Thread.Sleep(1000); InputGenerator.KeyPress(VirtualKeyCodes.KEY_K); Thread.Sleep(233); }
private static RootedTree[] GetRandomTrees(int count, int vertexCount, int minChildCount, int maxChildCount) { var randomTrees = new RootedTree[count]; for (int i = 0; i < count; ++i) { randomTrees[i] = InputGenerator.GenerateRandomRootedTree(vertexCount, minChildCount, maxChildCount); } return(randomTrees); }
public void Solve_TrickyCase2() { var seed = 1448362612; var difficultyLevel = 1; var generatorConfig = new DifficultyLevels().GetConfig(seed, difficultyLevel); var testData = new InputGenerator(generatorConfig).Generate(); var result = Submission?.Solve(testData.Input); Assert.AreEqual(testData.Solution, result); }
public void InputGeneratorHandlesInvalidCharactersInScenarioName() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature", "", "Scenario: :Abc123_-~!@#$%^&*()[].," }; var features = generator.Load(contents); Assert.AreEqual("Abc123", features[0].Scenarios[0].Name); }
private void ParseKBEvent(string kbEvent) { string[] words = kbEvent.Split(new char[] { '+' }, 2); if (words[0] == "UP") { InputGenerator.SendKeyUP(words[1]); } if (words[0] == "DOWN") { InputGenerator.SendKeyDown(words[1]); } }
public void InputGeneratorCreatesOneFeatureWithoutScenarios() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature" }; var features = generator.Load(contents); Assert.AreEqual(1, features.Count, "feature count mismatch"); Assert.AreEqual(0, features[0].Scenarios.Count, "scenario count mismatch"); Assert.AreEqual("MyNewFeature", features[0].Name); }
public void InputGeneratorCreatesOneScenarioWithoutSteps() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature", "", "Scenario: my new scenario" }; var features = generator.Load(contents); Assert.AreEqual("MyNewScenario", features[0].Scenarios[0].Name); Assert.AreEqual(0, features[0].Scenarios[0].Steps.Count, "step count mismatch"); }
public void InputGeneratorHandlesLeadingNumbersInScenarioName() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature", "", "Scenario: 123:Abc123_-~!@#$%^&*()[].," }; var features = generator.Load(contents); Assert.AreEqual("_23Abc123", features[0].Scenarios[0].Name); }
public void InputGeneratorHandlesLeadingNumbersInStepName() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature", "", "Scenario: my new scenario", "\tGiven 123:Abc123_-~!@#$%^&*()[].,", }; var features = generator.Load(contents); Assert.AreEqual("Given123Abc123", features[0].Scenarios[0].Steps[0].Name); }
public void InputGeneratorCreatesOneStep() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature", "", "Scenario: my new scenario", "\tGiven I have a step" }; var features = generator.Load(contents); Assert.AreEqual(1, features[0].Scenarios[0].Steps.Count, "step count mismatch"); Assert.AreEqual("GivenIHaveAStep", features[0].Scenarios[0].Steps[0].Name); Assert.AreEqual(0, features[0].Scenarios[0].Steps[0].Parameters.Count, "parameter count mismatch"); }
public void InputGeneratorCreatesOneStepWithOneParameterThatHasSpaces() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature", "", "Scenario: my new scenario", "\tGiven I have a step with one 'parameter that has spaces'" }; var features = generator.Load(contents); Assert.AreEqual(1, features[0].Scenarios[0].Steps.Count, "step count mismatch"); Assert.AreEqual("GivenIHaveAStepWithOne", features[0].Scenarios[0].Steps[0].Name); Assert.AreEqual(1, features[0].Scenarios[0].Steps[0].Parameters.Count, "parameter count mismatch"); Assert.AreEqual("parameter that has spaces", features[0].Scenarios[0].Steps[0].Parameters[0].Value); }
public void InputGeneratorCreatesOneFeatureHook() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "@feature", "Feature: my new feature", "", "Scenario: my new scenario" }; var features = generator.Load(contents); Assert.AreEqual(1, features[0].Hooks.Count, "feature hook count mismatch"); Assert.AreEqual("feature", features[0].Hooks[0].Name); Assert.AreEqual(1, features[0].Scenarios[0].Hooks.Count, "scenario hook count mismatch"); Assert.AreEqual("feature", features[0].Scenarios[0].Hooks[0].Name); }
public void InputGeneratorCreatesOneStepWithOneParamaterAndTable() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature", "", "Scenario: my new scenario", "\tGiven I have a step with 'one' parameter and:", "\t\t| a | b | c |", "\t\t| 1 | 2 | 3 |" }; var features = generator.Load(contents); Assert.AreEqual("GivenIHaveAStepWithParameterAnd", features[0].Scenarios[0].Steps[0].Name); Assert.AreEqual(1, features[0].Scenarios[0].Steps[0].Parameters.Count, "parameter count mismatch"); Assert.AreEqual("one", features[0].Scenarios[0].Steps[0].Parameters[0].Value); Assert.AreEqual(2, features[0].Scenarios[0].Steps[0].Rows.Count, "table row count mismatch"); }
public void InputGeneratorCreatesOneStepWithOneParameterAndOneStepWithoutParameters() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature", "", "Scenario: my new scenario", "\tGiven I have a step with one 'parameter'", "\tThen I have two steps" }; var features = generator.Load(contents); Assert.AreEqual(2, features[0].Scenarios[0].Steps.Count, "step count mismatch"); Assert.AreEqual("GivenIHaveAStepWithOne", features[0].Scenarios[0].Steps[0].Name); Assert.AreEqual(1, features[0].Scenarios[0].Steps[0].Parameters.Count, "parameter count mismatch"); Assert.AreEqual("parameter", features[0].Scenarios[0].Steps[0].Parameters[0].Value); Assert.AreEqual("ThenIHaveTwoSteps", features[0].Scenarios[0].Steps[1].Name); Assert.AreEqual(0, features[0].Scenarios[0].Steps[1].Parameters.Count, "parameter count mismatch"); }
public void InputGeneratorCreatesOneStepWithTable() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature", "", "Scenario: my new scenario", "\tGiven I have a step:", "\t\t| a | b | c |", "\t\t| 1 | 2 | 3 |" }; var features = generator.Load(contents); Assert.AreEqual("GivenIHaveAStep", features[0].Scenarios[0].Steps[0].Name); Assert.AreEqual(2, features[0].Scenarios[0].Steps[0].Rows.Count, "table row count mismatch"); Assert.AreEqual("a", features[0].Scenarios[0].Steps[0].Rows[0][0]); Assert.AreEqual("b", features[0].Scenarios[0].Steps[0].Rows[0][1]); Assert.AreEqual("c", features[0].Scenarios[0].Steps[0].Rows[0][2]); Assert.AreEqual("1", features[0].Scenarios[0].Steps[0].Rows[1][0]); Assert.AreEqual("2", features[0].Scenarios[0].Steps[0].Rows[1][1]); Assert.AreEqual("3", features[0].Scenarios[0].Steps[0].Rows[1][2]); }
public void InputGeneratorParametersAreCaseSensitive() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature", "", "Scenario: my new scenario", "\tGiven I have a step with 'cAsE sEnSiTiVe' parameter" }; var features = generator.Load(contents); Assert.AreEqual(1, features[0].Scenarios[0].Steps.Count, "step count mismatch"); Assert.AreEqual("GivenIHaveAStepWithParameter", features[0].Scenarios[0].Steps[0].Name); Assert.AreEqual(1, features[0].Scenarios[0].Steps[0].Parameters.Count, "parameter count mismatch"); Assert.AreEqual("cAsE sEnSiTiVe", features[0].Scenarios[0].Steps[0].Parameters[0].Value); }
public void InputGeneratorCreatesOneStepWithTwoParameters() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature", "", "Scenario: my new scenario", "\tGiven I have a step with 'two' amazing 'parameters'" }; var features = generator.Load(contents); Assert.AreEqual(1, features[0].Scenarios[0].Steps.Count, "step count mismatch"); Assert.AreEqual("GivenIHaveAStepWithAmazing", features[0].Scenarios[0].Steps[0].Name); Assert.AreEqual(2, features[0].Scenarios[0].Steps[0].Parameters.Count, "parameter count mismatch"); Assert.AreEqual("p0", features[0].Scenarios[0].Steps[0].Parameters[0].Name); Assert.AreEqual("p1", features[0].Scenarios[0].Steps[0].Parameters[1].Name); Assert.AreEqual("two", features[0].Scenarios[0].Steps[0].Parameters[0].Value); Assert.AreEqual("parameters", features[0].Scenarios[0].Steps[0].Parameters[1].Value); }
public void InputGeneratorParameterTypesAreCorrect() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "Feature: my new feature", "", "Scenario: my new scenario", "\tGiven I have a step with '1' int", "\tGiven I have a step with '1.1' decimal", "\tGiven I have a step with 'one1' string" }; var features = generator.Load(contents); Assert.AreEqual(3, features[0].Scenarios[0].Steps.Count, "step count mismatch"); Assert.AreEqual(1, features[0].Scenarios[0].Steps[0].Parameters.Count, "parameter count mismatch on step 1"); Assert.AreEqual(1, features[0].Scenarios[0].Steps[1].Parameters.Count, "parameter count mismatch on step 2"); Assert.AreEqual(1, features[0].Scenarios[0].Steps[2].Parameters.Count, "parameter count mismatch on step 3"); Assert.AreEqual("int", features[0].Scenarios[0].Steps[0].Parameters[0].Type); Assert.AreEqual("decimal", features[0].Scenarios[0].Steps[1].Parameters[0].Type); Assert.AreEqual("string", features[0].Scenarios[0].Steps[2].Parameters[0].Type); }
public void InputGeneratorHandlesDuplicateHooks() { InputGenerator generator = new InputGenerator(); string[] contents = new string[] { "@f1", "@f1", "Feature: my new feature", "", "@f1", "@f1", "@s1", "@s1", "Scenario: my new scenario" }; var features = generator.Load(contents); Assert.AreEqual(1, features[0].Hooks.Count, "feature hook count mismatch"); Assert.AreEqual("f1", features[0].Hooks[0].Name); Assert.AreEqual(2, features[0].Scenarios[0].Hooks.Count, "feature hook count mismatch"); Assert.AreEqual("f1", features[0].Scenarios[0].Hooks[0].Name); Assert.AreEqual("s1", features[0].Scenarios[0].Hooks[1].Name); }