// Separate steps to select / generate with or without, error on the side of no conditionals in test code public void GenerateWithoutStartingText(LoremIpsum loremIpsum) { Amount.Clear(); Amount.SendKeys(loremIpsum.Amount); GenerationType(loremIpsum.TextGenerationType.ToString().ToLowerInvariant()).Click(); StartingText.Click(); GenerateLoremIpsum.Click(); }
// defining models from data passed through from step instead public void GenerateListWithoutStartText(TestData testData, int amount) { testData.LoremIpsum = new LoremIpsum { Amount = amount.ToString(), StartWithDefaultText = false, TextGenerationType = TextGenerationType.Lists }; Amount.Clear(); Amount.SendKeys(testData.LoremIpsum.Amount); GenerationType(testData.LoremIpsum.TextGenerationType.ToString().ToLowerInvariant()).Click(); StartingText.Click(); GenerateLoremIpsum.Click(); }
public void TestThrowsAlready() { string finalResult; using (var vault = _vaultGen()) { string originalValue = vault.CopyCurrentValue(TimeSpan.FromMilliseconds(50)); Assert.True(originalValue == StartingText); for (int i = 0; i < 3; ++i) { using var lck = vault.RoLock(); Assert.Equal(StartingText, lck.ToString()); } { using var lck = vault.RoLock(); try { string shouldntWork = vault.CopyCurrentValue(TimeSpan.FromMilliseconds(100)); Helper.WriteLine("You shouldn't ever see me: {0}.", shouldntWork); throw new ThrowsException(typeof(LockAlreadyHeldThreadException)); } catch (RwLockAlreadyHeldThreadException) { } catch (ThrowsException) { throw; } catch (Exception ex) { throw new ThrowsException(typeof(RwLockAlreadyHeldThreadException), ex); } } { using var finalLck = vault.RoLock(); Assert.True(finalLck.Contains("Hello")); Assert.True(finalLck.IndexOf("world") == StartingText.IndexOf("world", StringComparison.Ordinal)); Assert.True(finalLck.IndexOf("Clorton") < 0); Assert.False(finalLck.Contains("Clorton")); Assert.True(finalLck.Length == StartingText.Length); for (int i = 0; i < finalLck.Length; ++i) { Assert.Equal(finalLck[i], StartingText[i]); } try { char x = finalLck[finalLck.Length]; Helper.WriteLine("Never see me: {0}", x); throw new ThrowsException(typeof(IndexOutOfRangeException)); } catch (IndexOutOfRangeException) { } finalResult = finalLck.ToString(); } Assert.Equal(finalResult, originalValue); } Assert.Equal(finalResult, StartingText); Helper.WriteLine(finalResult); }