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

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

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

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

            TransactionStatu entity = new TransactionStatu();

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

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

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

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Update(new TransactionStatu());

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

            modifiedRecord.Should().NotBeNull();
        }