Пример #1
0
        public async void Create()
        {
            Mock <ILogger <TransactionHistoryRepository> > loggerMoc = TransactionHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TransactionHistoryRepositoryMoc.GetContext();
            var repository = new TransactionHistoryRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Пример #2
0
        public async void Get()
        {
            Mock <ILogger <TransactionHistoryRepository> > loggerMoc = TransactionHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TransactionHistoryRepositoryMoc.GetContext();
            var repository = new TransactionHistoryRepository(loggerMoc.Object, context);

            TransactionHistory entity = new TransactionHistory();

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

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

            record.Should().NotBeNull();
        }
Пример #3
0
        public async void Delete()
        {
            Mock <ILogger <TransactionHistoryRepository> > loggerMoc = TransactionHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TransactionHistoryRepositoryMoc.GetContext();
            var repository            = new TransactionHistoryRepository(loggerMoc.Object, context);
            TransactionHistory entity = new TransactionHistory();

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

            await repository.Delete(entity.TransactionID);

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

            modifiedRecord.Should().BeNull();
        }
Пример #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <TransactionHistoryRepository> > loggerMoc = TransactionHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TransactionHistoryRepositoryMoc.GetContext();
            var repository            = new TransactionHistoryRepository(loggerMoc.Object, context);
            TransactionHistory entity = new TransactionHistory();

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

            await repository.Update(new TransactionHistory());

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

            modifiedRecord.Should().NotBeNull();
        }