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; } } } } }
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); } }
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); } }
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); } }
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); }
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); } }
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); } }
public void ClassInfoIntegationTests_GetClassCategoryByKeyword() { using (PrivateClassesDBContext dbContext = new PrivateClassesDBContext()) { ClassInfoRepo repo = new ClassInfoRepo(dbContext); var res = repo.GetClassCategoryByKeyword("Party"); Assert.IsTrue(res != null); } }
public void ParticipantTests_GetClassById_Mock() { ClassInfoRepo repo = new ClassInfoRepo(GetMockContext().Object) { IncludeNavigationProperties = false }; var res = repo.GetClassById(2); Assert.IsTrue(res != null); }
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); }
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); }
public void ClassInfoRepoTests_GetAllClassCategories_Mock() { ClassInfoRepo repo = new ClassInfoRepo(GetMockContext().Object) { IncludeNavigationProperties = false }; var res = repo.GetAllClassCategories(); Assert.IsTrue(res != null && res.Count == 2); }