private IServiceTest Verify() { using (var context = new CatSharpContext(base.Options)) { Assert.True(context.Cats.Any(x => x.Name.Equals("Cat B"))); Assert.False(context.Cats.Any(x => x.Name.Equals("Cat 1"))); } return(this); }
private IServiceTest Verify() { using (var context = new CatSharpContext(base.Options)) { Assert.Equal(1, context.Cats.Count()); Assert.Equal("Cat 1", context.Cats.Single().Name); } return(this); }
private IServiceTest Execute() { using (var context = new CatSharpContext(base.Options)) { var service = new CatService(context); service.Create(new CatCreateDto("Cat 1", new DateTime(2018, 01, 01), null)); } return(this); }
private IServiceTest Execute() { using (var context = new CatSharpContext(base.Options)) { var service = new CatService(context); base.Result = service.GetAll(); } return(this); }
private IServiceTest SeedData() { using (var context = new CatSharpContext(base.Options)) { context.Cats.Add(new Cat() { Name = "Cat 1" }); context.SaveChanges(); } return(this); }
public virtual IServiceTest Start() { Connection = new SqliteConnection("DataSource=:memory:"); Connection.Open(); Options = new DbContextOptionsBuilder <CatSharpContext>().UseSqlite(Connection).Options; // Create the schema in the database using (var context = new CatSharpContext(Options)) { context.Database.EnsureCreated(); } return(this); }
private IServiceTest Execute() { using (var context = new CatSharpContext(base.Options)) { // Get the cat created var cat = context.Cats.AsNoTracking().Single(x => x.Name.Equals("Cat 1")); // Simulate the return value as CatGetDto var oldDto = cat.ToDto(); // Create the new CatUpdateDto with the date to be updated var newDto = new CatUpdateDto(oldDto.Id, "Cat B", oldDto.BirthDate, oldDto.Weights); // Update var service = new CatService(context); service.Update(newDto); } return(this); }
public CatService(CatSharpContext context) { _context = context; _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; }