public void DeleteNotFound()
        {
            Mock <ILogger <PetRepository> > loggerMoc = PetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext            context   = PetRepositoryMoc.GetContext();
            var repository = new PetRepository(loggerMoc.Object, context);

            Func <Task> delete = async() =>
            {
                await repository.Delete(default(int));
            };

            delete.Should().NotThrow();
        }
Beispiel #2
0
        public async void Delete()
        {
            Mock <ILogger <PetRepository> > loggerMoc = PetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext            context   = PetRepositoryMoc.GetContext();
            var repository = new PetRepository(loggerMoc.Object, context);
            Pet entity     = new Pet();

            context.Set <Pet>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            Pet modifiedRecord = await context.Set <Pet>().FirstOrDefaultAsync();

            modifiedRecord.Should().BeNull();
        }
        public async void DeleteFound()
        {
            Mock <ILogger <PetRepository> > loggerMoc = PetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext            context   = PetRepositoryMoc.GetContext();
            var repository = new PetRepository(loggerMoc.Object, context);
            Pet entity     = new Pet();

            entity.SetProperties(default(int), 1, 2, "B", 2);
            context.Set <Pet>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            var records = await context.Set <Pet>().ToListAsync();

            records.Count.Should().Be(1);
        }