예제 #1
0
        public void CreateCommandXElement_NullActionResultExecutor_ThrowsArgumentNullException()
        {
            var evalCommand = new EvalCommand("script");

              Action action = () => evalCommand.CreateCommandXElement(null);

              action.ShouldThrow<ArgumentNullException>();
        }
        public TaconiteResult Execute(string script)
        {
            if (String.IsNullOrEmpty(script))
            throw new ArgumentNullException("script");

              var command = new EvalCommand(script);
              AddCommand(command);

              return this;
        }
        public TaconiteResult Execute(JavaScriptResult javaScriptResult)
        {
            if (javaScriptResult == null)
            throw new ArgumentNullException("javaScriptResult");

              var command = new EvalCommand(javaScriptResult);
              AddCommand(command);

              return this;
        }
예제 #4
0
        public void Equals_OneEvalCommandHasScriptAndOtherHasJavaScriptResult_ReturnsFalse()
        {
            var script = "console.log('weeeeeee')";
              var javaScriptResult = new JavaScriptResult();
              var evalCommand0 = new EvalCommand(script);
              var evalCommand1 = new EvalCommand(javaScriptResult);

              var result = evalCommand0.Equals(evalCommand1);

              result.Should().BeFalse();
        }
예제 #5
0
        public void Equals_OtherEvalCommandHasDifferentJavaScriptResult_ReturnsFalse()
        {
            var javaScriptResult0 = new JavaScriptResult();
              var javaScriptResult1 = new JavaScriptResult();
              var evalCommand0 = new EvalCommand(javaScriptResult0);
              var evalCommand1 = new EvalCommand(javaScriptResult1);

              var result = evalCommand0.Equals(evalCommand1);

              result.Should().BeFalse();
        }
예제 #6
0
        /// <summary>
        /// Determines whether the given <see cref="EvalCommand"/> equals this <see cref="EvalCommand"/>.
        /// </summary>
        /// <param name="other">The other <see cref="EvalCommand"/>.</param>
        /// <returns>Whether the given <see cref="EvalCommand"/> equals this <see cref="EvalCommand"/>.</returns>
        public bool Equals(EvalCommand other)
        {
            if (ReferenceEquals(null, other))
            return false;

              if (ReferenceEquals(this, other))
            return true;

              return (_script != null && other._script != null && _script.Equals(other._script, StringComparison.InvariantCulture))
              || (_javaScriptResult != null && other._javaScriptResult != null && _javaScriptResult.Equals(other._javaScriptResult));
        }
예제 #7
0
        public void CreateCommandXElement_RawScript_ReturnsCorrectXElement()
        {
            var script = "console.log('weeeeeee')";
              var evalCommand = new EvalCommand(script);
              var controllerContext = Substitute.For<ControllerContext>();
              var actionResultExecutor = Substitute.For<ActionResultExecutor>(controllerContext);

              var result = evalCommand.CreateCommandXElement(actionResultExecutor);

              result.Name.Should().Be((XName) "eval");
              result.Value.Should().Be(script);
        }
예제 #8
0
        public TaconiteResult Execute(JavaScriptResult javaScriptResult)
        {
            if (javaScriptResult == null)
            {
                throw new ArgumentNullException("javaScriptResult");
            }

            var command = new EvalCommand(javaScriptResult);

            AddCommand(command);

            return(this);
        }
예제 #9
0
        public TaconiteResult Execute(string script)
        {
            if (String.IsNullOrEmpty(script))
            {
                throw new ArgumentNullException("script");
            }

            var command = new EvalCommand(script);

            AddCommand(command);

            return(this);
        }
예제 #10
0
        /// <summary>
        /// Determines whether the given <see cref="EvalCommand"/> equals this <see cref="EvalCommand"/>.
        /// </summary>
        /// <param name="other">The other <see cref="EvalCommand"/>.</param>
        /// <returns>Whether the given <see cref="EvalCommand"/> equals this <see cref="EvalCommand"/>.</returns>
        public bool Equals(EvalCommand other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((_script != null && other._script != null && _script.Equals(other._script, StringComparison.InvariantCulture)) ||
                   (_javaScriptResult != null && other._javaScriptResult != null && _javaScriptResult.Equals(other._javaScriptResult)));
        }
예제 #11
0
        public void Equals_OtherEvalCommandHasSameScript_ReturnsTrue()
        {
            var script = "console.log('weeeeeee')";
              var evalCommand0 = new EvalCommand(script);
              var evalCommand1 = new EvalCommand(script);

              var result = evalCommand0.Equals(evalCommand1);

              result.Should().BeTrue();
        }
예제 #12
0
        public void GetHashCode_EvalCommandsHaveSameScript_ReturnsSameHashCode()
        {
            var script = "console.log('weeeeeee')";
              var evalCommand0 = new EvalCommand(script);
              var evalCommand1 = new EvalCommand(script);

              var result0 = evalCommand0.GetHashCode();
              var result1 = evalCommand1.GetHashCode();

              result0.Should().Be(result1);
        }
예제 #13
0
        public void Equals_OtherEvalCommandIsSameObject_ReturnsTrue()
        {
            var script = "console.log('weeeeeee')";
              var evalCommand = new EvalCommand(script);

              var result = evalCommand.Equals(evalCommand);

              result.Should().BeTrue();
        }
예제 #14
0
        public void Equals_OtherEvalCommandIsNull_ReturnsFalse()
        {
            var script = "console.log('weeeeeee')";
              var evalCommand0 = new EvalCommand(script);
              EvalCommand evalCommand1 = null;

              var result = evalCommand0.Equals(evalCommand1);

              result.Should().BeFalse();
        }
예제 #15
0
        public void Equals_OtherEvalCommandHasDifferentScript_ReturnsFalse()
        {
            var script0 = "console.log('weeeeeee')";
              var script1 = "console.log('no.')";
              var evalCommand0 = new EvalCommand(script0);
              var evalCommand1 = new EvalCommand(script1);

              var result = evalCommand0.Equals(evalCommand1);

              result.Should().BeFalse();
        }
예제 #16
0
        public void Equals_OtherEvalCommandHasSameJavaScriptResult_ReturnsTrue()
        {
            var javaScriptResult = new JavaScriptResult();
              var evalCommand0 = new EvalCommand(javaScriptResult);
              var evalCommand1 = new EvalCommand(javaScriptResult);

              var result = evalCommand0.Equals(evalCommand1);

              result.Should().BeTrue();
        }
예제 #17
0
        public void Equals_OtherObjectIsNotAnEvalCommand_ReturnsFalse()
        {
            var other = new object();
              var evalCommand = new EvalCommand("script");

              var result = evalCommand.Equals(other);

              result.Should().BeFalse();
        }
예제 #18
0
        public void GetHashCode_EvalCommandHasScriptAndOtherHasJavaScriptResult_ReturnsDifferentHashCodes()
        {
            var script = "console.log('weeeeeee')";
              var javaScriptResult = new JavaScriptResult();
              var evalCommand0 = new EvalCommand(script);
              var evalCommand1 = new EvalCommand(javaScriptResult);

              var result0 = evalCommand0.GetHashCode();
              var result1 = evalCommand1.GetHashCode();

              result0.Should().NotBe(result1);
        }
예제 #19
0
        public void GetHashCode_EvalCommandsHaveDifferentJavaScriptResults_ReturnsDifferentHashCodes()
        {
            var javaScriptResult0 = new JavaScriptResult();
              var javaScriptResult1 = new JavaScriptResult();
              var evalCommand0 = new EvalCommand(javaScriptResult0);
              var evalCommand1 = new EvalCommand(javaScriptResult1);

              var result0 = evalCommand0.GetHashCode();
              var result1 = evalCommand1.GetHashCode();

              result0.Should().NotBe(result1);
        }
예제 #20
0
        public void GetHashCode_EvalCommandsHaveDifferentScripts_ReturnsDifferentHashCodes()
        {
            var script0 = "console.log('weeeeeee')";
              var script1 = "console.log('no.')";
              var evalCommand0 = new EvalCommand(script0);
              var evalCommand1 = new EvalCommand(script1);

              var result0 = evalCommand0.GetHashCode();
              var result1 = evalCommand1.GetHashCode();

              result0.Should().NotBe(result1);
        }
예제 #21
0
        public void GetHashCode_EvalCommandsHaveSameJavaScriptResult_ReturnsSameHashCode()
        {
            var javaScriptResult = new JavaScriptResult();
              var evalCommand0 = new EvalCommand(javaScriptResult);
              var evalCommand1 = new EvalCommand(javaScriptResult);

              var result0 = evalCommand0.GetHashCode();
              var result1 = evalCommand1.GetHashCode();

              result0.Should().Be(result1);
        }