public void AddSolutionAsyncShouldReturnSolutionCorrectly() { var options = new DbContextOptionsBuilder <IntillegioContext>() .UseInMemoryDatabase(databaseName: "Add_Solution_Db") .Options; var dbContext = new IntillegioContext(options); var solutionBindingModel = new AdminSolutionBindingModel { Name = "Development Manager", Image255X155 = "http://specthemes.com/redbiz/redbiz-5/img/content/services/service-2b.jpg", About = "Career Development Process- Development managers are responsible for developing the group.", }; var mapper = new Mock <IMapper>(); mapper.Setup(m => m.Map <Solution>(solutionBindingModel)) .Returns(new Solution { Name = "Development Manager", Image255X155 = "http://specthemes.com/redbiz/redbiz-5/img/content/services/service-2b.jpg", About = "Career Development Process- Development managers are responsible for developing the group.", }); var service = new SolutionsService(dbContext, mapper.Object); service.AddSolutionAsync(solutionBindingModel); Assert.True(dbContext.Solutions.Any(n => n.Name == solutionBindingModel.Name)); Assert.True(dbContext.Solutions.Any(a => a.Image255X155 == solutionBindingModel.Image255X155)); Assert.True(dbContext.Solutions.Any(b => b.About == solutionBindingModel.About)); }
public void GetAllSolutionsForAdminShouldGetSolutionsCorrectly() { var mockList = new List <AdminSolutionViewModel> { new AdminSolutionViewModel { Name = "Business Solutions", Image255X155 = "http://specthemes.com/redbiz/redbiz-5/img/content/services/service-1b.jpg", About = "A business solution comes in terms of marketing and advertising, payroll,accounting market research and investigation, among the other essential Business Technology .", }, new AdminSolutionViewModel { Name = "Development Manager", Image255X155 = "http://specthemes.com/redbiz/redbiz-5/img/content/services/service-2b.jpg", About = "Career Development Process- Development managers are responsible for developing the group.", } }; var options = new DbContextOptionsBuilder <IntillegioContext>() .UseInMemoryDatabase(databaseName: "Get_All_Solutions_for_Admin_Db") .Options; var dbContext = new IntillegioContext(options); var mapper = new Mock <IMapper>(); mapper.Setup(m => m.Map <IEnumerable <AdminSolutionViewModel> >( dbContext.Solutions)) .Returns(mockList); var solutionCount = 6; for (int i = 0; i < solutionCount; i++) { dbContext.Solutions.Add(new Solution()); } dbContext.SaveChanges(); var service = new SolutionsService(dbContext, mapper.Object); var allSolutions = service.GetAllSolutionsForAdmin(); Assert.NotNull(allSolutions); }
public void DeleteSolutionAsyncShouldDeleteSolutionCorrectly() { var options = new DbContextOptionsBuilder <IntillegioContext>() .UseInMemoryDatabase(databaseName: "Delete_Solution_Db") .Options; var dbContext = new IntillegioContext(options); var service = new SolutionsService(dbContext, null); var solution = new Solution(); dbContext.Solutions.Add(solution); dbContext.SaveChanges(); var solutionId = dbContext.Solutions.LastOrDefault().Id; service.DeleteSolutionAsync(solutionId); Assert.True(dbContext .Solutions .Any(a => a.Id == solutionId) == false); }
private void Run() { var dbConnFact = new DbConnectionFactory(_config); using (var conn = dbConnFact.Get()) { Console.WriteLine($"Importing data:"); Console.WriteLine($" from: {NHSD.GPITF.BuyingCatalog.Settings.GIF_CRM_URL(_config)}"); Console.WriteLine($" into: {conn.ConnectionString}"); Console.WriteLine(); Console.WriteLine($"Retrieving data from CRM:"); #region NHSD data Console.WriteLine($" Frameworks..."); var frameworksSvc = new FrameworksService(_repo); var frameworks = frameworksSvc .GetAll() .Select(x => Converter.FromCrm(x)) .ToList(); Console.WriteLine($" Capabilities..."); var capsSvc = new CapabilitiesService(_repo); var caps = capsSvc .GetAll() .Select(x => Converter.FromCrm(x)) .ToList(); Console.WriteLine($" Standards..."); var stdsSvc = new StandardsService(_repo); var stds = stdsSvc .GetAll() .Select(x => Converter.FromCrm(x)) .ToList(); Console.WriteLine($" TODO CapabilityFramework..."); Console.WriteLine($" TODO FrameworkStandard..."); Console.WriteLine($" CapabilityStandard..."); var capsStdsSvc = new CapabilitiesStandardService(_repo); var capsStds = capsStdsSvc .GetAll() .Select(x => Converter.FromCrm(x)) .ToList(); #endregion #region Supplier data Console.WriteLine($" Organisations..."); var orgsSvc = new OrganisationsService(_repo); var orgs = orgsSvc .GetAll() .Select(x => Converter.FromCrm(x)) .ToList(); Console.WriteLine($" Contacts..."); var contactsSvc = new ContactsService(_repo); var contacts = orgs .SelectMany(org => contactsSvc.ByOrganisation(org.Id)) .Select(x => Converter.FromCrm(x)) .ToList(); Console.WriteLine($" Solutions..."); var solnsSvc = new SolutionsService(_repo); var solns = orgs .SelectMany(org => solnsSvc.ByOrganisation(org.Id)) .Select(x => Converter.FromCrm(x)) .ToList(); Console.WriteLine($" TechnicalContact..."); var techContSvc = new TechnicalContactService(_repo); var techConts = solns .SelectMany(soln => techContSvc.BySolution(soln.Id)) .Select(x => Converter.FromCrm(x)) .ToList(); Console.WriteLine($" TODO FrameworkSolution..."); Console.WriteLine($" ClaimedCapability..."); var claimedCapsSvc = new CapabilitiesImplementedService(_repo); var claimedCaps = solns .SelectMany(soln => claimedCapsSvc.BySolution(soln.Id)) .Select(x => Converter.FromCrm(x)) .ToList(); Console.WriteLine($" ClaimedStandard..."); var claimedStdsSvc = new StandardsApplicableService(_repo); var claimedStds = solns .SelectMany(soln => claimedStdsSvc.BySolution(soln.Id)) .Select(x => Converter.FromCrm(x)) .ToList(); Console.WriteLine($" ClaimedCapabilityEvidence..."); var claimedCapsEvSvc = new CapabilitiesImplementedEvidenceService(_repo); var claimedCapsEv = claimedCaps .SelectMany(claim => claimedCapsEvSvc.ByClaim(claim.Id).SelectMany(x => x)) .Select(x => Converter.FromCrm(x)) .ToList(); Console.WriteLine($" ClaimedStandardEvidence..."); var claimedStdsEvSvc = new StandardsApplicableEvidenceService(_repo); var claimedStdsEv = claimedStds .SelectMany(claim => claimedStdsEvSvc.ByClaim(claim.Id).SelectMany(x => x)) .Select(x => Converter.FromCrm(x)) .ToList(); Console.WriteLine($" ClaimedCapabilityReview..."); var claimedCapsRevSvc = new CapabilitiesImplementedReviewsService(_repo); var claimedCapsRev = claimedCapsEv .SelectMany(ev => claimedCapsRevSvc.ByEvidence(ev.Id).SelectMany(x => x)) .Select(x => Converter.CapabilitiesImplementedReviewsFromCrm(x)) .ToList(); Console.WriteLine($" ClaimedStandardReview..."); var claimedStdsRevSvc = new StandardsApplicableReviewsService(_repo); var claimedStdsRev = claimedStdsEv .SelectMany(ev => claimedStdsRevSvc.ByEvidence(ev.Id).SelectMany(x => x)) .Select(x => Converter.StandardsApplicableReviewsFromCrm(x)) .ToList(); #endregion Console.WriteLine(); Console.WriteLine($"Importing data into datastore..."); using (var trans = conn.BeginTransaction()) { // NHSD data conn.Insert(frameworks, trans); conn.Insert(caps, trans); conn.Insert(stds, trans); conn.Insert(capsStds, trans); // Supplier data conn.Insert(orgs, trans); conn.Insert(contacts, trans); conn.Insert(solns, trans); conn.Insert(techConts, trans); conn.Insert(claimedCaps, trans); conn.Insert(claimedStds, trans); conn.Insert(GetInsertionTree(claimedCapsEv), trans); conn.Insert(GetInsertionTree(claimedStdsEv), trans); conn.Insert(GetInsertionTree(claimedCapsRev), trans); conn.Insert(GetInsertionTree(claimedStdsRev), trans); trans.Commit(); } Console.WriteLine("Finished!"); } }