public EmployeeEntityTest(ITestOutputHelper output) { var converter = new Converter(output); Console.SetOut(converter); _world = World.StartWithDefaults("test-object-entity"); var objectStore = _world.ActorFor <IObjectStore>(typeof(InMemoryObjectStoreActor <string>), new MockDispatcher()); var registry = new ObjectTypeRegistry(_world); // NOTE: The InMemoryObjectStoreActor implementation currently // does not use PersistentObjectMapper, and thus the no-op decl. var employeeInfo = new Info <EmployeeState>( objectStore, "HR-Database", MapQueryExpression.Using <IEmployee>("find", MapQueryExpression.Map("number", "number")), StateObjectMapper.With <IEmployee>(new object(), new object())); registry.Register(employeeInfo); }
public void TestThatObjectPersistsQueries() { _dispatcher.AfterCompleting(1); var persistAccess = _persistInterest.AfterCompleting(1); var person = new Person("Tom Jones", 85); var source = new Test1Source(); _objectStore.Persist(person, new List <Test1Source> { source }, _persistInterest); var persistSize = persistAccess.ReadFrom <int>("size"); Assert.Equal(1, persistSize); Assert.Equal(person, persistAccess.ReadFrom <int, object>("object", 0)); var query = MapQueryExpression.Using <Person>("find", MapQueryExpression.Map("id", person.PersistenceId)); var queryAccess = _queryResultInterest.AfterCompleting(1); _objectStore.QueryObject(query, _queryResultInterest, null); var querySize = queryAccess.ReadFrom <int>("size"); Assert.Equal(1, querySize); Assert.Equal(person, queryAccess.ReadFrom <int, object>("object", 0)); Assert.Equal(1, _dispatcher.DispatchedCount()); var dispatched = _dispatcher.GetDispatched()[0]; ValidateDispatchedState(person, dispatched); var dispatchedEntries = dispatched.Entries; Assert.Single(dispatchedEntries); var entry = dispatchedEntries[0]; Assert.NotNull(entry.Id); Assert.Equal(source.GetType().AssemblyQualifiedName, entry.TypeName); Assert.Equal(Metadata.NullMetadata(), entry.Metadata); }
public ObjectProcessTest(ITestOutputHelper output) { var converter = new Converter(output); Console.SetOut(converter); _world = World.StartWithDefaults("five-step-process-test"); var queue = new AsyncMessageQueue(null); _exchange = new LocalExchange(queue); var adapter = new ProcessMessageTextAdapter(); EntryAdapterProvider.Instance(_world).RegisterAdapter(adapter); var dispatcher = new MockDispatcher(); var objectStore = _world.ActorFor <IObjectStore>(() => new InMemoryObjectStoreActor <string>(dispatcher)); var objectTypeRegistry = new ObjectTypeRegistry(_world); var stepCountStateInfo = new Info <StepCountObjectState>( objectStore, nameof(StepCountObjectState), MapQueryExpression.Using <StepCountObjectState>("find", MapQueryExpression.Map("id", "id")), StateObjectMapper.With <StepCountObjectState>(new object(), new object())); objectTypeRegistry.Register(stepCountStateInfo); _exchangeSender = new LocalExchangeSender(queue); var processTypeRegistry = new ProcessTypeRegistry(_world); processTypeRegistry.Register(new ObjectProcessInfo <FiveStepEmittingObjectProcess, StepCountObjectState>(nameof(FiveStepEmittingObjectProcess), _exchange, objectTypeRegistry)); _exchangeReceivers = new ExchangeReceivers(); RegisterExchangeCoveys(); }