Пример #1
0
        public async void Create()
        {
            Mock <ILogger <SalesPersonRepository> > loggerMoc = SalesPersonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SalesPersonRepositoryMoc.GetContext();
            var repository = new SalesPersonRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Пример #2
0
        public async void Get()
        {
            Mock <ILogger <SalesPersonRepository> > loggerMoc = SalesPersonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SalesPersonRepositoryMoc.GetContext();
            var repository = new SalesPersonRepository(loggerMoc.Object, context);

            SalesPerson entity = new SalesPerson();

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

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

            record.Should().NotBeNull();
        }
Пример #3
0
        public async void Delete()
        {
            Mock <ILogger <SalesPersonRepository> > loggerMoc = SalesPersonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SalesPersonRepositoryMoc.GetContext();
            var         repository       = new SalesPersonRepository(loggerMoc.Object, context);
            SalesPerson entity           = new SalesPerson();

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

            await repository.Delete(entity.BusinessEntityID);

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

            modifiedRecord.Should().BeNull();
        }
Пример #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <SalesPersonRepository> > loggerMoc = SalesPersonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SalesPersonRepositoryMoc.GetContext();
            var         repository       = new SalesPersonRepository(loggerMoc.Object, context);
            SalesPerson entity           = new SalesPerson();

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

            await repository.Update(new SalesPerson());

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

            modifiedRecord.Should().NotBeNull();
        }