Esempio n. 1
0
        public async void Create()
        {
            Mock <ILogger <ClientCommunicationRepository> > loggerMoc = ClientCommunicationRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClientCommunicationRepositoryMoc.GetContext();
            var repository = new ClientCommunicationRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Esempio n. 2
0
        public async void Get()
        {
            Mock <ILogger <ClientCommunicationRepository> > loggerMoc = ClientCommunicationRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClientCommunicationRepositoryMoc.GetContext();
            var repository = new ClientCommunicationRepository(loggerMoc.Object, context);

            ClientCommunication entity = new ClientCommunication();

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

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

            record.Should().NotBeNull();
        }
Esempio n. 3
0
        public async void Delete()
        {
            Mock <ILogger <ClientCommunicationRepository> > loggerMoc = ClientCommunicationRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClientCommunicationRepositoryMoc.GetContext();
            var repository             = new ClientCommunicationRepository(loggerMoc.Object, context);
            ClientCommunication entity = new ClientCommunication();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
Esempio n. 4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <ClientCommunicationRepository> > loggerMoc = ClientCommunicationRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClientCommunicationRepositoryMoc.GetContext();
            var repository             = new ClientCommunicationRepository(loggerMoc.Object, context);
            ClientCommunication entity = new ClientCommunication();

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

            await repository.Update(new ClientCommunication());

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

            modifiedRecord.Should().NotBeNull();
        }