Ejemplo n.º 1
0
        public void DeleteNotFound()
        {
            Mock <ILogger <RetweetRepository> > loggerMoc = RetweetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = RetweetRepositoryMoc.GetContext();
            var repository = new RetweetRepository(loggerMoc.Object, context);

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

            delete.Should().NotThrow();
        }
Ejemplo n.º 2
0
        public async void Delete()
        {
            Mock <ILogger <RetweetRepository> > loggerMoc = RetweetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = RetweetRepositoryMoc.GetContext();
            var     repository           = new RetweetRepository(loggerMoc.Object, context);
            Retweet entity = new Retweet();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
Ejemplo n.º 3
0
        public async void DeleteFound()
        {
            Mock <ILogger <RetweetRepository> > loggerMoc = RetweetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = RetweetRepositoryMoc.GetContext();
            var     repository           = new RetweetRepository(loggerMoc.Object, context);
            Retweet entity = new Retweet();

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

            await repository.Delete(entity.Id);

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

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