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

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

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

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

            await repository.Delete(entity.Id);

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

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

            entity.SetProperties(default(int), DateTime.Parse("1/1/1988 12:00:00 AM"), "B", 1);
            context.Set <Badge>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

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

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