예제 #1
0
        public async void Create()
        {
            Mock <ILogger <EmailAddressRepository> > loggerMoc = EmailAddressRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = EmailAddressRepositoryMoc.GetContext();
            var repository = new EmailAddressRepository(loggerMoc.Object, context);

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

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

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

            EmailAddress entity = new EmailAddress();

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

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

            record.Should().NotBeNull();
        }
예제 #3
0
        public async void Delete()
        {
            Mock <ILogger <EmailAddressRepository> > loggerMoc = EmailAddressRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = EmailAddressRepositoryMoc.GetContext();
            var          repository      = new EmailAddressRepository(loggerMoc.Object, context);
            EmailAddress entity          = new EmailAddress();

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

            await repository.Delete(entity.BusinessEntityID);

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

            modifiedRecord.Should().BeNull();
        }
예제 #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <EmailAddressRepository> > loggerMoc = EmailAddressRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = EmailAddressRepositoryMoc.GetContext();
            var          repository      = new EmailAddressRepository(loggerMoc.Object, context);
            EmailAddress entity          = new EmailAddress();

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

            await repository.Update(new EmailAddress());

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

            modifiedRecord.Should().NotBeNull();
        }