Exemple #1
0
        public async Task <IHttpActionResult> PostOpgaver(Opgaver opgaver)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Opgaver.Add(opgaver);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (OpgaverExists(opgaver.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = opgaver.ID }, opgaver));
        }
Exemple #2
0
        public void TestMethod1()
        {
            //Arrange
            ViewModel     vm                 = new ViewModel();
            DBPersistency dbContext          = new DBPersistency();
            Kunder        k1                 = new Kunder(20, "Carl", "20202020", "Solvej22");
            Opgaver       o1                 = new Opgaver(20, 20, "Hækklipning 4 timer", null, false);
            string        expectedPreUpdate  = "Hækklipning 4 timer";
            string        expectedPostUpdate = "græsslåning";


            //Act
            vm.SelectedOpgave = o1;
            vm.AddKunde(k1);
            vm.AddOpgave(o1);


            if (vm.OpgaveList[20].Beskrivelse == expectedPreUpdate)
            {
                o1.Beskrivelse = "græsslåning";
                vm.UpdateOpgave(o1);
            }



            //Assert

            Assert.Equals(expectedPostUpdate, vm.OpgaveList[20].Beskrivelse);
        }
Exemple #3
0
        public void OpdateringAfOpgavePåDB()
        {
            //Arrange - Opstilling
            ViewModel vm = new ViewModel();

            Opgaver o1 = new Opgaver(20, 20, "Hækklipning 4 timer", null, false);
            string  expectedPreUpdate  = "Hækklipning 4 timer";
            string  expectedPostUpdate = "græsslåning";

            //Act - Handling vi ønsker udført
            vm.UpdateOpgave(o1);

            var Query1 = from n in vm.OpgaveList where n.ID == 20 select n;

            if (Query1.FirstOrDefault().Beskrivelse == expectedPreUpdate)
            {
                o1.Beskrivelse = "græsslåning";
                vm.UpdateOpgave(o1);
            }


            var Query2 = from n in vm.OpgaveList where n.Beskrivelse == expectedPostUpdate select n;

            string ActualPostUpdate = Query2.FirstOrDefault().Beskrivelse;

            //Assert - Kontrollere resultatet af handlingen ud fra opstillingen.

            Assert.AreEqual(expectedPostUpdate, ActualPostUpdate);
        }
 public void Exercise4ATest()
 {
     int[] intArray = { 1, 3, 4, 5, 6, 8, 9, 11 };
     Assert.Equal(8, Opgaver.StepsInLinearSearch(11, intArray));
     Assert.Equal(4, Opgaver.StepsInLinearSearch(5, intArray));
     //Assert.Equal(???, Opgaver.StepsInLinearSearch(9, intArray));
 }
Exemple #5
0
        public async Task <IHttpActionResult> PutOpgaver(int id, Opgaver opgaver)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != opgaver.ID)
            {
                return(BadRequest());
            }

            db.Entry(opgaver).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OpgaverExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public void Exercise4BTest()
 {
     int[] intArray = { 1, 3, 4, 5, 6, 8, 9, 11 };
     Assert.Equal(2, Opgaver.StepsInBinarySearch(intArray, 0, intArray.Length - 1, 3));
     Assert.Equal(1, Opgaver.StepsInBinarySearch(intArray, 0, intArray.Length - 1, 5));
     Assert.Equal(3, Opgaver.StepsInBinarySearch(intArray, 0, intArray.Length - 1, 9));
 }
        public IHttpActionResult PostOpgaver(Opgaver opgaver)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Opgavers.Add(opgaver);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (OpgaverExists(opgaver.ArbejdsId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = opgaver.ArbejdsId }, opgaver));
        }
        public void Exercise1Test()
        {
            int x = 5, y = 10;

            Opgaver.Interchange(ref x, ref y);
            Assert.Equal(10, x);
            Assert.Equal(5, y);
        }
Exemple #9
0
        public ActionResult DeleteConfirmed(int id)
        {
            Opgaver opgaver = db.Opgavers.Find(id);

            db.Opgavers.Remove(opgaver);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public void Exercise9Test()
 {
     Assert.Equal("foo1", Opgaver.IncrementString("foo"));
     Assert.Equal("foobar01003", Opgaver.IncrementString("foobar01002"));
     Assert.Equal("foobar00600", Opgaver.IncrementString("foobar00599"));
     Assert.Equal("foo100", Opgaver.IncrementString("foo099"));
     Assert.Equal("foo10000", Opgaver.IncrementString("foo09999"));
     Assert.Equal("foo10000", Opgaver.IncrementString("foo9999"));
 }
        public void Exercise2Test()
        {
            int a = 1, b = 2, c = 3;

            Opgaver.InterchangeTriple(ref a, ref b, ref c);
            Assert.Equal(3, a);
            Assert.Equal(1, b);
            Assert.Equal(2, c);
        }
 public void Exercise6Test()
 {
     Assert.Equal(new int[] { 7, 14, 21, 28, 35 }, Opgaver.ArrayOfMultiples(7, 5));
     Assert.Equal(new int[] { 12, 24, 36, 48, 60, 72, 84, 96, 108, 120 }, Opgaver.ArrayOfMultiples(12, 10));
     Assert.Equal(new int[] { 17, 34, 51, 68, 85, 102, 119 }, Opgaver.ArrayOfMultiples(17, 7));
     Assert.Equal(new int[] { 630, 1260, 1890, 2520, 3150, 3780, 4410, 5040, 5670, 6300, 6930, 7560, 8190, 8820 }, Opgaver.ArrayOfMultiples(630, 14));
     Assert.Equal(new int[] { 140, 280, 420 }, Opgaver.ArrayOfMultiples(140, 3));
     Assert.Equal(new int[] { 7, 14, 21, 28, 35, 42, 49, 56 }, Opgaver.ArrayOfMultiples(7, 8));
     Assert.Equal(new int[] { 11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231 }, Opgaver.ArrayOfMultiples(11, 21));
 }
 public void Exercise7Test()
 {
     Assert.Equal(1, Opgaver.PowerRanger(5, 31, 33));
     Assert.Equal(3, Opgaver.PowerRanger(4, 250, 1300));
     Assert.Equal(2, Opgaver.PowerRanger(2, 49, 65));
     Assert.Equal(3, Opgaver.PowerRanger(3, 1, 27));
     Assert.Equal(1, Opgaver.PowerRanger(10, 1, 5));
     Assert.Equal(5, Opgaver.PowerRanger(1, 1, 5));
     Assert.Equal(10, Opgaver.PowerRanger(2, 1, 100));
 }
Exemple #14
0
        public ViewModel()
        {
            ObservableCollection <Hjælpere> HjælperList = new ObservableCollection <Hjælpere>();
            ObservableCollection <Opgaver>  OpgaveList  = new ObservableCollection <Opgaver>();
            ObservableCollection <Kunder>   KunderList  = new ObservableCollection <Kunder>();

            _selectedHjælper = new Hjælpere();
            _selectedKunde   = new Kunder();
            _selectedOpgave  = new Opgaver();
        }
Exemple #15
0
        public async Task <IHttpActionResult> GetOpgaver(int id)
        {
            Opgaver opgaver = await db.Opgaver.FindAsync(id);

            if (opgaver == null)
            {
                return(NotFound());
            }

            return(Ok(opgaver));
        }
        public IHttpActionResult GetOpgaver(int id)
        {
            Opgaver opgaver = db.Opgavers.Find(id);

            if (opgaver == null)
            {
                return(NotFound());
            }

            return(Ok(opgaver));
        }
Exemple #17
0
 public ActionResult Edit([Bind(Include = "id,addresse,dato,beskrivelse,udføres,jobnr,fk_stauts,fk_kategori")] Opgaver opgaver)
 {
     if (ModelState.IsValid)
     {
         db.Entry(opgaver).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.fk_kategori = new SelectList(db.Kategoris, "katid", "kategori1", opgaver.fk_kategori);
     ViewBag.fk_stauts   = new SelectList(db.status, "statusid", "status1", opgaver.fk_stauts);
     return(View(opgaver));
 }
        public void Exercise3Test()
        {
            string palindrome = "level";

            Assert.True(Opgaver.IsPalindrome(palindrome));
            palindrome = "cammac";
            Assert.True(Opgaver.IsPalindrome(palindrome));
            palindrome = "kayak";
            Assert.True(Opgaver.IsPalindrome(palindrome));
            palindrome = "ward draw";
            Assert.True(Opgaver.IsPalindrome(palindrome));
        }
 public void Exercise8Test()
 {
     Assert.Equal(1, Opgaver.Factorial(0));
     Assert.Equal(2, Opgaver.Factorial(2));
     Assert.Equal(6, Opgaver.Factorial(3));
     Assert.Equal(24, Opgaver.Factorial(4));
     Assert.Equal(120, Opgaver.Factorial(5));
     Assert.Equal(720, Opgaver.Factorial(6));
     Assert.Equal(3628800, Opgaver.Factorial(10));
     Assert.Equal(6227020800, Opgaver.Factorial(13));
     Assert.Equal(87178291200, Opgaver.Factorial(14));
 }
        public void Exercise5Test()
        {
            List <int> listA = new List <int> {
                1, 2, 3, 5, 6, 8, 9
            };

            Assert.Equal(3, Opgaver.InsertSortedList(listA, 4));
            List <int> listB = new List <int> {
                1, 2, 3, 5, 6, 8, 9
            };

            Assert.Equal(5, Opgaver.InsertSortedList(listB, 7));
        }
Exemple #21
0
        public async Task <IHttpActionResult> DeleteOpgaver(int id)
        {
            Opgaver opgaver = await db.Opgaver.FindAsync(id);

            if (opgaver == null)
            {
                return(NotFound());
            }

            db.Opgaver.Remove(opgaver);
            await db.SaveChangesAsync();

            return(Ok(opgaver));
        }
Exemple #22
0
        // GET: Home/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Opgaver opgaver = db.Opgavers.Find(id);

            if (opgaver == null)
            {
                return(HttpNotFound());
            }
            return(View(opgaver));
        }
        public IHttpActionResult DeleteOpgaver(int id)
        {
            Opgaver opgaver = db.Opgavers.Find(id);

            if (opgaver == null)
            {
                return(NotFound());
            }

            db.Opgavers.Remove(opgaver);
            db.SaveChanges();

            return(Ok(opgaver));
        }
 public void Aspfk()
 {
     // INVALID PASSWORDS
     Assert.False(Opgaver.ValidatePassword("P1zz@"));                     //5 characters
     Assert.False(Opgaver.ValidatePassword("P1zz@P1zz@P1zz@P1zz@P1zz@")); //25 characters
     Assert.False(Opgaver.ValidatePassword("mypassword11"));              //No uppercase
     Assert.False(Opgaver.ValidatePassword("MYPASSWORD11"));              //No lowercase
     Assert.False(Opgaver.ValidatePassword("iLoveYou"));                  //No numbers
     Assert.False(Opgaver.ValidatePassword("Pè7$areLove"));               //è is not a speciel character
     // VALID PASSWORDS
     Assert.True(Opgaver.ValidatePassword("H4(k+x0z"));
     Assert.True(Opgaver.ValidatePassword("Fhweg93@"));
     Assert.True(Opgaver.ValidatePassword("aA0!@#$%^&*()+=_-{}[]:;\""));
     Assert.True(Opgaver.ValidatePassword("zZ9'?<>,."));
 }
Exemple #25
0
        // GET: Home/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Opgaver opgaver = db.Opgavers.Find(id);

            if (opgaver == null)
            {
                return(HttpNotFound());
            }
            ViewBag.fk_kategori = new SelectList(db.Kategoris, "katid", "kategori1", opgaver.fk_kategori);
            ViewBag.fk_stauts   = new SelectList(db.status, "statusid", "status1", opgaver.fk_stauts);
            return(View(opgaver));
        }
Exemple #26
0
        [TestMethod] public void TilknytOpgaveTilHjælper()
        {
            //Arrange
            ViewModel vm = new ViewModel();
            Hjælpere  h1 = vm.HjælperList[1];

            vm.LoggedIndHjælper = h1;
            Opgaver o1 = vm.OpgaveList[1];

            o1.HjælperTilknyttet = 2;
            int expectedAmount = 2;

            //Act
            vm.UpdateOpgave(o1);
            int actualAmount = vm.LoggedInHjælperOpgaverNotDone.Count;

            //Assert
            Assert.AreEqual(expectedAmount, actualAmount);
        }
Exemple #27
0
 public void UpdateOpgave(Opgaver O)
 {
     OpgaverSingleton.Instance.UpdateOpgave(O);
     OnPropertyChanged(nameof(OpgaveList));
 }
Exemple #28
0
 public void RemoveOpgaver(Opgaver o)
 {
     OpgaverSingleton.Instance.RemoveOpgaver(o);
     OnPropertyChanged(nameof(OpgaveList));
 }
        static void Main(string[] args)
        {
            int x = 5;
            int y = 10;

            Opgaver.Interchange(ref x, ref y);
            Console.WriteLine($"INTERCHANGE: {x}, {y}");

            Console.WriteLine();

            int a = 2;
            int b = 4;
            int c = 6;

            Console.Write($"INTERCHANGETRIPLE: ({a}, {b}, {c}) = ");
            Opgaver.InterchangeTriple(ref a, ref b, ref c);
            Console.WriteLine($"({a}, {b}, {c})");

            Console.WriteLine();

            string[] palindromeChecks = { "racecar", "radar", "rotator", "tenet", "kayak", "ass" };
            foreach (string s in palindromeChecks)
            {
                bool isPalindrome = Opgaver.IsPalindrome(s);
                if (isPalindrome)
                {
                    Console.WriteLine($"{s} is a palindrome!");
                }
                else
                {
                    Console.WriteLine($"{s} is NOT a palindrome!");
                }
            }

            Console.WriteLine();

            int[] integerArray = { 1, 3, 4, 5, 6, 8, 9, 11 };
            Console.WriteLine(string.Join(", ", integerArray));
            Console.WriteLine("LinearSearch:");
            Console.WriteLine($"STEPS FOR 11: {Opgaver.StepsInLinearSearch(11, integerArray)}");
            Console.WriteLine($"STEPS FOR 5: {Opgaver.StepsInLinearSearch(5, integerArray)}");
            Console.WriteLine("BinarySearch:");
            Console.WriteLine($"STEPS FOR 3: {Opgaver.StepsInBinarySearch(integerArray, 0, integerArray.Length - 1, 3)}");
            Console.WriteLine($"STEPS FOR 5: {Opgaver.StepsInBinarySearch(integerArray, 0, integerArray.Length - 1, 5)}");

            Console.WriteLine();

            List <int> sortedList = new List <int> {
                1, 2, 3, 5, 6, 8, 9
            };

            Console.WriteLine(string.Join(", ", sortedList));
            Console.WriteLine($"4 PLACE AT POS: {Opgaver.InsertSortedList(sortedList, 4)}");
            Console.WriteLine($"7 PLACE AT POS: {Opgaver.InsertSortedList(sortedList, 7)}");


            Console.WriteLine();

            int num    = 7;
            int length = 5;

            Console.WriteLine($"NUM:{num}. LENGTH:{length}, MULTIPLES: {string.Join(", ", Opgaver.ArrayOfMultiples(num, length))}");


            Console.WriteLine();

            int power = 2;
            int min   = 50;
            int max   = 100;

            Console.WriteLine($"POWER:{power}, MIN:{min}, MAX:{max}");
            Console.WriteLine($"COUNT: {Opgaver.PowerRanger(power, min, max)}");

            Console.WriteLine();


            int n = 5;

            Console.WriteLine($"FACTORIAL OF {n} = {Opgaver.Factorial(n)}");


            Console.WriteLine();

            string txt = "Boat0099";

            Console.WriteLine(Opgaver.IncrementString(txt));

            Console.WriteLine();
            //// INVALID PASSWORDS
            //Assert.False(Opgaver.ValidatePassword("P1zz@")); //5 characters
            //Assert.False(Opgaver.ValidatePassword("P1zz@P1zz@P1zz@P1zz@P1zz@")); //25 characters
            //Assert.False(Opgaver.ValidatePassword("mypassword11")); //No uppercase
            //Assert.False(Opgaver.ValidatePassword("MYPASSWORD11")); //No lowercase
            //Assert.False(Opgaver.ValidatePassword("iLoveYou")); //No numbers
            //Assert.False(Opgaver.ValidatePassword("Pè7$areLove")); //è is not a speciel character
            //// VALID PASSWORDS
            //Assert.True(Opgaver.ValidatePassword("H4(k+x0z"));
            //Assert.True(Opgaver.ValidatePassword("Fhweg93@"));
            //Assert.True(Opgaver.ValidatePassword("aA0!@#$%^&*()+=_-{}[]:;\""));
            //Assert.True(Opgaver.ValidatePassword("zZ9'?<>,."));
            string[] passwords =
            {
                "P1zz@",
                "P1zz@P1zz@P1zz@P1zz@P1zz@",
                "mypassword11",
                "MYPASSWORD11",
                "iLoveYou",
                "Pè7$areLove",
                "H4(k+x0z",
                "Fhweg93@",
                "aA0!@#$%^&*()+=_-{}[]:;\"",
                "zZ9'?<>,."
            };
            //Check all the passwords
            foreach (var pass in passwords)
            {
                Console.WriteLine($"# {pass} # is {Opgaver.ValidatePassword(pass)}");
            }


            Console.ReadLine();
        }