public static void AfterAllTests() { var ctx = new CashFlowEntities(); ctx.Database.ExecuteSqlCommand(@"delete from AspNetUsers where Id = {0}", sampleEmployee.Id); ctx.Database.ExecuteSqlCommand(@"delete from AspNetUsers where Id = {0}", sampleManager.Id); }
public static void BeforeAllTests(TestContext testContext) { var ctx = new CashFlowEntities(); ctx.Database .ExecuteSqlCommand(@"insert into AspNetUsers(Id,FirstName, LastName,Email, Username) Values({0},'Clark','Kent','*****@*****.**','*****@*****.**')", sampleEmployee.Id); ctx.Database .ExecuteSqlCommand(@"insert into AspNetUsers(Id,FirstName, LastName,Email, Username) Values({0},'Bruce','Wayne','*****@*****.**','*****@*****.**')", sampleManager.Id); }
public void Should_Be_Able_To_Retrieve_All_Staffs_In_Database() { using (CashFlowEntities context = new CashFlowEntities()) using (var repo = new StaffRepository(context)) using (DbContextTransaction transaction = context.Database.BeginTransaction()) { repo.Create(sampleEmployee); repo.Create(sampleManager); Assert.AreEqual(2, context.Staffs.Count()); transaction.Rollback(); } }
public void Can_Retrieve_Staff_From_DataBase_Using_Id() { using (CashFlowEntities context = new CashFlowEntities()) using (var repo = new StaffRepository(context)) using (DbContextTransaction transaction = context.Database.BeginTransaction()) { repo.Create(TestData.sampleManager); Staff manager = context.Staffs.Single(); Staff managerId = repo.GetStaff(manager.Id); Assert.IsNotNull(manager); Assert.AreEqual("Bruce Wayne", manager.Name); transaction.Rollback(); } }
public void Can_Successfully_Create_New_Income_In_DataBase() { using (CashFlowEntities context = new CashFlowEntities()) using (var repo = new IncomeRepository(context)) using (var staffRepo = new StaffRepository(context)) using (DbContextTransaction transaction = context.Database.BeginTransaction()) { context.Staffs.Add(sampleManager); context.SaveChanges(); Income income = new Income("Web_Advertisment", 3000, sampleManager.Id); repo.Create(income); var dbIncome = sampleManager.Incomes.SingleOrDefault(); Assert.AreEqual(3000, dbIncome.Amount); transaction.Rollback(); } }
public void BeforeEach() { _context = new CashFlowEntities(); _transaction = _context.Database.BeginTransaction(); }
public IncomeRepository(CashFlowEntities context) { _db = context; _externalContext = true; }
public IncomeRepository() { _db = new CashFlowEntities(); }
public StaffRepository() { _db = new CashFlowEntities(); }
public ExpenseRepository() { _db = new CashFlowEntities(); }