Esempio n. 1
0
        private static void LoadFile(string fileName)
        {
            using (StreamReader sr = new StreamReader(fileName))
            {
                var csv = new CsvReader(sr);
                while (csv.Read())
                {
                    //Import Customer(Account and Parent)
                    int accountId = ImportCustomer(csv);

                    //ClassInfo
                    ClassInfo classInfo = new ClassInfo();
                    classInfo.FromCsv(csv);

                    using (PrivateClassesDBContext dbContext = new PrivateClassesDBContext())
                    {
                        ClassInfoRepo repo = new ClassInfoRepo(dbContext);

                        repo.Add(classInfo);

                        try
                        {
                            //Save to DB
                            dbContext.SaveChanges();
                        }
                        catch (DbEntityValidationException)
                        {
                            throw;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public void ClassInfoIntegationTests_AddClass()
        {
            using (PrivateClassesDBContext dbContext = new PrivateClassesDBContext())
            {
                ClassInfoRepo repo = new ClassInfoRepo(dbContext);
                repo.Add(new ClassInfo {
                    ClassCategoryId = 1, ClassName = "TestClass", Location = "Trails", ProductCode = "C12345", DateStart = DateTime.Now, DateEnd = DateTime.Now
                });
                try
                {
                    dbContext.SaveChanges();
                }
                catch (DbEntityValidationException exc)
                {
                    Assert.Fail(exc.EntityValidationErrors.ToString());
                }
                catch (Exception exc)
                {
                    Assert.Fail(exc.ToString());
                }

                var res = repo.FindOne(c => c.ClassName == "TestClass");
                Assert.IsNotNull(res);
            }
        }
Esempio n. 3
0
        private ClassCategory GetClassCategory(string className)
        {
            //Get value from lookup
            string lookupValue = String.Empty;

            foreach (string s in CategoryKeywordsLookup)
            {
                if (className.ToLower().Contains(s))
                {
                    lookupValue = s;
                }
            }

            if (String.IsNullOrEmpty(lookupValue))
            {
                lookupValue = "default";
            }

            using (PrivateClassesDBContext dbContext = new PrivateClassesDBContext())
            {
                ClassInfoRepo repo = new ClassInfoRepo(dbContext);
                var           res  = repo.GetClassCategoryByKeyword(lookupValue);
                return(res);
            }
        }
Esempio n. 4
0
 public void ClassInfoIntegationTests_FindUnPaidClasses()
 {
     using (PrivateClassesDBContext dbContext = new PrivateClassesDBContext())
     {
         ClassInfoRepo    repo = new ClassInfoRepo(dbContext);
         List <ClassInfo> res  = repo.FindMany(c => c.Orders.Where(o => !o.PaymentId.HasValue).Count() > 0).ToList();
         Assert.IsTrue(res != null && res.Count > 0);
     }
 }
Esempio n. 5
0
        public void ParticipantTests_FindFullyPaidClasses_Mock()
        {
            ClassInfoRepo repo = new ClassInfoRepo(GetMockContext().Object)
            {
                IncludeNavigationProperties = false
            };
            List <ClassInfo> res = repo.FindMany(c => c.Orders.Where(o => o.PaymentId.HasValue).Count() > 0).ToList();

            Assert.IsTrue(res != null && res.Count > 0);
        }
Esempio n. 6
0
        public void ClassInfoIntegationTests_GetClassById()
        {
            using (PrivateClassesDBContext dbContext = new PrivateClassesDBContext())
            {
                ClassInfoRepo repo = new ClassInfoRepo(dbContext);

                var res = repo.GetClassById(3);
                Assert.IsTrue(res != null && res.ClassCategory != null);
            }
        }
Esempio n. 7
0
        public void ClassInfoIntegationTests_GetAll()
        {
            using (PrivateClassesDBContext dbContext = new PrivateClassesDBContext())
            {
                ClassInfoRepo repo = new ClassInfoRepo(dbContext);

                List <ClassInfo> res = repo.GetAll().ToList();
                Assert.IsTrue(res != null && res.Count > 0);
            }
        }
Esempio n. 8
0
        public void ClassInfoIntegationTests_GetClassCategoryByKeyword()
        {
            using (PrivateClassesDBContext dbContext = new PrivateClassesDBContext())
            {
                ClassInfoRepo repo = new ClassInfoRepo(dbContext);

                var res = repo.GetClassCategoryByKeyword("Party");
                Assert.IsTrue(res != null);
            }
        }
Esempio n. 9
0
        public void ParticipantTests_GetClassById_Mock()
        {
            ClassInfoRepo repo = new ClassInfoRepo(GetMockContext().Object)
            {
                IncludeNavigationProperties = false
            };

            var res = repo.GetClassById(2);

            Assert.IsTrue(res != null);
        }
Esempio n. 10
0
        public void ParticipantTests_FindOne_Mock()
        {
            ClassInfoRepo repo = new ClassInfoRepo(GetMockContext().Object)
            {
                IncludeNavigationProperties = false
            };

            var res = repo.FindOne(x => x.ClassName.ToLower().Contains("birthday") && x.ClassCategory.CategoryName.ToLower() == "party");

            Assert.IsTrue(res != null);
        }
Esempio n. 11
0
        public void ParticipantTests_GetAll_Mock()
        {
            ClassInfoRepo repo = new ClassInfoRepo(GetMockContext().Object)
            {
                IncludeNavigationProperties = false
            };

            var res = repo.GetAll().ToList();

            Assert.IsTrue(res != null && res.Count == 2);
        }
Esempio n. 12
0
        public void ClassInfoRepoTests_GetAllClassCategories_Mock()
        {
            ClassInfoRepo repo = new ClassInfoRepo(GetMockContext().Object)
            {
                IncludeNavigationProperties = false
            };

            var res = repo.GetAllClassCategories();

            Assert.IsTrue(res != null && res.Count == 2);
        }