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

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

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

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

            Address entity = new Address();

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

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

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

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

            await repository.Delete(entity.AddressID);

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

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

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

            await repository.Update(new Address());

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

            modifiedRecord.Should().NotBeNull();
        }