public void CreateCommandXElement_NullActionResultExecutor_ThrowsArgumentNullException() { var elementCommand = new ElementCommand("command", "#selector", "<div>Some HTML!</div>"); Action action = () => elementCommand.CreateCommandXElement(null); action.ShouldThrow<ArgumentNullException>(); }
public void Equals_Html_OtherElementCommandPropertiesDifferent_ReturnsFalse( string command0, string selector0, string html0, string command1, string selector1, string html1) { var elementCommand0 = new ElementCommand(command0, selector0, html0); var elementCommand1 = new ElementCommand(command1, selector1, html1); var result = elementCommand0.Equals(elementCommand1); result.Should().BeFalse(); }
public void CreateCommandXElement_RawHtml_ReturnsCorrectXElement() { var command = "command"; var selector = "#selector"; var html = "<div>Some HTML!</div>"; var elementCommand = new ElementCommand(command, selector, html); var controllerContext = Substitute.For<ControllerContext>(); var actionResultExecutor = Substitute.For<ActionResultExecutor>(controllerContext); var result = elementCommand.CreateCommandXElement(actionResultExecutor); result.Name.Should().Be((XName)command); result.Should().HaveAttribute("select", selector); result.FirstNode.NodeType.Should().Be(XmlNodeType.CDATA); result.Value.Should().Be(html); }
/// <summary> /// Determines whether the given <see cref="ElementCommand"/> equals this <see cref="ElementCommand"/>. /// </summary> /// <param name="other">The other <see cref="ElementCommand"/>.</param> /// <returns>Whether the given <see cref="ElementCommand"/> equals this <see cref="ElementCommand"/>.</returns> public bool Equals(ElementCommand other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(_command.Equals(other._command, StringComparison.OrdinalIgnoreCase) && _selector.Equals(other._selector, StringComparison.Ordinal) && ((_html != null && other._html != null && _html.Equals(other._html, StringComparison.InvariantCulture)) || (_partial != null && other._partial != null && _partial.Equals(other._partial)))); }
public void GetHashCode_PartialViewResult_PartialViewResultsDifferent_ReturnsDifferentHashCode() { var command = "command"; var selector = "#selector"; var elementCommand0 = new ElementCommand(command, selector, new PartialViewResult()); var elementCommand1 = new ElementCommand(command, selector, new PartialViewResult()); var result0 = elementCommand0.GetHashCode(); var result1 = elementCommand1.GetHashCode(); result0.Should().NotBe(result1); }
public void GetHashCode_OneHtmlAndOnePartialViewResult_ReturnsFalse() { var command = "command"; var selector = "#selector"; var elementCommand0 = new ElementCommand(command, selector, "<div>Some HTML!</div>"); var elementCommand1 = new ElementCommand(command, selector, new PartialViewResult()); var result0 = elementCommand0.GetHashCode(); var result1 = elementCommand1.GetHashCode(); result0.Should().NotBe(result1); }
public void GetHashCode_Html_ElementCommandsHaveSameProperties_ReturnsSameHashCode( string command0, string selector0, string html0, string command1, string selector1, string html1) { var elementCommand0 = new ElementCommand(command0, selector0, html0); var elementCommand1 = new ElementCommand(command1, selector1, html1); var result0 = elementCommand0.GetHashCode(); var result1 = elementCommand1.GetHashCode(); result0.Should().Be(result1); }
public void Equals_PartialViewResult_PartialViewResultsDifferent_ReturnsFalse() { var command = "command"; var selector = "#selector"; var elementCommand0 = new ElementCommand(command, selector, new PartialViewResult()); var elementCommand1 = new ElementCommand(command, selector, new PartialViewResult()); var result = elementCommand0.Equals(elementCommand1); result.Should().BeFalse(); }
public void Equals_PartialViewResult_OtherElementCommandPropertiesSame_ReturnsTrue() { var command = "command"; var selector = "#selector"; var partialViewResult = new PartialViewResult(); var elementCommand0 = new ElementCommand(command, selector, partialViewResult); var elementCommand1 = new ElementCommand(command, selector, partialViewResult); var result = elementCommand0.Equals(elementCommand1); result.Should().BeTrue(); }
public void Equals_OtherObjectIsNotAnElementCommand_ReturnsFalse() { var other = new object(); var elementCommand = new ElementCommand("command", "#selector", "<div>Some HTML!</div>"); var result = elementCommand.Equals(other); result.Should().BeFalse(); }
public void Equals_OtherElementCommandIsSameObject_ReturnsTrue() { var elementCommand = new ElementCommand("command", "#selector", "<div>Some HTML!</div>"); var result = elementCommand.Equals(elementCommand); result.Should().BeTrue(); }
public void Equals_OtherElementCommandIsNull_ReturnsFalse() { var elementCommand = new ElementCommand("command", "#selector", "<div>Some HTML!</div>"); ElementCommand other = null; var result = elementCommand.Equals(other); result.Should().BeFalse(); }
public void Equals_OneHtmlAndOnePartialViewResult_ReturnsFalse() { var command = "command"; var selector = "#selector"; var elementCommand0 = new ElementCommand(command, selector, "<div>Some HTML!</div>"); var elementCommand1 = new ElementCommand(command, selector, new PartialViewResult()); var result = elementCommand0.Equals(elementCommand1); result.Should().BeFalse(); }
/// <summary> /// Determines whether the given <see cref="ElementCommand"/> equals this <see cref="ElementCommand"/>. /// </summary> /// <param name="other">The other <see cref="ElementCommand"/>.</param> /// <returns>Whether the given <see cref="ElementCommand"/> equals this <see cref="ElementCommand"/>.</returns> public bool Equals(ElementCommand other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return _command.Equals(other._command, StringComparison.OrdinalIgnoreCase) && _selector.Equals(other._selector, StringComparison.Ordinal) && ((_html != null && other._html != null && _html.Equals(other._html, StringComparison.InvariantCulture)) || (_partial != null && other._partial != null && _partial.Equals(other._partial))); }