public JsonResult Delete(EducationModel model) { try { #region " [ Declaration ] " EducationService _service = new EducationService(); #endregion #region " [ Main process ] " model.CreateBy = UserID; model.DeleteBy = UserID; model.DeleteDate = DateTime.Now; #endregion //Call to service return(this.Json(_service.Delete(model), JsonRequestBehavior.AllowGet)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, "Delete", UserID, ex); } }
public void GetEducation_Pass() { using (ApplicationDbContext context = new ApplicationDbContext(Options)) { EducationService educationService = new EducationService(context); UserService userService = new UserService(context); User user = new User { FirstName = "Kyle", LastName = "Burgi" }; userService.AddUser(user); Education edu = new Education { CollegeName = "Eastern Washington University", FieldOfStudy = "Computer Science", UserId = user.Id }; educationService.AddEducation(edu); } using (ApplicationDbContext context = new ApplicationDbContext(Options)) { EducationService educationService = new EducationService(context); Education fetchedEducation = educationService.GetEducation(1); Assert.AreEqual("Eastern Washington University", fetchedEducation.CollegeName); Assert.AreEqual(1, fetchedEducation.UserId); } }
public void SetUpMethod() { this._repositoryMock = new Mock <SnilDBContext>(); this._mapperMock = new Mock <IMapper>(); this._loggerMock = new Mock <NLogAdapter <CookieManagerTests> >(); this._educationService = new EducationService(this._loggerMock.Object, this._repositoryMock.Object, this._mapperMock.Object); }
public HttpResponseMessage DeleteEducation(EducationModel model) { IUnitOfWork uWork = new UnitOfWork(); IEducationRepository education = new EducationRepository(uWork); IEducationService educationService = new EducationService(education); try { if (this.ModelState.IsValid) { var result = educationService.DeleteEducation(model); if (result != null) { return(Request.CreateResponse(HttpStatusCode.OK, result)); } else { string message = "Not deleted successfully"; return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public HttpResponseMessage GetEducationModels(EducationModel model) { IUnitOfWork uWork = new UnitOfWork(); IEducationRepository education = new EducationRepository(uWork); IEducationService educationService = new EducationService(education); try { if (this.ModelState.IsValid) { var educationList = educationService.GetAllEducationList(model); if (educationList != null) { return(Request.CreateResponse(HttpStatusCode.OK, educationList)); } else { string message = "Error in getting Data"; return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message)); } }
public void EditEducationShoudEditOneOrMorePropertiesInEducation() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_Tests").Options; var dbContext = new ApplicationDbContext(options); var service = new EducationService(dbContext); var model = new UpdateDeleteEducationViewModel { Title = "Edited" }; var education = new Education { Title = "New" }; dbContext.Educations.Add(education); dbContext.SaveChanges(); var educationToEdit = dbContext.Educations.First(); service.EditEducation(educationToEdit, model); Assert.Equal("Edited", educationToEdit.Title); }
public ActionResult Edit(string id) { try { #region " [ Declaration ] " EducationTypeService _typeService = new EducationTypeService(); EducationService _service = new EducationService(); ViewBag.id = id; ViewBag.type = _typeService.GetAll(UserID); #endregion // Call to service EducationModel model = _service.GetItemByID(new EducationModel() { ID = new Guid(id), CreateBy = UserID, Insert = false }); return(View(model)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, "Edit", UserID, ex); } }
public void UpdateEducationByIdProfile_InvalidEducationObject_ShouldBeThrownValidationException() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); EducationService service = new EducationService(uow.Object); service.Update(It.IsAny <int>(), null); }
public void InsertEducationByIdProfile_InvalidEducationObject_ShouldBeThrownValidationException() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); EducationService service = new EducationService(uow.Object); service.Insert(null); }
public void GetEducationByIdProfile_InvalidProfileId_ShouldBeThrownValidationException() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); EducationService service = new EducationService(uow.Object); uow.Setup(a => a.ProgrammerProfiles.Get(It.IsAny <string>())).Returns((ProgrammerProfile)null); service.GetEducationByProfileId(It.IsAny <string>()); }
public void DeleteEducation_InvalidEducationId_ShouldBeThrownValidationException() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); EducationService service = new EducationService(uow.Object); uow.Setup(a => a.Educations.Get(It.IsAny <int>())).Returns((Education)null); service.Delete(It.IsAny <int>()); }
public void DeleteEducation_DeletedEducationWithCorrectId_ShouldBeDeleted() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); EducationService service = new EducationService(uow.Object); uow.Setup(a => a.Educations.Get(It.IsAny <int>())).Returns(new Education()); service.Delete(It.IsAny <int>()); uow.Verify(x => x.Save()); }
public void UpdateEducation_EducationExist_ShouldBeEditingSaved() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); EducationService service = new EducationService(uow.Object); uow.Setup(a => a.Educations.Get(It.IsAny <int>())).Returns(new Education()); service.Update(It.IsAny <int>(), new EducationDTO()); uow.Verify(x => x.Save()); }
public void InsertEducationByIdProfile_InvalidEducationId_ShouldBeThrownValidationException() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); EducationService service = new EducationService(uow.Object); uow.Setup(a => a.Educations.Get(It.IsAny <int>())).Returns(new Education()); service.Insert(new EducationDTO { Id = 1 }); }
public void UpdateEducationByIdProfile_EducationIdNotMatch_ShouldBeThrownValidationException() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); EducationService service = new EducationService(uow.Object); service.Update(1, new EducationDTO() { Id = 2, ProgrammerId = "1", CloseDate = new DateTime(2010, 11, 10), EntryDate = new DateTime(2009, 10, 10), Level = "high", NameInstitution = "KPI" }); }
public async Task GetEducations() { // Arrange var svc = new EducationService(); // Act var result = await svc.GetEducations(); // Assert Assert.Equal(2, result.Count); }
public void UpdateEducationByIdProfile_InvalidEducationId_ShouldBeThrownValidationException() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); EducationService service = new EducationService(uow.Object); uow.Setup(a => a.Educations.Get(It.IsAny <int>())).Returns((Education)null); service.Update(2, new EducationDTO() { Id = 2, ProgrammerId = "1", CloseDate = new DateTime(2010, 11, 10), EntryDate = new DateTime(2009, 10, 10), Level = "high", NameInstitution = "KPI" }); }
public static IEducationService<Education> GetJobSeekerEducation() { IEducationService<SkillSmart.Dto.Education> serviceObj = null; switch (sectionHandler.ConnectionStringName) { case DataBaseType.SKILLSMART_MONGO_DB: serviceObj = new EducationService(DatabaseFactory.CreateMongoDatabase()); break; default: serviceObj = new EducationService(DatabaseFactory.CreateMongoDatabase()); break; } return serviceObj; }
public void InsertEducation_NewEducationAddingToDatabase_ShouldBeAddedNewEducation() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); EducationService service = new EducationService(uow.Object); uow.Setup(a => a.Educations.Get(It.IsAny <int>())).Returns((Education)null); service.Insert(new EducationDTO() { Id = 1, ProgrammerId = "1", CloseDate = new DateTime(2010, 11, 10), EntryDate = new DateTime(2009, 10, 10), Level = "high", NameInstitution = "KPI" }); uow.Verify(x => x.Save()); }
public void UpdateEducation_Pass() { using (ApplicationDbContext context = new ApplicationDbContext(Options)) { EducationService educationService = new EducationService(context); UserService userService = new UserService(context); User user = new User { FirstName = "Kyle", LastName = "Burgi" }; userService.AddUser(user); Education edu = new Education { CollegeName = "Eastern Washington University", FieldOfStudy = "Computer Science", UserId = user.Id }; educationService.AddEducation(edu); } using (ApplicationDbContext context = new ApplicationDbContext(Options)) { EducationService educationService = new EducationService(context); UserService userService = new UserService(context); List <User> users = userService.GetBatchUsers(); List <Education> userEdcuation = educationService.GetEducationForUser(users[0].Id); Assert.IsTrue(userEdcuation.Count > 0); userEdcuation[0].CollegeName = "Gonzaga University"; educationService.UpdateEducation(userEdcuation[0]); } using (ApplicationDbContext context = new ApplicationDbContext(Options)) { EducationService educationService = new EducationService(context); UserService userService = new UserService(context); List <User> users = userService.GetBatchUsers(); List <Education> userEdcuation = educationService.GetEducationForUser(users[0].Id); Assert.AreEqual("Gonzaga University", userEdcuation[0].CollegeName); Assert.AreEqual("Computer Science", users[0].EducationHistory[0].FieldOfStudy); } }
public async Task GetAllGroupBySpecialityTest() { _repoWrapper.Setup(r => r.Education.GetAllAsync(null, null)).ReturnsAsync(new List <Education>().AsQueryable()); var service = new EducationService(_repoWrapper.Object, _mapper.Object); _mapper.Setup(x => x.Map <Education, EducationDTO>(It.IsAny <Education>())).Returns(new EducationDTO()); // Act var result = await service.GetAllGroupBySpecialityAsync(); // Assert Assert.NotNull(result); Assert.IsAssignableFrom <IEnumerable <EducationDTO> >(result); }
public async Task GetByIdTest() { _repoWrapper.Setup(r => r.Education.GetFirstOrDefaultAsync(It.IsAny <Expression <Func <Education, bool> > >(), null)).ReturnsAsync(new Education()); var service = new EducationService(_repoWrapper.Object, _mapper.Object); _mapper.Setup(x => x.Map <Education, EducationDTO>(It.IsAny <Education>())).Returns(new EducationDTO()); // Act var result = await service.GetByIdAsync(1); // Assert Assert.NotNull(result); Assert.IsType <EducationDTO>(result); }
public static IEducationService <Education> GetJobSeekerEducation() { IEducationService <SkillSmart.Dto.Education> serviceObj = null; switch (sectionHandler.ConnectionStringName) { case DataBaseType.SKILLSMART_MONGO_DB: serviceObj = new EducationService(DatabaseFactory.CreateMongoDatabase()); break; default: serviceObj = new EducationService(DatabaseFactory.CreateMongoDatabase()); break; } return(serviceObj); }
public FormInputResultInterview() { InitializeComponent(); _scoreService = new ScoreService(); _resultService = new ResultsService(); _positionService = new PositionService(); _departmentService = new DepartmentService(); _educationService = new EducationService(); LoadDataGridLookUpEdit(); LoadDataGridLookUpEditPositions(); LoadDataGridLookUpEditDepartments(); LoadDataGridLookUpEditEducations(); }
public void IncrementViewsShouldIncreaseCounterOnViews() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_Tests").Options; var dbContext = new ApplicationDbContext(options); var service = new EducationService(dbContext); dbContext.Educations.Add(new Education()); dbContext.SaveChanges(); var education = dbContext.Educations.First(); service.IncrementViews(education); service.IncrementViews(education); Assert.Equal(2, education.Views); }
public void GetEducationsShouldReturnAllEducations() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_Videos").Options; var dbContext = new ApplicationDbContext(options); var service = new EducationService(dbContext); dbContext.Educations.Add(new Education()); dbContext.Educations.Add(new Education()); dbContext.Educations.Add(new Education()); dbContext.Educations.Add(new Education()); dbContext.Educations.Add(new Education()); dbContext.SaveChanges(); var educations = service.GetEducations(); Assert.Equal(5, educations.Length); }
public void DeleteEducationShouldDeleteAnEducationFromDatabase() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_Tests").Options; var dbContext = new ApplicationDbContext(options); var service = new EducationService(dbContext); dbContext.Educations.Add(new Education()); dbContext.Educations.Add(new Education()); dbContext.Educations.Add(new Education()); dbContext.SaveChanges(); var education = dbContext.Educations.First(); service.DeleteEducation(education); Assert.Equal(2, dbContext.Educations.Count()); }
public void GetEducationShouldReturnAnEducationById() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_CreatingEducations").Options; var dbContext = new ApplicationDbContext(options); var service = new EducationService(dbContext); var education = new Education { Title = "Test" }; dbContext.Educations.Add(education); dbContext.SaveChanges(); var returnedEducation = service.GetEducation(1); Assert.Equal(education.Title, returnedEducation.Title); }
public void GetEducationByIdProfile_GetEducationWithCorrectProfileId_ShouldBeRecieved() { Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); IUnitOfWork uow = mock.Object; EducationService service = new EducationService(uow); IEnumerable <Education> educations = new List <Education> { new Education() { Id = 1, ProgrammerId = "1" }, new Education() { Id = 2, ProgrammerId = "1" }, new Education() { Id = 3, ProgrammerId = "1" } }; var expected = new List <EducationDTO> { new EducationDTO() { Id = 1, ProgrammerId = "1" }, new EducationDTO() { Id = 2, ProgrammerId = "1" }, new EducationDTO() { Id = 3, ProgrammerId = "1" } }; mock.Setup(a => a.ProgrammerProfiles.Get(It.IsAny <string>())).Returns(new ProgrammerProfile()); mock.Setup(a => a.Educations.GetAll()).Returns(educations); var actual = service.GetEducationByProfileId("1"); CollectionAssert.AreEquivalent(actual.Select(x => x.Id).ToList(), expected.Select(x => x.Id).ToList()); CollectionAssert.AreEquivalent(actual.Select(x => x.ProgrammerId).ToList(), expected.Select(x => x.ProgrammerId).ToList()); }
public void CreateEducationShouldCreateEducation() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_CreatingEducations").Options; var dbContext = new ApplicationDbContext(options); var service = new EducationService(dbContext); var model = new EducationViewModel { Title = "Title", AdditionalContent = "Something", AdditionalContentImage = "Something", Content = "Something", DownloadLink = "Something", ImageUrl = "Something", }; var education = service.CreateEducation(model); Assert.Equal(1, education); }
public JsonResult Index(CustomDataTableRequestHelper requestData) { try { #region " [ Declaration ] " EducationService _service = new EducationService(); #endregion #region " [ Main processing ] " if (requestData.Parameter1 == null) { requestData.Parameter1 = ""; } #endregion //Call to service Dictionary <string, object> _return = _service.List(requestData, UserID); if ((ResponseStatusCodeHelper)_return[DatatableCommonSetting.Response.STATUS] == ResponseStatusCodeHelper.OK) { DataTableResponse <EducationModel> itemResponse = _return[DatatableCommonSetting.Response.DATA] as DataTableResponse <EducationModel>; return(this.Json(itemResponse, JsonRequestBehavior.AllowGet)); } // return(this.Json(new DataTableResponse <EducationModel>(), JsonRequestBehavior.AllowGet)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, "Index", UserID, ex); } }