コード例 #1
0
        public void SetUp()
        {
            world          = new World("test-world");
            entityManager  = world.GetOrCreateManager <EntityManager>();
            TestGameObject = new GameObject();
            var loggingDispatcher = new LoggingDispatcher();
            var workerSystem      = world.CreateManager <WorkerSystem>(
                null,               // Connection connection
                loggingDispatcher,  // ILogDispatcher logDispatcher
                WorkerType,         // string workerType
                Vector3.zero        // Vector3 origin
                );

            PopulateBehaviours();

            var spatialOSComponent = TestGameObject.AddComponent <SpatialOSComponent>();

            spatialOSComponent.Worker = workerSystem;
            spatialOSComponent.Entity = entityManager.CreateEntity();

            var injectableStore       = new InjectableStore();
            var requiredFieldInjector = new RequiredFieldInjector(entityManager, loggingDispatcher);

            ActivationManager = new MonoBehaviourActivationManager(TestGameObject,
                                                                   requiredFieldInjector, injectableStore, loggingDispatcher);
        }
コード例 #2
0
        public void Dispatch_Should_Call_Next_Dispatcher()
        {
            TestQuery testQuery = new TestQuery();
            Mock <IObjectSerializer>      mockSerializer   = new Mock <IObjectSerializer>();
            Mock <ILogger>                mockLogger       = new Mock <ILogger>();
            Mock <IDispatcher <IQuery> >  mockDispatcher   = new Mock <IDispatcher <IQuery> >();
            DelegatingDispatcher <IQuery> dispatcherTested = new LoggingDispatcher <IQuery>(mockSerializer.Object, mockLogger.Object);

            dispatcherTested.Next = mockDispatcher.Object;

            dispatcherTested.Dispatch <TestResponse>(testQuery);

            mockDispatcher.Verify(n => n.Dispatch <TestResponse>(testQuery), Times.Once);
        }
コード例 #3
0
        public void Dispatch_Should_Log_Exception_And_Rethrow()
        {
            Mock <IObjectSerializer>      mockSerializer   = new Mock <IObjectSerializer>();
            Mock <ILogger>                mockLogger       = new Mock <ILogger>();
            Mock <IDispatcher <IQuery> >  mockDispatcher   = new Mock <IDispatcher <IQuery> >();
            DelegatingDispatcher <IQuery> dispatcherTested = new LoggingDispatcher <IQuery>(mockSerializer.Object, mockLogger.Object);

            dispatcherTested.Next = mockDispatcher.Object;
            TestQuery     testQuery = new TestQuery();
            TestException exception = new TestException("boum");

            mockDispatcher.Setup(m => m.Dispatch <object>(testQuery)).Throws(exception);

            Assert.That(() => dispatcherTested.Dispatch <object>(testQuery), Throws.InstanceOf <TestException>());

            mockLogger.Verify(m => m.LogException(exception), Times.Once);
        }
コード例 #4
0
        public void Dispatch_Should_Log_Serialized_Query()
        {
            string expectedMessage = "Serialized Query";
            Mock <IObjectSerializer>      mockSerializer   = new Mock <IObjectSerializer>();
            Mock <ILogger>                mockLogger       = new Mock <ILogger>();
            Mock <IDispatcher <IQuery> >  mockDispatcher   = new Mock <IDispatcher <IQuery> >();
            DelegatingDispatcher <IQuery> dispatcherTested = new LoggingDispatcher <IQuery>(mockSerializer.Object, mockLogger.Object);

            dispatcherTested.Next = mockDispatcher.Object;
            TestQuery testQuery = new TestQuery();

            mockSerializer.Setup(m => m.Serialize(testQuery)).Returns(expectedMessage);

            dispatcherTested.Dispatch <object>(testQuery);

            mockSerializer.Verify(m => m.Serialize(testQuery), Times.Once);
            mockLogger.Verify(m => m.LogQuery(expectedMessage), Times.Once);
        }
コード例 #5
0
        public void Setup()
        {
            var logDispatcher = new LoggingDispatcher();

            var connectionBuilder = new MockConnectionHandlerBuilder();

            connectionHandler = connectionBuilder.ConnectionHandler;
            workerInWorld     = WorkerInWorld
                                .CreateWorkerInWorldAsync(connectionBuilder, WorkerType, logDispatcher, Vector3.zero)
                                .Result;
            receiveSystem          = workerInWorld.World.GetExistingSystem <SpatialOSReceiveSystem>();
            requireLifecycleSystem = workerInWorld.World.GetExistingSystem <RequireLifecycleSystem>();

            var goInitSystem = workerInWorld.World
                               .CreateSystem <GameObjectInitializationSystem>(
                new GameObjectCreatorFromMetadata(WorkerType, Vector3.zero, logDispatcher), null);

            linker = goInitSystem.Linker;
        }
コード例 #6
0
 public void SetUp()
 {
     logDispatcher = new LoggingDispatcher();
 }