public void Constructor_InvalidUrl_ThrowsArgumentException() { // Arrange // Act TestDelegate[] actions = { () => new NavigateCommand(""), () => new NavigateCommand(" "), }; // Assert AssertMultiple.Throws <ArgumentException>(actions); }
public void GetDefault_EmptyType_ThrowsArgumentException() { // Arrange // Act TestDelegate[] actions = { () => WebDriverConfigs.GetDefault(""), () => WebDriverConfigs.GetDefault(" ") }; // Assert AssertMultiple.Throws <ArgumentException>(actions); }
public void Constructor_InvalidUrl_ThrowsUriFormatException() { // Arrange // Act TestDelegate[] actions = { () => new NavigateCommand("wb tstr"), () => new NavigateCommand("<('-'<)"), }; // Assert AssertMultiple.Throws <UriFormatException>(actions); }
public void GetFromPreset_EmptyPreset_ThrowsArgumentException() { // Arrange // Act TestDelegate[] actions = { () => WebDriverConfigs.GetFromPreset(WebDriverType.Chrome, ""), () => WebDriverConfigs.GetFromPreset(WebDriverType.Chrome, " ") }; // Assert AssertMultiple.Throws <ArgumentException>(actions); }
public void Constructor_NullSelectorOffset_ThrowsArgumentNullException() { // Arrange string selector = null; // Act TestDelegate[] actions = { () => new DragCommand(selector, 0, 0), () => new DragCommand(0, 0, selector), }; // Assert AssertMultiple.Throws <ArgumentNullException>(actions); }
public void Constructor_NullElementOffset_ThrowsArgumentNullException() { // Arrange IElement element = null; // Act TestDelegate[] actions = { () => new DragCommand(element, 0, 0), () => new DragCommand(0, 0, element), }; // Assert AssertMultiple.Throws <ArgumentNullException>(actions); }
public void Constructor_InvalidFileName_ThrowsArgumentException() { // Arrange // Act TestDelegate[] actions = { () => new ScreenshotCommand("", DefaultDirectoryPath), () => new ScreenshotCommand(" ", DefaultDirectoryPath), () => new ScreenshotCommand("filename.*", DefaultDirectoryPath), () => new ScreenshotCommand("filename<?>", DefaultDirectoryPath), }; // Assert AssertMultiple.Throws <ArgumentException>(actions); }
public void IsValidFileName_ValidInput_ReturnsTrue() { // Arrange // Act Func <bool>[] actions = { () => MultiPurposeValidator.IsValidFileName("image.jpg"), () => MultiPurposeValidator.IsValidFileName("image.unkown"), () => MultiPurposeValidator.IsValidFileName("directory/filename.png"), () => MultiPurposeValidator.IsValidFileName("filename_noext") }; // Assert AssertMultiple.Returns(actions, true); }
public void Constructor_InvalidWidthHeight_ThrowsArgumentException() { // Arrange int invalid = -1; int valid = 0; // Act TestDelegate[] actions = { () => new ResizeCommand(invalid, valid), () => new ResizeCommand(valid, invalid), }; // Assert AssertMultiple.Throws <ArgumentException>(actions); }
public void Constructor_InvalidDirectoryPath_ThrowsArgumentException() { // Arrange // Act TestDelegate[] actions = { () => new ScreenshotCommand(DefaultFileName, ""), () => new ScreenshotCommand(DefaultFileName, " "), () => new ScreenshotCommand(DefaultFileName, "path.*"), () => new ScreenshotCommand(DefaultFileName, "path<?>"), }; // Assert AssertMultiple.Throws <ArgumentException>(actions); }
public void Constructor_ValidReturnType_DoesNotThrow() { // Arrange // Act TestDelegate[] actions = { () => new ExecuteJsCommand <string>(DefaultJsExpression), () => new ExecuteJsCommand <bool>(DefaultJsExpression), () => new ExecuteJsCommand <long>(DefaultJsExpression), () => new ExecuteJsCommand <IElement>(DefaultJsExpression), }; // Assert AssertMultiple.DoesNotThrow(actions); }
public void Constructor_ValidUrl_DoesNotThrow() { // Arrange // Act TestDelegate[] actions = { () => new NavigateCommand("http://www.wbtstr.net"), () => new NavigateCommand("http://wbtstr.net"), () => new NavigateCommand("www.wbtstr.net"), () => new NavigateCommand("wbtstr.net"), }; // Assert AssertMultiple.DoesNotThrow(actions); }
public void IsValidDirectoryPath_ValidInput_ReturnsTrue() { // Arrange // Act Func <bool>[] actions = { () => MultiPurposeValidator.IsValidFileName("sub/sub/sub\\sap\\sap\\sap"), () => MultiPurposeValidator.IsValidFileName("%TEMP%"), () => MultiPurposeValidator.IsValidFileName("C://Windows/System32"), () => MultiPurposeValidator.IsValidFileName("folder_only") }; // Assert AssertMultiple.Returns(actions, true); }
public void IsValidFileName_InvalidInput_ReturnsFalse() { // Arrange // Act Func <bool>[] actions = { () => MultiPurposeValidator.IsValidFileName(""), () => MultiPurposeValidator.IsValidFileName(" "), () => MultiPurposeValidator.IsValidFileName("file*name"), () => MultiPurposeValidator.IsValidFileName("<?>") }; // Assert AssertMultiple.Returns(actions, false); }
public void IsValidDirectoryPath_InvalidInput_DoesNotThrowException() { // Arrange // Act TestDelegate[] actions = { () => MultiPurposeValidator.IsValidFileName(""), () => MultiPurposeValidator.IsValidFileName(" "), () => MultiPurposeValidator.IsValidFileName("directory*path"), () => MultiPurposeValidator.IsValidFileName("<?>") }; // Assert AssertMultiple.DoesNotThrow(actions); }
public void Constructor_InvalidReturnType_ThrowsArgumentException() { // Arrange // Act TestDelegate[] actions = { () => new ExecuteJsCommand <int>(DefaultJsExpression), () => new ExecuteJsCommand <short>(DefaultJsExpression), () => new ExecuteJsCommand <object>(DefaultJsExpression), () => new ExecuteJsCommand <IWebElement>(DefaultJsExpression), () => new ExecuteJsCommand <IEnumerable>(DefaultJsExpression), }; // Assert AssertMultiple.Throws <ArgumentException>(actions); }
public void AssertionShouldBeRunMultipleTimes() { try { AssertMultiple.Multiple(() => { (2 + 2).Should().Be(5); (2 + 2).Should().Be(6); }); } catch (AssertionException exception) { Console.WriteLine(exception.Message); exception.Message.Should().Contain("to be 5, but found 4") .And.Subject.Should().Contain("to be 6, but found 4."); // ⬆ differs here } }
public void Constructor_InvalidOffsetSelector_ThrowsArgumentException() { // Arrange string selector = DefaultSelector; // Act TestDelegate[] actions = { () => new DragCommand(selector, -1, 0), () => new DragCommand(selector, 0, -1), () => new DragCommand(selector, -1, -1), () => new DragCommand(-1, 0, selector), () => new DragCommand(0, -1, selector), () => new DragCommand(-1, -1, selector), }; // Assert AssertMultiple.Throws <ArgumentException>(actions); }
public void Constructor_NullSelector_ThrowsArgumentNullException() { // Arrange string selector = null; IElement element = Substitute.For <IElement>(); // Act TestDelegate[] actions = { () => new DragCommand(selector, selector), () => new DragCommand(selector, DefaultSelector), () => new DragCommand(DefaultSelector, selector), () => new DragCommand(selector, element), () => new DragCommand(element, selector) }; // Assert AssertMultiple.Throws <ArgumentException>(actions); }
public void Constructor_InvalidOffsetElement_ThrowsArgumentException() { // Arrange IElement element = Substitute.For <IElement>(); // Act TestDelegate[] actions = { () => new DragCommand(element, -1, 0), () => new DragCommand(element, 0, -1), () => new DragCommand(element, -1, -1), () => new DragCommand(-1, 0, element), () => new DragCommand(0, -1, element), () => new DragCommand(-1, -1, element), }; // Assert AssertMultiple.Throws <ArgumentException>(actions); }
public async Task AsyncAssertionShouldBeRunMultipleTimes() { try { await AssertMultiple.MultipleAsync(async() => { (2 + 2).Should().Be(5); await Task.Delay(200); (2 + 2).Should().Be(6); }); } catch (AssertionException exception) { Console.WriteLine(exception.Message); exception.Message.Should().Contain("to be 5, but found 4") .And.Subject.Should().Contain("to be 6, but found 4."); // ⬆ differs here } }
public void Constructor_NullElement_ThrowArgumentNullException() { // Arrange IElement elementA = null; IElement elementB = null; IElement elementC = Substitute.For <IElement>(); // Act TestDelegate[] actions = { () => new DragCommand(elementA, elementB), () => new DragCommand(elementC, elementB), () => new DragCommand(elementA, elementC), () => new DragCommand(elementA, DefaultSelector), () => new DragCommand(DefaultSelector, elementB), }; // Assert AssertMultiple.Throws <ArgumentNullException>(actions); }
public void GetDefault_NonDefaultEnumTypes_DoesNotThrow() { // Arrange var webDriverTypes = Enum.GetValues(typeof(WebDriverType)).Cast <WebDriverType>(); // Act var actions = new List <TestDelegate>(); foreach (var webDriverType in webDriverTypes) { if (webDriverType == default(WebDriverType)) { continue; } actions.Add(() => WebDriverConfigs.GetDefault(webDriverType)); } // Assert AssertMultiple.DoesNotThrow(actions); }
public void Constructor_ValidInput_DoesNotThrow() { // Arrange string selector = DefaultSelector; IElement element = Substitute.For <IElement>(); // Act TestDelegate[] actions = { () => new DragCommand(selector, selector), () => new DragCommand(element, element), () => new DragCommand(selector, 0, 0), () => new DragCommand(element, 0, 0), () => new DragCommand(0, 0,selector), () => new DragCommand(0, 0,element), () => new DragCommand(0, 0, 0,0), }; // Assert AssertMultiple.DoesNotThrow(actions); }