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

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

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

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Delete(entity.Id);

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

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