public GetContextWithData() { var options = new DbContextOptionsBuilder <AdviceFirstDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; _context = new AdviceFirstDbContext(options); GetLoadData(); }
public void RefreshContext() { var options = new DbContextOptionsBuilder <AdviceFirstDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; _dataContext = new AdviceFirstDbContext(options); // Add Users _dataContext.AfUser.Add(new AfUser { Id = 1, UserCode = "AA", UserName = "******", UserCodeName = "AA - AA User", UserRole = "User", UserStatus = AfUserStatus.Active }); _dataContext.AfUser.Add(new AfUser { Id = 2, UserCode = "BB", UserName = "******", UserCodeName = "BB - BB User", UserRole = "User", UserStatus = AfUserStatus.Active }); _dataContext.AfUser.Add(new AfUser { Id = 3, UserCode = "CC", UserName = "******", UserCodeName = "CC - CC User", UserRole = "User", UserStatus = AfUserStatus.Active }); _dataContext.AfUser.Add(new AfUser { Id = 4, UserCode = "DD", UserName = "******", UserCodeName = "DD - DD User", UserRole = "User", UserStatus = AfUserStatus.Active }); _dataContext.SaveChanges(); }
public AdviceFirstRepository(AdviceFirstDbContext context, IMapper mapper, ILogger <AdviceFirstRepository> logger) { _context = context ?? throw new ArgumentNullException(nameof(context)); _mapper = mapper; _logger = logger; }