public async Task ShouldGetPerson() { var repo = new PersonReadRepository(); var result = await repo.GetAsync(Guid.Parse("B6331C97-3A4B-4A22-8843-3E25F851712A")); result .Should() .NotBeNull(); result .Name .Should() .BeEquivalentTo("Agildo Rodrigues Silveira"); result .Birthdate .Should() .Be(new DateTime(1997, 9, 3)); result .Region .Should() .BeEquivalentTo("SP"); result .Points .Should() .Be(342237227); }
public async Task ShouldListPagedPeople() { var repo = new PersonReadRepository(); var result = await repo.PageAsync(1, 50); result .Should() .HaveCount(50); }
public async Task ShouldListAllPeople() { var repo = new PersonReadRepository(); var result = await repo.ListAsync(); result .Should() .HaveCount(1000); }
static void Main(string[] args) { var optionBuliderWrite = new DbContextOptionsBuilder <PersonContext>(); optionBuliderWrite.UseSqlServer( @"Server=(localdb)\mssqllocaldb;initial catalog=CQRSWrite;integrated security=true;" ); var optionBuliderRead = new DbContextOptionsBuilder <PersonContext>(); optionBuliderRead.UseSqlServer( @"Server=(localdb)\mssqllocaldb;initial catalog=CQRSRead;integrated security=true;" ); var contextWrite = new PersonContext(optionBuliderWrite.Options); var contextRead = new PersonContext(optionBuliderRead.Options); //context.Database.EnsureCreated(); var ReadRep = new PersonReadRepository(contextRead.Database.GetDbConnection().ConnectionString); var WriteRep = new PersonWriteRepository(contextWrite); // WriteRep.Add(new Entities.Person { //FirstName="Reza", //LastName="Akbari" // }); var list = ReadRep.GetAll(); foreach (var item in list) { Console.WriteLine(string.Format($"Name{item.FirstName}" + " " + $"Name{item.LastName}")); } Console.ReadKey(); }
static void Main(string[] args) { var OptionBuilderWrite = new DbContextOptionsBuilder <PersonContext>(); OptionBuilderWrite.UseSqlServer("Server=.;Database=CQRSDBWrite;User Id = sa;Password = ABCabc123456;"); var OptionBuilderRead = new DbContextOptionsBuilder <PersonContext>(); OptionBuilderRead.UseSqlServer("Server=.;Database=CQRSReadDB;User Id = sa;Password = ABCabc123456;"); var ctxWrite = new PersonContext(OptionBuilderWrite.Options); var ctxRead = new PersonContext(OptionBuilderRead.Options); ctxWrite.Database.EnsureDeleted(); ctxRead.Database.EnsureDeleted(); ctxWrite.Database.EnsureCreated(); ctxRead.Database.EnsureCreated(); var ReadRepo = new PersonReadRepository(ctxRead); var WriteRepo = new PersonWriteRepository(ctxWrite); WriteRepo.Add(new _01.Entities.Person { FirstName = "Hassan", LastName = "Asil" }); var list = ReadRepo.GetAll(); foreach (var item in list) { Console.WriteLine($"FirstName:{ item.FirstName} lastName:{ item.LastName}"); } Console.ReadLine(); }