示例#1
0
        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());
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        public async Task Manager_Should_Create_FooType()
        {
            var context = FooGooTestHelpers.GetDummyContext();
            var manager = FooGooTestHelpers.GetFooManager(context);

            var item = new FooTypeDto {
                FooTypeId = Guid.NewGuid(), Name = Guid.NewGuid().ToString(), Active = true
            };
            await manager.CreateFooType(item);

            var result = await manager.GetFooType(item.FooTypeId);

            Assert.Equal(item.Name, result.Name);
        }
示例#6
0
        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());
        }
示例#7
0
        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);
        }
示例#8
0
        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());
        }