Example #1
0
        public async void Create()
        {
            Mock <ILogger <EmployeeDepartmentHistoryRepository> > loggerMoc = EmployeeDepartmentHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = EmployeeDepartmentHistoryRepositoryMoc.GetContext();
            var repository = new EmployeeDepartmentHistoryRepository(loggerMoc.Object, context);

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

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

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

            EmployeeDepartmentHistory entity = new EmployeeDepartmentHistory();

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

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

            record.Should().NotBeNull();
        }
Example #3
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <EmployeeDepartmentHistoryRepository> > loggerMoc = EmployeeDepartmentHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = EmployeeDepartmentHistoryRepositoryMoc.GetContext();
            var repository = new EmployeeDepartmentHistoryRepository(loggerMoc.Object, context);
            EmployeeDepartmentHistory entity = new EmployeeDepartmentHistory();

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

            await repository.Update(new EmployeeDepartmentHistory());

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

            modifiedRecord.Should().NotBeNull();
        }