public LightLoanDbContextTest() { dateTime = new DateTime(3001, 1, 1); _datetimeServiceMock = new Mock <IDatetimeService>(); _datetimeServiceMock.Setup(m => m.Now).Returns(dateTime); userId = Guid.NewGuid(); _userServiceMock = new Mock <IUserService>(); _userServiceMock.Setup(m => m.UserId).Returns(userId); var options = new DbContextOptionsBuilder <LightLoanDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; _dbContext = new LightLoanDbContext(_userServiceMock.Object, _datetimeServiceMock.Object, options); testId = Guid.NewGuid(); Branch branch = new Branch { Id = testId, Name = "Test Branch For Change", Address = new Address { Id = 1, Line1 = "Line1 Test", Line2 = "Line2 Test", City = "City Test", Country = "Country Test", Status = (char)Domain.Enums.Status.New }, Phone1 = "Test Phone 1", Phone2 = "Test Phone 2", HashValue1 = "Test Hash value 1", HashValue2 = "Test Hash value 2" }; _dbContext.Branches.Add(branch); _dbContext.SaveChanges(); }
public static LightLoanDbContext Create() { var dateTime = new DateTime(3001, 1, 1); var _datetimeServiceMock = new Mock <IDatetimeService>(); _datetimeServiceMock.Setup(m => m.Now).Returns(dateTime); var userId = Guid.NewGuid(); var _userServiceMock = new Mock <IUserService>(); _userServiceMock.Setup(m => m.UserId).Returns(userId); var options = new DbContextOptionsBuilder <LightLoanDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; var _dbContext = new LightLoanDbContext(_userServiceMock.Object, _datetimeServiceMock.Object, options); _dbContext.Database.EnsureCreated(); return(_dbContext); }
public static void Destroy(LightLoanDbContext dbContext) { dbContext.Database.EnsureDeleted(); dbContext.Dispose(); }
public CommandTestBase() { _dbContext = LightLoanDbContextFactory.Create(); }