public AccountTests() { var config = new MapperConfiguration(cfg => { cfg.AddProfile(new WebApi.Mappings.AutoMapper()); }); var mapper = config.CreateMapper(); var customersData = new List <Customer> { new Customer { FirstName = "Rena", LastName = "Markiewitz", Email = "*****@*****.**", CustomerId = new Guid("E7775225-9C97-4460-D971-08D82BD1D7C5"), Password = "******", Salt = "/PAaJXFGVGOxEWdGHv9TD+P6s9DaYmTws8ZMUkCp9Ow=" }, }; var accountsData = new List <Data.Entities.Account> { new Data.Entities.Account { AccountId = new Guid("9CFE55DF-65E2-4204-BAD5-08D82BD21687"), Balance = 1000.00, Customer = customersData.FirstOrDefault(c => c.CustomerId == new Guid("E7775225-9C97-4460-D971-08D82BD1D7C5")), OpenDate = Convert.ToDateTime("2020-07-19 13:03:43.4326053"), CustomerId = new Guid("E7775225-9C97-4460-D971-08D82BD1D7C5") }, }; var customers = new Mock <DbSet <Customer> >(); customers.SetSource(customersData); var accounts = new Mock <DbSet <Data.Entities.Account> >(); accounts.SetSource(accountsData); var context = new Mock <AccountContext>(); context.Setup(m => m.Accounts).Returns(accounts.Object); context.Setup(m => m.Customers).Returns(customers.Object); var newAccountRepository = new NewAccountRepository(context.Object, mapper); _service = new NewAccountService(newAccountRepository); }
public NewAccountTests() { var config = new MapperConfiguration(cfg => { cfg.AddProfile(new WebApi.Mappings.AutoMapper()); }); var mapper = config.CreateMapper(); IQueryable <Customer> customersData = new List <Customer> { new Customer { FirstName = "Rena", LastName = "Markiewitz", Email = "*****@*****.**", CustomerId = new Guid("E7775225-9C97-4460-D971-08D82BD1D7C5"), Password = "******", Salt = "/PAaJXFGVGOxEWdGHv9TD+P6s9DaYmTws8ZMUkCp9Ow=" }, }.AsQueryable(); var accountsData = new List <Data.Entities.Account> { new Data.Entities.Account { AccountId = new Guid("9CFE55DF-65E2-4204-BAD5-08D82BD21687"), Balance = 1000000, Customer = customersData.FirstOrDefault(c => c.CustomerId == new Guid("E7775225-9C97-4460-D971-08D82BD1D7C5")), OpenDate = Convert.ToDateTime("2020-07-19 13:03:43.4326053"), CustomerId = new Guid("E7775225-9C97-4460-D971-08D82BD1D7C5") }, }.AsQueryable(); var emailVerificationsData = new List <EmailVerification> { new EmailVerification { Email = "*****@*****.**", VerificationCode = 1234, ExpirationTime = DateTime.Now.AddDays(1) }, new EmailVerification { Email = "*****@*****.**", VerificationCode = 5678, ExpirationTime = DateTime.Now.AddMinutes(15) }, }.AsQueryable(); var operationsHistoryData = new List <OperationHistory> { new OperationHistory { OperationTime = DateTime.Now, AccountId = new Guid("9CFE55DF-65E2-4204-BAD5-08D82BD21687"), TransactionAmount = 0, TransactionId = Guid.NewGuid(), Balance = 10000, Debit = true, OperationHistoryId = Guid.NewGuid() }, new OperationHistory { OperationTime = DateTime.Now.AddDays(1), AccountId = new Guid("9CFE55DF-65E2-4204-BAD5-08D82BD21687"), TransactionAmount = 0, TransactionId = Guid.NewGuid(), Balance = 10000, Debit = false, OperationHistoryId = Guid.NewGuid() }, }.AsQueryable(); var context = new Mock <AccountContext>(); context.SetupGet(x => x.Customers).Returns(MockDBSetExtensions.GetDbSet(customersData).Object); context.SetupGet(x => x.Accounts).Returns(MockDBSetExtensions.GetDbSet(accountsData).Object); context.SetupGet(x => x.EmailVerifications).Returns(MockDBSetExtensions.GetDbSet(emailVerificationsData).Object); context.SetupGet(x => x.OperationsHistory).Returns(MockDBSetExtensions.GetDbSet(operationsHistoryData).Object); var newAccountRepository = new NewAccountRepository(context.Object, mapper); _service = new NewAccountService(newAccountRepository); }