Exemple #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();
        }
Exemple #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();
        }
Exemple #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();
        }
Exemple #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();
        }