Exemplo n.º 1
0
        public void CheckIfDayDeleted()
        {
            TimeKeeperContext context = new TimeKeeperContext();

            Employee emp1 = new Employee()
            {
                FirstName = "Hamida",
                LastName  = "Hamidovic",
                Position  = context.Roles.Find("DEV")
            };

            Day d = new Day()
            {
                Date     = DateTime.Now,
                Hours    = 8m,
                Type     = DayType.WorkingDay,
                Employee = emp1
            };

            context.Employees.Add(emp1);
            context.Days.Add(d);
            context.SaveChanges();

            context.Days.Remove(d);
            context.SaveChanges();

            d = context.Days.FirstOrDefault(x => x.Employee.FirstName == emp1.FirstName);
            Assert.IsNull(d);
        }
Exemplo n.º 2
0
        public void CheckProject()
        {
            TimeKeeperContext context = new TimeKeeperContext();

            //Arrange
            Team t = new Team()
            {
                Id    = "n01",
                Image = null,
                Name  = "Navajo team"
            };

            context.Teams.Add(t);
            context.SaveChanges();

            Address add = new Address
            {
                City    = "Sarajevo",
                Name    = "Bosmal",
                ZipCode = "71000"
            };

            //Customer c = new Customer()
            //{
            //    Name = "Mistral Technologies",
            //    Image = null,
            //    Monogram = null,
            //    Contact = "Sulejman Catibusic",
            //    Email = "*****@*****.**",
            //    Phone = "+38761200333",
            //    StatusCustomer = StatusCustomer.Client,
            //    Address = add
            //};

            //context.Customers.Add(c);
            //context.SaveChanges();

            Project p = new Project()
            {
                Name          = "TimeKeeper",
                Description   = "Application for time tracking",
                Amount        = 1000,
                BeginDate     = DateTime.Now,
                EndDate       = DateTime.Now,
                StatusProject = StatusProject.InProgress,
                Pricing       = Pricing.HourlyRate,
                //Customer = c,
                Team = t
            };

            //Act
            context.Projects.Add(p);
            context.SaveChanges();

            //Assert
            Assert.AreEqual("TimeKeeper", p.Name);
            //Assert.AreEqual("Mistral Technologies", p.Customer.Name);
            Assert.AreEqual("Navajo team", p.Team.Name);
        }
Exemplo n.º 3
0
        public void CheckIfProjDeleted()
        {
            TimeKeeperContext context = new TimeKeeperContext();

            Team t = new Team()
            {
                Id    = "n03",
                Image = null,
                Name  = "Navajo team"
            };

            Address add = new Address
            {
                City    = "Sarajevo",
                Name    = "Bosmal",
                ZipCode = "71000"
            };

            Customer c = new Customer()
            {
                Name           = "Mistral Technologies",
                Image          = null,
                Monogram       = null,
                Contact        = "Sulejman Catibusic",
                Email          = "*****@*****.**",
                Phone          = "+38761200333",
                StatusCustomer = StatusCustomer.Client,
                Address        = add
            };

            Project p = new Project()
            {
                Name          = "Testera",
                Description   = "Application for wood cutting",
                Amount        = 1000,
                BeginDate     = DateTime.Now,
                EndDate       = DateTime.Now,
                StatusProject = StatusProject.InProgress,
                Pricing       = Pricing.HourlyRate,
                Customer      = c,
                Team          = t
            };

            //Act
            context.Projects.Add(p);
            context.SaveChanges();

            context.Projects.Remove(p);
            context.SaveChanges();

            p = context.Projects
                .FirstOrDefault(x => x.Name == "Testera");
            Assert.IsNull(p);
        }
Exemplo n.º 4
0
        public void CheckEmployee()
        {
            //Arrange
            TimeKeeperContext context = new TimeKeeperContext();

            Employee emp1 = new Employee()
            {
                FirstName = "Esma",
                LastName  = "Holjan",
                Position  = context.Roles.Find("DEV")
            };

            Employee emp2 = new Employee()
            {
                FirstName = "Bekac",
                LastName  = "Beks",
                Position  = context.Roles.Find("DEV"),
            };

            //Act
            context.Employees.Add(emp1);
            context.Employees.Add(emp2);
            context.SaveChanges();

            //Assert
            Assert.AreEqual("Esma", emp1.FirstName);
            Assert.AreEqual("Beks", emp2.LastName);
        }
Exemplo n.º 5
0
        public void CheckCustomer()
        {
            TimeKeeperContext context = new TimeKeeperContext();

            Address add = new Address();

            add.City    = "Sarajevo";
            add.Name    = "Bosmal";
            add.ZipCode = "71000";

            Customer c = new Customer()
            {
                Name           = "Mistral Technologies",
                Image          = null,
                Monogram       = null,
                Contact        = "Sulejman Catibusic",
                Email          = "*****@*****.**",
                Phone          = "+38761200333",
                StatusCustomer = StatusCustomer.Client,
                Address        = add
            };

            context.Customers.Add(c);
            context.SaveChanges();

            Assert.AreEqual("Sulejman Catibusic", c.Contact);
        }
Exemplo n.º 6
0
        public void CheckDay()
        {
            TimeKeeperContext context = new TimeKeeperContext();

            Employee emp1 = new Employee()
            {
                FirstName = "Tester",
                LastName  = "Testerovski",
                Position  = context.Roles.Find("DEV")
            };

            Day d = new Day()
            {
                Date     = DateTime.Now,
                Hours    = 8m,
                Type     = DayType.WorkingDay,
                Employee = emp1
            };

            context.Employees.Add(emp1);
            context.Days.Add(d);
            context.SaveChanges();

            Assert.AreEqual(8, d.Hours);
        }
Exemplo n.º 7
0
 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());
 }
Exemplo n.º 8
0
        public void CheckIfDeletedEmp()
        {
            TimeKeeperContext context = new TimeKeeperContext();

            Employee emp = new Employee()
            {
                FirstName = "Bekir",
                LastName  = "Bukvarevic",
                Position  = context.Roles.Find("DEV")
            };

            //Act
            context.Employees.Add(emp);
            context.SaveChanges();

            context.Employees.Remove(emp);
            context.SaveChanges();

            //Assert
            emp = context.Employees
                  .FirstOrDefault(x => x.FirstName == "Bekir");
            Assert.IsNull(emp);
        }
Exemplo n.º 9
0
        public void CheckIfUpdated()
        {
            TimeKeeperContext context = new TimeKeeperContext();
            Employee          emp1    = new Employee()
            {
                FirstName = "Bekir",
                LastName  = "Beks",
                Position  = context.Roles.Find("DEV"),
            };

            context.Employees.AddOrUpdate(emp1);
            context.SaveChanges();

            Assert.AreEqual("Bekir", emp1.FirstName);
        }
Exemplo n.º 10
0
        public void GetEngagementsSuccess()
        {
            TimeKeeperContext context = new TimeKeeperContext();

            Team t = new Team()
            {
                Id    = "n04",
                Image = null,
                Name  = "NavajoO team"
            };

            Employee emp1 = new Employee()
            {
                FirstName = "Hamo",
                LastName  = "Hamic",
                Position  = context.Roles.Find("DEV")
            };

            Engagement eng1 = new Engagement()
            {
                Hours    = 40m,
                Employee = emp1,
                Team     = t,
                Role     = context.Roles.Find("SD")
            };

            context.Engagements.Add(eng1);
            context.SaveChanges();

            var controller = new EngagementsController();

            var response = controller.Get(1);
            var result   = (OkNegotiatedContentResult <EngagementModel>)response;

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Content);
        }
Exemplo n.º 11
0
 public void Save()
 {
     context.SaveChanges();
 }
Exemplo n.º 12
0
 public bool Save()
 {
     return(timeKeeperContext.SaveChanges() > 0);
 }
Exemplo n.º 13
0
 public bool Save()
 {
     return(context.SaveChanges() > 0);
 }