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

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

            var records = await repository.All(1, 0, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da").ToString());

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

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

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

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

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

            delete.Should().NotThrow();
        }
Beispiel #5
0
        public async void Get()
        {
            Mock <ILogger <BucketRepository> > loggerMoc = BucketRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = BucketRepositoryMoc.GetContext();
            var repository = new BucketRepository(loggerMoc.Object, context);

            Bucket entity = new Bucket();

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

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

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

            var entity = new Bucket();

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

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

            records.Count.Should().Be(2);
        }
Beispiel #7
0
        public async void Delete()
        {
            Mock <ILogger <BucketRepository> > loggerMoc = BucketRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = BucketRepositoryMoc.GetContext();
            var    repository            = new BucketRepository(loggerMoc.Object, context);
            Bucket entity = new Bucket();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
Beispiel #8
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <BucketRepository> > loggerMoc = BucketRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = BucketRepositoryMoc.GetContext();
            var    repository            = new BucketRepository(loggerMoc.Object, context);
            Bucket entity = new Bucket();

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

            await repository.Update(new Bucket());

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

            modifiedRecord.Should().NotBeNull();
        }
Beispiel #9
0
        public async void Get()
        {
            Mock <ILogger <BucketRepository> > loggerMoc = BucketRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = BucketRepositoryMoc.GetContext();
            var repository = new BucketRepository(loggerMoc.Object, context);

            Bucket entity = new Bucket();

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

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

            record.Should().NotBeNull();
        }
Beispiel #10
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <BucketRepository> > loggerMoc = BucketRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = BucketRepositoryMoc.GetContext();
            var    repository            = new BucketRepository(loggerMoc.Object, context);
            Bucket entity = new Bucket();

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

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

            await repository.Update(entity);

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

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