Exemplo n.º 1
0
        public async void Create()
        {
            Mock <ILogger <StoreRepository> > loggerMoc = StoreRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = StoreRepositoryMoc.GetContext();
            var repository = new StoreRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Exemplo n.º 2
0
        public async void Get()
        {
            Mock <ILogger <StoreRepository> > loggerMoc = StoreRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = StoreRepositoryMoc.GetContext();
            var repository = new StoreRepository(loggerMoc.Object, context);

            Store entity = new Store();

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

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

            record.Should().NotBeNull();
        }
Exemplo n.º 3
0
        public async void Delete()
        {
            Mock <ILogger <StoreRepository> > loggerMoc = StoreRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = StoreRepositoryMoc.GetContext();
            var   repository             = new StoreRepository(loggerMoc.Object, context);
            Store entity = new Store();

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

            await repository.Delete(entity.BusinessEntityID);

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

            modifiedRecord.Should().BeNull();
        }
Exemplo n.º 4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <StoreRepository> > loggerMoc = StoreRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = StoreRepositoryMoc.GetContext();
            var   repository             = new StoreRepository(loggerMoc.Object, context);
            Store entity = new Store();

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

            await repository.Update(new Store());

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

            modifiedRecord.Should().NotBeNull();
        }