Esempio n. 1
0
        public void Cycle()
        {
            var table = new ComponentTable <NameComponent>();

            table.Add(key1, new NameComponent {
                name = "Bob"
            });
            table.Add(key3, new NameComponent {
                name = "Frank"
            });
            Assert.AreEqual(expected: 2, actual: table.Count);
            Assert.AreEqual(expected: key1, actual: table.EntityAt(0));
            Assert.AreEqual(expected: "Bob", actual: table.TryGet(key1, out var name) ? name.name : null);

            Assert.IsTrue(table.Remove(key1));
            Assert.IsFalse(table.Remove(key1));
            Assert.AreEqual(expected: 1, actual: table.Count);

            Assert.AreEqual(expected: key3, actual: table.EntityAt(0));
            Assert.AreEqual(expected: "Frank", actual: table.TryGet(key3, out name) ? name.name : null);

            table.Add(key2, new NameComponent {
                name = "Susan"
            });
            Assert.AreEqual(expected: 2, actual: table.Count);

            Assert.IsTrue(table.Remove(key3));
            Assert.AreEqual(expected: 1, actual: table.Count);

            Assert.AreEqual(expected: key2, actual: table.EntityAt(0));
            Assert.AreEqual(expected: "Susan", actual: table.TryGet(key2, out name) ? name.name : null);
        }
Esempio n. 2
0
        public void SetReplace()
        {
            var table = new ComponentTable <NameComponent>();

            table.Add(key1, new NameComponent {
                name = "Bob"
            });
            table.Add(key1, new NameComponent {
                name = "Susan"
            });

            Assert.AreEqual(expected: 1, table.Count);
            Assert.AreEqual(expected: key1, actual: table.EntityAt(0));
            Assert.AreEqual(expected: "Susan", actual: table.TryGet(key1, out var name) ? name.name : null);
        }