public void AllEntitiesAreProcessedWhenCountIsDividableByNumThreads() { var system = new TestJobSystem(ctx, 2); for (int i = 0; i < 4; i++) { var e = ctx.CreateEntity(); e.AddNameAge("e" + i, -1); } system.Update(); var entities = ctx.GetEntities(); Assert.AreEqual(4, entities.Length); for (int i = 0; i < entities.Length; i++) { Assert.AreEqual("e" + i + "-Processed", entities[i].NameAge.name); } Assert.AreEqual(entities[1].NameAge.age, entities[0].NameAge.age); Assert.AreEqual(entities[3].NameAge.age, entities[2].NameAge.age); Assert.AreEqual(entities[2].NameAge.age, entities[0].NameAge.age); }
public void JobSystemCanRecoverFromException() { var system = new TestJobSystem(ctx, 2); system.exception = new Exception("Test Exception"); for (int i = 0; i < 10; i++) { var e = ctx.CreateEntity(); e.AddNameAge("e" + i, -1); } var didThrow = 0; try { system.Update(); } catch { didThrow += 1; } Assert.AreEqual(1, didThrow); system.exception = null; system.Update(); }
public void EntityIsProcessed() { var system = new TestJobSystem(ctx, 2); var e = ctx.CreateEntity(); e.AddNameAge("e", -1); system.Update(); Assert.AreEqual("e-Processed", e.NameAge.name); }
public void JobSystemThrowsWhenThreadThrows() { var system = new TestJobSystem(ctx, 2); system.exception = new Exception("Test Exception"); for (int i = 0; i < 10; i++) { var e = ctx.CreateEntity(); e.AddNameAge("e" + i, -1); } Assert.Throws <Exception>(() => system.Update()); }