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

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

            delete.Should().NotThrow();
        }
Esempio n. 2
0
        public async void Delete()
        {
            Mock <ILogger <HandlerRepository> > loggerMoc = HandlerRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = HandlerRepositoryMoc.GetContext();
            var     repository           = new HandlerRepository(loggerMoc.Object, context);
            Handler entity = new Handler();

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Delete(entity.Id);

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

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