public static void PopulateDb(TimeKeeperDbContext context) { ApplicationUser user1 = new ApplicationUser { Id = "70658403-ade4-47cf-82a6-034e176290f0", Email = "*****@*****.**", UserName = "******", }; ApplicationUser user2 = new ApplicationUser { Id = "2f044b20-3c7f-4be1-b1b5-c55fbfc0c679", Email = "*****@*****.**", UserName = "******", }; // OrganisationId will be 1. Organisation org = new Organisation { Name = "Electronics Store", ManagerId = "70658403-ade4-47cf-82a6-034e176290f0", OrganisationUsers = new List <ApplicationUser> { user2 }, }; context.Add(user1); context.Add(user2); context.Add(org); context.SaveChanges(); }
public void EmployeeSoftDelete_PassingTest() { TimeKeeperDbContext context = new TimeKeeperDbContext(); context.Employees.Remove(context.Employees.First(x => x.FirstName == "Fatima")); context.SaveChanges(); Employee fatima = context.Employees.First(x => x.FirstName == "Fatima"); }
private static void SeedTeams() { Console.Write("Teams: "); rawData = rawData.Open("Teams"); foreach (DataRow row in rawData.Rows) { context.Teams.Add(new Team() { Id = (string)row.Read(0, typeof(string)), Name = (string)row.Read(1, typeof(string)), Description = (string)row.Read(2, typeof(string)) }); } context.SaveChanges(); Console.WriteLine(context.Teams.Count()); }
public void AddProjects_WithoutHours_ValidationTest() { TimeKeeperDbContext context = new TimeKeeperDbContext(); Project newProject = new Project() { Name = "IMT Rezervni Dijelovi za Bagere", Description = "Some IMT Project", Status = ProjectStatus.Finished, Pricing = PricingStatus.HourlyRate, Team = context.Teams.Find("A") }; context.Projects.Add(newProject); context.SaveChanges(); }
public void AddCustomer_ValidData_PassingTest() { TimeKeeperDbContext context = new TimeKeeperDbContext(); Customer Mistral = new Customer() { Name = "Mistral", Status = CustomerStatus.Client, Contact = "Mersed Camdzic", Email = "*****@*****.**", Phone = "062 212 213" }; context.Customers.Add(Mistral); context.SaveChanges(); Assert.AreEqual(3, context.Customers.Count()); }
public void AddEmployee_WithCorrectInputs_PassingTest() { TimeKeeperDbContext context = new TimeKeeperDbContext(); Employee Fatima = new Employee() { FirstName = "Fatima", LastName = "Sinanovic", Email = "*****@*****.**", BirthDate = DateTime.Now.AddYears(-21), Status = EmployeeStatus.Active, BeginDate = DateTime.Now.AddYears(-3), Salary = 1500, Roles = context.Roles.Find("TL") }; context.Employees.Add(Fatima); context.SaveChanges(); Assert.AreEqual(3, Fatima.Id); }
public bool Save() { return(context.SaveChanges() > 0); }