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

            records.Should().NotBeEmpty();
            records.Count.Should().Be(1);
        }
Exemple #2
0
        public async void Create()
        {
            Mock <ILogger <TimestampCheckRepository> > loggerMoc = TimestampCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TimestampCheckRepositoryMoc.GetContext();
            var repository = new TimestampCheckRepository(loggerMoc.Object, context);

            var entity = new TimestampCheck();
            await repository.Create(entity);

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

            record.Should().NotBeNull();
        }
        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 #4
0
        public async void Get()
        {
            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();

            var record = await repository.Get(entity.Id);

            record.Should().NotBeNull();
        }
        public async void Create()
        {
            Mock <ILogger <TimestampCheckRepository> > loggerMoc = TimestampCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TimestampCheckRepositoryMoc.GetContext();
            var repository = new TimestampCheckRepository(loggerMoc.Object, context);

            var entity = new TimestampCheck();

            entity.SetProperties(default(int), "B", BitConverter.GetBytes(2));
            await repository.Create(entity);

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

            records.Count.Should().Be(2);
        }
Exemple #6
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();
        }
Exemple #7
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            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.Update(new TimestampCheck());

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

            modifiedRecord.Should().NotBeNull();
        }
        public async void Update_Entity_Is_Not_Tracked()
        {
            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();

            context.Entry(entity).State = EntityState.Detached;

            await repository.Update(entity);

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

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