Beispiel #1
0
        public async void Create()
        {
            Mock <ILogger <ClientRepository> > loggerMoc = ClientRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClientRepositoryMoc.GetContext();
            var repository = new ClientRepository(loggerMoc.Object, context);

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

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

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

            Client entity = new Client();

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

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

            record.Should().NotBeNull();
        }
Beispiel #3
0
        public async void Delete()
        {
            Mock <ILogger <ClientRepository> > loggerMoc = ClientRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClientRepositoryMoc.GetContext();
            var    repository            = new ClientRepository(loggerMoc.Object, context);
            Client entity = new Client();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
Beispiel #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <ClientRepository> > loggerMoc = ClientRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClientRepositoryMoc.GetContext();
            var    repository            = new ClientRepository(loggerMoc.Object, context);
            Client entity = new Client();

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

            await repository.Update(new Client());

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

            modifiedRecord.Should().NotBeNull();
        }