Exemplo n.º 1
0
        public async void Create()
        {
            Mock <ILogger <ShipMethodRepository> > loggerMoc = ShipMethodRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ShipMethodRepositoryMoc.GetContext();
            var repository = new ShipMethodRepository(loggerMoc.Object, context);

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

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

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

            ShipMethod entity = new ShipMethod();

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

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

            record.Should().NotBeNull();
        }
Exemplo n.º 3
0
        public async void Delete()
        {
            Mock <ILogger <ShipMethodRepository> > loggerMoc = ShipMethodRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ShipMethodRepositoryMoc.GetContext();
            var        repository        = new ShipMethodRepository(loggerMoc.Object, context);
            ShipMethod entity            = new ShipMethod();

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

            await repository.Delete(entity.ShipMethodID);

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

            modifiedRecord.Should().BeNull();
        }
Exemplo n.º 4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <ShipMethodRepository> > loggerMoc = ShipMethodRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ShipMethodRepositoryMoc.GetContext();
            var        repository        = new ShipMethodRepository(loggerMoc.Object, context);
            ShipMethod entity            = new ShipMethod();

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

            await repository.Update(new ShipMethod());

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

            modifiedRecord.Should().NotBeNull();
        }