Пример #1
0
        public void ShouldSendUpdatesAccordingToDoI()
        {
            var entity1 = new Entity();
            var entity2 = new Entity();

            doiMock.Setup(doi => doi.IsInterestedInEntity(entity1)).Returns(true);
            doiMock.Setup(doi => doi.IsInterestedInEntity(entity2)).Returns(false);

            var worldSync = new WorldSync();

            worldSync.HandleLocalAddedEntity(this, new EntityEventArgs(entity1));
            worldSync.HandleLocalAddedEntity(this, new EntityEventArgs(entity2));

            handlers.Verify(h => h.AddEntity(entity1.Guid.ToString(), World.Instance.ID.ToString(), It.Is <EntitySyncInfo>(
                                                 esi => esi.Components.Count == 0)), Times.Once());
            handlers.Verify(h => h.AddEntity(entity2.Guid.ToString(), World.Instance.ID.ToString(), It.Is <EntitySyncInfo>(
                                                 esi => esi.Components.Count == 0)), Times.Never());
        }
Пример #2
0
        public void ShouldSendEntityAdditions()
        {
            var entity = new Entity();

            entity["test"]["a"].Suggest(33);

            var worldSync = new WorldSync();

            worldSync.HandleLocalAddedEntity(this, new EntityEventArgs(entity));

            handlers.Verify(h => h.AddEntity(entity.Guid.ToString(), World.Instance.ID.ToString(), It.Is <EntitySyncInfo>(esi =>
                                                                                                                          esi.Components.Count == 1 &&
                                                                                                                          esi.Components["test"]["a"].LastValue.Equals(33))), Times.Once());
        }
        public void ShouldSendUpdatesAccordingToDoI()
        {
            var entity1 = new Entity();
            var entity2 = new Entity();
            doiMock.Setup(doi => doi.IsInterestedInEntity(entity1)).Returns(true);
            doiMock.Setup(doi => doi.IsInterestedInEntity(entity2)).Returns(false);

            var worldSync = new WorldSync();
            worldSync.HandleLocalAddedEntity(this, new EntityEventArgs(entity1));
            worldSync.HandleLocalAddedEntity(this, new EntityEventArgs(entity2));

            handlers.Verify(h => h.AddEntity(entity1.Guid, It.Is<EntitySyncInfo>(
                esi => esi.Components.Count == 0)), Times.Once());
            handlers.Verify(h => h.AddEntity(entity2.Guid, It.Is<EntitySyncInfo>(
                esi => esi.Components.Count == 0)), Times.Never());
        }
        public void ShouldSendEntityAdditions()
        {
            var entity = new Entity();
            entity["test"]["a"].Suggest(33);

            var worldSync = new WorldSync();
            worldSync.HandleLocalAddedEntity(this, new EntityEventArgs(entity));

            handlers.Verify(h => h.AddEntity(entity.Guid, It.Is<EntitySyncInfo>(esi =>
                esi.Components.Count == 1 &&
                esi.Components["test"]["a"].LastValue.Equals(33))), Times.Once());
        }