Beispiel #1
0
        public async void All()
        {
            Mock <ILogger <RowVersionCheckRepository> > loggerMoc = RowVersionCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = RowVersionCheckRepositoryMoc.GetContext();
            var repository = new RowVersionCheckRepository(loggerMoc.Object, context);
            var records    = await repository.All();

            records.Should().NotBeEmpty();
            records.Count.Should().Be(1);
        }
Beispiel #2
0
        public void DeleteNotFound()
        {
            Mock <ILogger <RowVersionCheckRepository> > loggerMoc = RowVersionCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = RowVersionCheckRepositoryMoc.GetContext();
            var repository = new RowVersionCheckRepository(loggerMoc.Object, context);

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

            delete.Should().NotThrow();
        }
        public async void Create()
        {
            Mock <ILogger <RowVersionCheckRepository> > loggerMoc = RowVersionCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = RowVersionCheckRepositoryMoc.GetContext();
            var repository = new RowVersionCheckRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Beispiel #4
0
        public async void Create()
        {
            Mock <ILogger <RowVersionCheckRepository> > loggerMoc = RowVersionCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = RowVersionCheckRepositoryMoc.GetContext();
            var repository = new RowVersionCheckRepository(loggerMoc.Object, context);

            var entity = new RowVersionCheck();

            entity.SetProperties(default(int), "B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            await repository.Create(entity);

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

            records.Count.Should().Be(2);
        }
        public async void Get()
        {
            Mock <ILogger <RowVersionCheckRepository> > loggerMoc = RowVersionCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = RowVersionCheckRepositoryMoc.GetContext();
            var repository = new RowVersionCheckRepository(loggerMoc.Object, context);

            RowVersionCheck entity = new RowVersionCheck();

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

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

            record.Should().NotBeNull();
        }
Beispiel #6
0
        public async void Get()
        {
            Mock <ILogger <RowVersionCheckRepository> > loggerMoc = RowVersionCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = RowVersionCheckRepositoryMoc.GetContext();
            var repository = new RowVersionCheckRepository(loggerMoc.Object, context);

            RowVersionCheck entity = new RowVersionCheck();

            entity.SetProperties(default(int), "B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            context.Set <RowVersionCheck>().Add(entity);
            await context.SaveChangesAsync();

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

            record.Should().NotBeNull();
        }
        public async void Delete()
        {
            Mock <ILogger <RowVersionCheckRepository> > loggerMoc = RowVersionCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = RowVersionCheckRepositoryMoc.GetContext();
            var             repository   = new RowVersionCheckRepository(loggerMoc.Object, context);
            RowVersionCheck entity       = new RowVersionCheck();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <RowVersionCheckRepository> > loggerMoc = RowVersionCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = RowVersionCheckRepositoryMoc.GetContext();
            var             repository   = new RowVersionCheckRepository(loggerMoc.Object, context);
            RowVersionCheck entity       = new RowVersionCheck();

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

            await repository.Update(new RowVersionCheck());

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

            modifiedRecord.Should().NotBeNull();
        }
Beispiel #9
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <RowVersionCheckRepository> > loggerMoc = RowVersionCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = RowVersionCheckRepositoryMoc.GetContext();
            var             repository   = new RowVersionCheckRepository(loggerMoc.Object, context);
            RowVersionCheck entity       = new RowVersionCheck();

            entity.SetProperties(default(int), "B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            context.Set <RowVersionCheck>().Add(entity);
            await context.SaveChangesAsync();

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

            await repository.Update(entity);

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

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