public void CreateLookupCommand() { // Arrange const int commandId = 3; var resultFactoryMock = new Mock<IEvaluationResultFactory>(); var handles = new[] { 25 }; // Act var lookupCommand = new LookupCommand(commandId, resultFactoryMock.Object, handles); // Assert Assert.AreEqual(commandId, lookupCommand.Id); Assert.AreEqual( string.Format( "{{\"command\":\"lookup\",\"seq\":{0},\"type\":\"request\",\"arguments\":{{\"handles\":{1},\"includeSource\":false}}}}", commandId, JsonConvert.SerializeObject(handles)), lookupCommand.ToString()); }
public void ProcessLookupResponseWithPrimitiveObject() { // 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)); const int handle = 9; var handles = new[] { handle }; var lookupCommand = new LookupCommand(commandId, resultFactoryMock.Object, handles); // Act lookupCommand.ProcessResponse(SerializationTestData.GetLookupResponseWithPrimitiveObject()); // Assert Assert.AreEqual(commandId, lookupCommand.Id); Assert.IsNotNull(lookupCommand.Results); Assert.IsTrue(lookupCommand.Results.ContainsKey(handle)); Assert.IsNotNull(lookupCommand.Results[handle]); resultFactoryMock.Verify(factory => factory.Create(It.IsAny<INodeVariable>()), Times.Once); }