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); }
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); }
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); }
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); }
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; }
public void SetUp() { logDispatcher = new LoggingDispatcher(); }