public async Task Process_Should_Process_DeleteBarEvent() { var context = FooGooTestHelpers.GetDummyContext(); var fooManager = FooGooTestHelpers.GetFooManager(context); var manager = FooGooTestHelpers.GetFooEventManager(context, fooManager); var fooTypeId1 = Guid.NewGuid(); var fooId = Guid.NewGuid(); var barId = Guid.NewGuid(); var events = new List <IFooGooEvent> { new FooTypeCreateEvent { Id = fooTypeId1, Name = Guid.NewGuid().ToString() }, new FooCreateEvent { Id = fooId, Name = Guid.NewGuid().ToString(), FooTypeId = fooTypeId1 }, new BarCreateEvent { Id = barId, FooId = fooId, Name = Guid.NewGuid().ToString() }, new BarDeleteEvent { Id = barId } }; await manager.AddEvents(events, Guid.NewGuid()); await manager.Process(Guid.NewGuid()); var bars = await fooManager.GetAllActiveBarsByFooId(fooId); Assert.Empty(bars); }
public async Task Process_Should_Process_UpdateFooFooTypeEvent() { var context = FooGooTestHelpers.GetDummyContext(); var fooManager = FooGooTestHelpers.GetFooManager(context); var manager = FooGooTestHelpers.GetFooEventManager(context, fooManager); var fooTypeId1 = Guid.NewGuid(); var fooTypeId2 = Guid.NewGuid(); var fooId = Guid.NewGuid(); var name = Guid.NewGuid().ToString(); var events = new List <IFooGooEvent> { new FooTypeCreateEvent { Id = fooTypeId1, Name = Guid.NewGuid().ToString() }, new FooTypeCreateEvent { Id = fooTypeId2, Name = Guid.NewGuid().ToString() }, new FooCreateEvent { Id = fooId, Name = Guid.NewGuid().ToString(), FooTypeId = fooTypeId1 }, new FooUpdateFooTypeIdEvent { Id = fooId, FooTypeId = fooTypeId2 } }; await manager.AddEvents(events, Guid.NewGuid()); await manager.Process(Guid.NewGuid()); Assert.Equal(1, context.Foos.Count()); Assert.Equal(fooTypeId2, context.Foos.Select(x => x.FooTypeId).FirstOrDefault()); }
public async Task Manager_Should_Update_Foo_Name() { var context = FooGooTestHelpers.GetDummyContext(); var fooManager = FooGooTestHelpers.GetFooManager(context); var fooEventManager = FooGooTestHelpers.GetFooEventManager(context, fooManager); var fooType = new FooTypeCreateEvent { Id = Guid.NewGuid(), Name = Guid.NewGuid().ToString() }; await fooEventManager.ProcessFooEventAsync(fooType); var foo = new FooCreateEvent { Id = Guid.NewGuid(), Name = Guid.NewGuid().ToString(), FooTypeId = fooType.Id }; await fooEventManager.ProcessFooEventAsync(foo); var item = new FooUpdateNameEvent { Id = foo.Id, Name = Guid.NewGuid().ToString() }; await fooEventManager.ProcessFooEventAsync(item); var result = await fooManager.GetFoo(item.Id); Assert.Equal(item.Name, result.Name); }
public async Task Manager_Should_Delete_Bar() { var context = FooGooTestHelpers.GetDummyContext(); var fooManager = FooGooTestHelpers.GetFooManager(context); var fooEventManager = FooGooTestHelpers.GetFooEventManager(context, fooManager); var fooType = new FooTypeCreateEvent { Id = Guid.NewGuid(), Name = Guid.NewGuid().ToString() }; await fooEventManager.ProcessFooEventAsync(fooType); var foo = new FooCreateEvent { Id = Guid.NewGuid(), Name = Guid.NewGuid().ToString(), FooTypeId = fooType.Id }; await fooEventManager.ProcessFooEventAsync(foo); var bar = new BarCreateEvent { Id = Guid.NewGuid(), Name = Guid.NewGuid().ToString(), FooId = foo.Id }; await fooEventManager.ProcessFooEventAsync(bar); var item = new BarDeleteEvent { Id = bar.Id }; await fooEventManager.ProcessFooEventAsync(item); var result = await fooManager.GetAllActiveBarsByFooId(foo.Id); Assert.Empty(result); }
public async Task Process_Should_Create_FooType() { var context = FooGooTestHelpers.GetDummyContext(); var fooManager = FooGooTestHelpers.GetFooManager(context); var manager = FooGooTestHelpers.GetFooEventManager(context, fooManager); var fooTypeId = Guid.NewGuid(); var events = new List <IFooGooEvent> { new FooTypeCreateEvent { Id = fooTypeId, Name = Guid.NewGuid().ToString() }, new FooCreateEvent { Id = Guid.NewGuid(), Name = Guid.NewGuid().ToString(), FooTypeId = fooTypeId } }; await manager.AddEvents(events, Guid.NewGuid()); Assert.Equal(2, context.FooGooEvents.Count()); }
public async Task Manager_Should_Delete_FooType() { var context = FooGooTestHelpers.GetDummyContext(); var fooManager = FooGooTestHelpers.GetFooManager(context); var fooEventManager = FooGooTestHelpers.GetFooEventManager(context, fooManager); var item = new FooTypeCreateEvent { Id = Guid.NewGuid(), Name = Guid.NewGuid().ToString() }; await fooEventManager.ProcessFooEventAsync(item); var item2 = new FooTypeDeleteEvent { Id = item.Id }; await fooEventManager.ProcessFooEventAsync(item2); var result = await fooManager.GetFooType(item2.Id); Assert.Null(result); }
public async Task Process_Should_Process_DeleteFooTypeEvent() { var context = FooGooTestHelpers.GetDummyContext(); var fooManager = FooGooTestHelpers.GetFooManager(context); var manager = FooGooTestHelpers.GetFooEventManager(context, fooManager); var fooTypeId = Guid.NewGuid(); var name = Guid.NewGuid().ToString(); var events = new List <IFooGooEvent> { new FooTypeCreateEvent { Id = fooTypeId, Name = Guid.NewGuid().ToString() }, new FooTypeDeleteEvent { Id = fooTypeId } }; await manager.AddEvents(events, Guid.NewGuid()); await manager.Process(Guid.NewGuid()); Assert.Empty(await fooManager.GetAllActiveFooTypes()); }