예제 #1
0
        public async void Create()
        {
            Mock <ILogger <AccountRepository> > loggerMoc = AccountRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = AccountRepositoryMoc.GetContext();
            var repository = new AccountRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
예제 #2
0
        public async void Get()
        {
            Mock <ILogger <AccountRepository> > loggerMoc = AccountRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = AccountRepositoryMoc.GetContext();
            var repository = new AccountRepository(loggerMoc.Object, context);

            Account entity = new Account();

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

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

            record.Should().NotBeNull();
        }
예제 #3
0
        public async void Delete()
        {
            Mock <ILogger <AccountRepository> > loggerMoc = AccountRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = AccountRepositoryMoc.GetContext();
            var     repository           = new AccountRepository(loggerMoc.Object, context);
            Account entity = new Account();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
예제 #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <AccountRepository> > loggerMoc = AccountRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = AccountRepositoryMoc.GetContext();
            var     repository           = new AccountRepository(loggerMoc.Object, context);
            Account entity = new Account();

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

            await repository.Update(new Account());

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

            modifiedRecord.Should().NotBeNull();
        }