public void ProcessSetVariableValueResponse() { // Arrange const int commandId = 3; var resultFactoryMock = new Mock <IEvaluationResultFactory>(); resultFactoryMock.Setup(factory => factory.Create(It.IsAny <INodeVariable>())) .Returns(() => new NodeEvaluationResult(0, null, null, null, null, null, NodeExpressionType.None, null)); var stackFrame = new NodeStackFrame(0); const string variableName = "port"; const int handle = 40; var setVariableValueCommand = new SetVariableValueCommand(commandId, resultFactoryMock.Object, stackFrame, variableName, handle); // Act setVariableValueCommand.ProcessResponse(SerializationTestData.GetSetVariableValueResponse()); // Assert Assert.AreEqual(commandId, setVariableValueCommand.Id); Assert.IsNotNull(setVariableValueCommand.Result); resultFactoryMock.Verify(factory => factory.Create(It.IsAny <INodeVariable>()), Times.Once); }
public void CreateSetVariableValue() { // Arrange JObject json = SerializationTestData.GetSetVariableValueResponse(); const int frameId = 3; var stackFrame = new NodeStackFrame(frameId); const string name = "name"; // Act var result = new NodeSetValueVariable(stackFrame, name, json); // Assert Assert.IsNotNull(result); Assert.AreEqual(NodePropertyAttributes.None, result.Attributes); Assert.IsNull(result.Class); Assert.AreEqual(44, result.Id); Assert.AreEqual(name, result.Name); Assert.IsNull(result.Parent); Assert.AreEqual(stackFrame, result.StackFrame); Assert.AreEqual("55", result.Text); Assert.AreEqual(NodePropertyType.Normal, result.Type); Assert.AreEqual("number", result.TypeName); Assert.AreEqual("55", result.Value); }