public void OnEntityQueryResponse_should_error_if_request_id_not_found() { using (var wrappedOp = WorkerOpFactory.CreateEntityQueryResponseOp(TestCommandRequestId)) { Assert.Throws <UnknownRequestIdException>(() => { receiveSystem.OnEntityQueryResponse(wrappedOp.Op); }); } }
public void OnEntityQueryResponse_should_add_received_responses_to_entity() { var entity = SetupTestEntity(); var emptyRequest = new WorldCommands.EntityQuery.Request(); var context = "Some context"; entityQueryStorage.CommandRequestsInFlight.Add(TestCommandRequestId, new CommandRequestStore <WorldCommands.EntityQuery.Request>(entity, emptyRequest, context, TestCommandRequestId)); using (var wrappedOp = WorkerOpFactory.CreateEntityQueryResponseOp(TestCommandRequestId)) { receiveSystem.OnEntityQueryResponse(wrappedOp.Op); Assert.IsTrue(entityManager.HasComponent <WorldCommands.EntityQuery.CommandResponses>(entity)); var responses = entityManager.GetComponentData <WorldCommands.EntityQuery.CommandResponses>(entity); var count = 0; Assert.DoesNotThrow(() => { count = responses.Responses.Count; }); Assert.AreEqual(1, count); var response = responses.Responses[0]; Assert.AreEqual(emptyRequest, response.RequestPayload); Assert.AreEqual(context, response.Context); Assert.AreEqual(TestCommandRequestId, response.RequestId); Assert.AreEqual(wrappedOp.Op.StatusCode, response.StatusCode); Assert.AreEqual(wrappedOp.Op.Message, response.Message); Assert.AreEqual(wrappedOp.Op.Result, response.Result); Assert.AreEqual(wrappedOp.Op.ResultCount, response.ResultCount); } }
public void OnEntityQueryResponse_should_log_if_corresponding_entity_not_found() { var emptyRequest = new WorldCommands.EntityQuery.Request(); entityQueryStorage.CommandRequestsInFlight.Add(TestCommandRequestId, new CommandRequestStore <WorldCommands.EntityQuery.Request>(Entity.Null, emptyRequest, null, TestCommandRequestId)); using (var wrappedOp = WorkerOpFactory.CreateEntityQueryResponseOp(TestCommandRequestId)) { using (var expectingScope = logDispatcher.EnterExpectingScope()) { expectingScope.Expect(LogType.Log, LoggingUtils.LoggerName, "Op"); receiveSystem.OnEntityQueryResponse(wrappedOp.Op); } } }
public void OnEntityQueryResponse_should_add_received_responses_to_entity() { var entity = SetupTestEntity(); var emptyRequest = new WorldCommands.EntityQuery.Request(); var context = "Some context"; entityQueryStorage.CommandRequestsInFlight.Add(TestCommandRequestId, new CommandRequestStore <WorldCommands.EntityQuery.Request>(entity, emptyRequest, context, TestCommandRequestId)); using (var wrappedOp = WorkerOpFactory.CreateEntityQueryResponseOp(TestCommandRequestId)) { receiveSystem.OnEntityQueryResponse(wrappedOp.Op); Assert.IsTrue(entityManager.HasComponent <WorldCommands.EntityQuery.CommandResponses>(entity)); var responses = entityManager.GetComponentData <WorldCommands.EntityQuery.CommandResponses>(entity); var count = 0; Assert.DoesNotThrow(() => { count = responses.Responses.Count; }); Assert.AreEqual(1, count); var response = responses.Responses[0]; Assert.AreEqual(emptyRequest, response.RequestPayload); Assert.AreEqual(context, response.Context); Assert.AreEqual(TestCommandRequestId, response.RequestId); Assert.AreEqual(wrappedOp.Op.StatusCode, response.StatusCode); Assert.AreEqual(wrappedOp.Op.Message, response.Message); Assert.AreEqual(wrappedOp.Op.ResultCount, response.ResultCount); // Check that the result and the op contain snapshots of the same entities // Or that they are both null if one of them is null // todo UTY-1361 clean this up if (wrappedOp.Op.Result == null) { Assert.IsNull(response.Result); } else { CollectionAssert.AreEquivalent(wrappedOp.Op.Result.Keys, response.Result.Keys); } } }