public void GetId_ShouldWrapAround() { var collection = new ElementByIdCollection(); var generator = new CollectionBasedElementIdGenerator(collection); var first = generator.GetId(); var firstElement = new DummyElement() { Id = first }; collection.Add(firstElement); for (int i = 0; i < ElementConstants.MaxElementId - 2; i++) { var id = generator.GetId(); collection.Add(new DummyElement() { Id = id }); } collection.Remove(firstElement); var finalId = generator.GetId(); finalId.Should().Be(first); }
public void GetId_ShouldWrapAround() { var repository = new ElementByIdRepository(); var generator = new RepositoryBasedElementIdGenerator(repository); var first = generator.GetId(); var firstElement = new DummyElement() { Id = first }; repository.Add(firstElement); for (int i = 0; i < ElementConstants.MaxElementId - 2; i++) { var id = generator.GetId(); repository.Add(new DummyElement() { Id = id }); } repository.Remove(firstElement); var finalId = generator.GetId(); finalId.Should().Be(first); }
public void GetId_ShouldReturnUnusedId() { var collection = new ElementByIdCollection(); var dummyElement = new DummyElement() { Id = 0 }; collection.Add(dummyElement); var generator = new CollectionBasedElementIdGenerator(collection); var id = generator.GetId(); id.Should().NotBe(dummyElement.Id); }
public void GetId_ShouldReturnUnusedId() { var repository = new ElementByIdRepository(); var dummyElement = new DummyElement() { Id = 0 }; repository.Add(dummyElement); var generator = new RepositoryBasedElementIdGenerator(repository); var id = generator.GetId(); id.Should().NotBe(dummyElement.Id); }
private static bool TryToEnter(Token t, DummyElement element) { m_sw.WriteLine(t.State.ToString() + "\t: Enter(" + element + ")"); //m_sw.WriteLine("\r\nAttempting to call Enter(" + element + ") with a token in the " + t.State.ToString() + " state."); bool result = true; try { t.Enter(element, null); } catch (Token.IllegalOperationException ioe) { m_sw.WriteLine("\tFAIL : " + ioe.Message); result = false; } finally { m_sw.WriteLine("\tToken in " + t.State.ToString() + ", held by " + (t.CurrentHolder == null ? "<null>" : t.CurrentHolder.ToString()) + "."); } return(result); }
public void ColShapeEnterNotCalledWhenOutOfColShape() { var server = new TestingServer(); var behaviour = server.Instantiate <CollisionShapeBehaviour>(); var collisionShape = new CollisionSphere(new Vector3(100, 100, 100), 10).AssociateWith(server);; var dummy = new DummyElement().AssociateWith(server); var isEventCalled = false; collisionShape.ElementEntered += (element) => { if (element == dummy) { isEventCalled = true; } }; dummy.Position = new Vector3(0, 100, 100); isEventCalled.Should().BeFalse(); }
public void ColShapeEnterCalledOnceForTwoUpdatesInColshape() { var server = new TestingServer(); var behaviour = server.Instantiate <CollisionShapeBehaviour>(); var collisionShape = new CollisionSphere(new Vector3(100, 100, 100), 10).AssociateWith(server);; var dummy = new DummyElement().AssociateWith(server); int callCount = 0; collisionShape.ElementEntered += (element) => { if (element == dummy) { callCount++; } }; dummy.Position = new Vector3(95, 100, 100); dummy.Position = new Vector3(97.5f, 100, 100); callCount.Should().Be(1); }
private void TestClientResource(Client client) { var resourceRoot = new DummyElement() { Parent = this.root, ElementTypeName = "resource", }.AssociateWith(server); var resourceDyanmic = new DummyElement() { Parent = resourceRoot, ElementTypeName = "resource", }.AssociateWith(server); var entityPacket = AddEntityPacketFactory.CreateAddEntityPacket(new Element[] { resourceRoot, resourceDyanmic }); client.SendPacket(entityPacket); var testResourceFiles = this.resourceServer.GetResourceFiles("./TestResource"); client.SendPacket(new ResourceStartPacket( "TestResource", 0, resourceRoot.Id, resourceDyanmic.Id, 0, null, null, false, 0, testResourceFiles, new string[0]) ); }
public void AddDummy(DummyElement element) { packet.AddDummy(element.Id, (byte)element.ElementType, element.Parent?.Id ?? 0, element.Interior, element.Dimension, null, element.AreCollisionsEnabled, element.IsCallPropagationEnabled, new CustomData(), element.Name, element.TimeContext, element.ElementTypeName, element.Position); }
DummyElement NewDummyElement() { DummyElement de = new DummyElement(m_deNum++); return(de); }