public void EnsureGetPersonByColorWorksProperly()
        {
            FavouriteColorCSVFileRepository favCSVFileRepo = new FavouriteColorCSVFileRepository();
            var person = favCSVFileRepo.GetPeopleByColor("blau");

            Assert.IsTrue(person.Count() >= 2);
        }
Exemple #2
0
        public void EnsureFillingUpDB()
        {
            try
            {
                var csvFile = new FavouriteColorCSVFileRepository();
                var test    = csvFile.GetPeople();

                PersonsContext pc = new PersonsContext();

                //Dumb cleaning
                pc.Database.ExecuteSqlCommand("delete  from  [Person];");
                pc.Database.ExecuteSqlCommand("delete  from  [Color];");



                pc.Colors.AddRange(UtilColor.Colors);
                pc.Persons.AddRange(test);
                pc.SaveChanges();
                Assert.IsTrue(true);
            }
            catch (Exception)
            {
                Assert.IsTrue(false);
            }
        }
        public void EnsureGetPersonWorksProperly()
        {
            FavouriteColorCSVFileRepository favCSVFileRepo = new FavouriteColorCSVFileRepository();
            var person = favCSVFileRepo.GetPerson(2);

            Assert.IsTrue(person.Id == 2);
        }
        public void EnsureGetPeopleReturnsAllRecordsProperly()
        {
            FavouriteColorCSVFileRepository favCSVFileRepo = new FavouriteColorCSVFileRepository();
            var peopleTest = favCSVFileRepo.GetPeople();

            Assert.IsTrue(peopleTest.Count() >= 10);
        }
 public void EnsureGetPersonByColorDealsWithUknownStringsProperly()
 {
     try
     {
         FavouriteColorCSVFileRepository favCSVFileRepo = new FavouriteColorCSVFileRepository();
         var person = favCSVFileRepo.GetPeopleByColor("blauklasjdlkasjdlsakdjsalkdj");
         Assert.IsTrue(false);
     }
     catch (ColorNotExistException)
     {
         Assert.IsTrue(true);
     }
 }
        public void EnsureSavePeopleWorksProperly()
        {
            FavouriteColorCSVFileRepository favCSVFileRepo = new FavouriteColorCSVFileRepository();
            var ps = new List <Person>()
            {
                new Person()
                {
                    Id = 10, Name = "John", Lastname = "Doe", City = "Sky", Zipcode = "12345", FavColourId = 1
                }
            };
            var ok = favCSVFileRepo.SavePeople(ps);

            Assert.IsTrue(ok);
        }
        public void EnsureGetPersonDealsWithUnknownIdProperly()
        {
            FavouriteColorCSVFileRepository favCSVFileRepo = new FavouriteColorCSVFileRepository();

            try
            {
                var person = favCSVFileRepo.GetPerson(322);
                Assert.IsTrue(false);
            }
            catch (PersonNotExistException)
            {
                Assert.IsTrue(true);
            }
        }
 public void EnsureSavePeopleDealsWithEmptyPeopleInputProperly()
 {
     try
     {
         FavouriteColorCSVFileRepository favCSVFileRepo = new FavouriteColorCSVFileRepository();
         var ps = new List <Person>();
         var ok = favCSVFileRepo.SavePeople(ps);
         Assert.IsTrue(false);
     }
     catch (NoPeopleForUpdateException)
     {
         Assert.IsTrue(true);
     }
 }
 public void EnsureSavePeopleDealsWithNullColorProperly()
 {
     try
     {
         FavouriteColorCSVFileRepository favCSVFileRepo = new FavouriteColorCSVFileRepository();
         var ps = new List <Person>()
         {
             new Person()
             {
                 Id = 10, Name = "John", Lastname = "Doe", City = "Sky", Zipcode = "12345"
             }
         };
         var ok = favCSVFileRepo.SavePeople(ps);
         Assert.IsTrue(false);
     }
     catch (ColorIsNullException)
     {
         Assert.IsTrue(true);
     }
 }