public void Initialize() { //string connectionString = "data source=MIKE_LAPTOP;initial catalog=FinanceINT;integrated security=True;App=MSTest;"; //var mcfactory = new ModelContextFactory(connectionString); //IScheduleFactory scheduleFactory = new Fakes.FakeScheduleFactory(); //transferFactory = new Fakes.FakeTransferFactory(scheduleFactory); //new Finances.Persistence.EF.MappingCreator(transferFactory).CreateMappings(); //repository = new BankAccountRepository(mcfactory,Mapper.Engine); repository = container.Resolve<IBankAccountRepository>(); testEntity = new Core.Entities.BankAccount() { Bank = new Core.Entities.Bank() { BankId = 1 }, AccountNumber = "1234", AccountOwner = "me", Name = "Test-" + Guid.NewGuid().ToString(), LoginID = "login", LoginURL = "abc", PasswordHint = "hint", OpenedDate = DateTime.Now.Date, ClosedDate = DateTime.Now.Date.AddDays(1), SortCode = "000010", InitialRate = 1.1M, PaysTaxableInterest = true, MilestoneDate = DateTime.Now.Date.AddDays(2), MilestoneNotes = "msnotes", Notes = "test notes" }; }
private void CompareBankAccounts(Core.Entities.BankAccount entity1, Core.Entities.BankAccount entity2, string prefix) { Assert.IsNotNull(entity1, "{0} - entity1", prefix); Assert.IsNotNull(entity2, "{0} - entity2", prefix); Assert.AreEqual(entity1.BankAccountId, entity2.BankAccountId, "{0} - BankAccountId", prefix); Assert.AreEqual(entity1.Name, entity2.Name, "{0} - Name", prefix); Assert.IsNotNull(entity1.Bank, "{0} - entity1.Bank", prefix); Assert.IsNotNull(entity2.Bank, "{0} - entity2.Bank", prefix); Assert.AreEqual(entity1.Bank.BankId, entity2.Bank.BankId, "{0} - BankId", prefix); Assert.AreEqual(entity1.SortCode, entity2.SortCode, "{0} - SortCode", prefix); Assert.AreEqual(entity1.AccountNumber, entity2.AccountNumber, "{0} - AccountNumber", prefix); Assert.AreEqual(entity1.AccountOwner, entity2.AccountOwner, "{0} - AccountOwner", prefix); Assert.AreEqual(entity1.PaysTaxableInterest, entity2.PaysTaxableInterest, "{0} - PaysTaxableInterest", prefix); Assert.AreEqual(entity1.LoginURL, entity2.LoginURL, "{0} - LoginURL", prefix); Assert.AreEqual(entity1.LoginID, entity2.LoginID, "{0} - LoginID", prefix); Assert.AreEqual(entity1.PasswordHint, entity2.PasswordHint, "{0} - PasswordHint", prefix); Assert.AreEqual(entity1.OpenedDate, entity2.OpenedDate, "{0} - OpenedDate", prefix); Assert.AreEqual(entity1.ClosedDate, entity2.ClosedDate, "{0} - ClosedDate", prefix); Assert.AreEqual(entity1.InitialRate, entity2.InitialRate, "{0} - InitialRate", prefix); Assert.AreEqual(entity1.MilestoneDate, entity2.MilestoneDate, "{0} - MilestoneDate", prefix); Assert.AreEqual(entity1.MilestoneNotes, entity2.MilestoneNotes, "{0} - MilestoneNotes", prefix); Assert.AreEqual(entity1.Notes, entity2.Notes, "{0} - Notes", prefix); }
public bool Delete(Core.Entities.BankAccount entity) { var ef = mapper.Map <BankAccount>(entity); using (FinanceEntities context = factory.CreateContext()) { context.Entry(ef).State = EntityState.Deleted; context.SaveChanges(); } return(true); }
public Core.Entities.BankAccount Read(int id) { Core.Entities.BankAccount entity = null; using (FinanceEntities context = factory.CreateContext()) { var ef = (from b in context.BankAccounts.Include(a => a.Bank) where b.BankAccountId == id select b).FirstOrDefault(); entity = mapper.Map <Core.Entities.BankAccount>(ef); } return(entity); }
public bool Update(Core.Entities.BankAccount entity) { var ef = mapper.Map <BankAccount>(entity); using (FinanceEntities context = factory.CreateContext()) { context.Entry(ef).State = EntityState.Modified; context.SaveChanges(); } //read back columns which may have changed entity.RecordUpdatedDateTime = ef.RecordUpdatedDateTime; return(true); }
public int Add(Core.Entities.BankAccount entity) { int id = 0; var ef = mapper.Map <BankAccount>(entity); using (FinanceEntities context = factory.CreateContext()) { context.Entry(ef).State = EntityState.Added; context.SaveChanges(); } //read back columns which may have changed entity.BankAccountId = ef.BankAccountId; entity.RecordCreatedDateTime = ef.RecordCreatedDateTime; entity.RecordUpdatedDateTime = ef.RecordUpdatedDateTime; id = ef.BankAccountId; return(id); }
public void Initialize() { //string connectionString = "data source=MIKE_LAPTOP;initial catalog=FinanceINT;integrated security=True;App=MSTest;"; //var mcfactory = new ModelContextFactory(connectionString); //IScheduleFactory scheduleFactory = new Fakes.FakeScheduleFactory(); //transferFactory = new Fakes.FakeTransferFactory(scheduleFactory); //new Finances.Persistence.EF.MappingCreator(transferFactory).CreateMappings(); //repository = new BankAccountRepository(mcfactory,Mapper.Engine); repository = container.Resolve <IBankAccountRepository>(); testEntity = new Core.Entities.BankAccount() { Bank = new Core.Entities.Bank() { BankId = 1 }, AccountNumber = "1234", AccountOwner = "me", Name = "Test-" + Guid.NewGuid().ToString(), LoginID = "login", LoginURL = "abc", PasswordHint = "hint", OpenedDate = DateTime.Now.Date, ClosedDate = DateTime.Now.Date.AddDays(1), SortCode = "000010", InitialRate = 1.1M, PaysTaxableInterest = true, MilestoneDate = DateTime.Now.Date.AddDays(2), MilestoneNotes = "msnotes", Notes = "test notes" }; }