public JobOfferServiceUnitTest() { _mongoDataBaseMock = new Mock <IMongoDatabase>(MockBehavior.Loose); _jobOfferRepositoryMock = new Mock <JobOfferRepository>(MockBehavior.Strict, _mongoDataBaseMock.Object); _personRepositoryMock = new Mock <PersonRepository>(MockBehavior.Strict, _mongoDataBaseMock.Object); _service = new JobOfferService(_jobOfferRepositoryMock.Object, _personRepositoryMock.Object); }
public HomeJobSeeker() { InitializeComponent(); List <JobOffer> offerList = JobOfferService.GetAllOffers(); //render promoted offers foreach (var item in offerList) { if (item.Promoted) { parentPanel.Controls.Add(new offerComponent(item)); } } //render not prometed offers foreach (var item in offerList) { if (!item.Promoted) { parentPanel.Controls.Add(new offerComponent(item)); } } parentPanel.Refresh(); }
private void btnSearch_Click(object sender, EventArgs e) { foreach (var item in JobOfferService.GetOffersByBusinessJobOfferDate (txtCompanyName.Text.ToLower(), txtJobName.Text.ToLower(), txtDateTime.ToString())) { flowLayoutPanel1.Controls.Add(new offerComponent(item)); } }
public Statistic() { InitializeComponent(); lblBusinessNum.Text = BusinessService.GetBusinessNum().ToString(); lbJobSeekerNum.Text = JobSeekerService.GetJobSeekerNum().ToString(); lblOfferNum.Text = JobOfferService.GetOfferNum().ToString(); }
public AllOffers() { InitializeComponent(); foreach (var item in JobOfferService.GetAllOffers()) { flowLayoutPanel1.Controls.Add(new offerComponent(item, this)); } flowLayoutPanel1.Refresh(); }
public OffersAll() { InitializeComponent(); foreach (var item in JobOfferService.GetOffersByBusinessName(LoggedData.LoggedBusiness.Name)) { flowLayoutPanel1.Controls.Add(new offerComponent(item)); } flowLayoutPanel1.Refresh(); }
public void ReturnFalse_WhenNullArgumentIsPassed() { //Arrange var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedMapper = new Mock <IMapper>(); var jobOfferService = new JobOfferService(mockedUnitOfWork.Object, mockedMapper.Object); //Act & Assert Assert.IsFalse(jobOfferService.Delete(null)); }
private void Share_Click(object sender, EventArgs e) { //qitu u met me ndreq business mos me lan null Address a1 = new Address(cmbCity.SelectedItem.ToString(), txtStreet.Text, 10000); JobOfferService.AddOffer(new JobOffer(txtTitleOffer.Text, txtOfferDescription.Text, new Business(LoggedData.LoggedBusiness.BusinessType, LoggedData.LoggedBusiness.BusinessCategory, LoggedData.LoggedBusiness.Name, "password", "password"), a1, new Category(cmbCategory.SelectedItem.ToString()))); MessageBox.Show("You Shared an Offer succesfuly"); }
public void JobOfferFacadeTest() { var unit = new UnitOfWork(GetInMemoryOptions()); Seeder.Seed(unit); var jobOfferService = new JobOfferService(unit, new JobOfferQueryObject(unit)); var jobOfferFacade = new JobOfferFacade(unit, jobOfferService, mapper); var o = new JobOfferDto() { Name = "Lol" }; jobOfferFacade.CreateAsync(o).Wait(); var s = unit.JobOfferQuery.FilterByName("Lol").ExecuteAsync().Result.First(); Assert.NotNull(s.Id); Assert.NotNull(jobOfferService.GetByIdAsync(s.Id ?? -1).Result); s.Id = null; s.Name = "new lol"; // Null ID get IMPOSSIBLE due to GetById accepting only int // Null ID edit/update var excp2 = Assert.Throws <AggregateException>(() => jobOfferFacade.UpdateAsync(mapper.Map <JobOfferDto>(s)).Wait()); Assert.Contains("The property 'Id' on entity type 'JobOffer' is part of a key " + "and so cannot be modified or marked as modified.", excp2.Message); // Null ID delete excp2 = Assert.Throws <AggregateException>(() => jobOfferFacade.DeleteAsync(mapper.Map <JobOfferDto>(s)).Wait()); Assert.Contains("JobOfferDto.Id can't be null!", excp2.Message); // Addition with conflicting ID // This invalidates the database var id1 = unit.JobOfferRepository.GetById(1); Assert.NotNull(id1); // makes sure company with id 1 is already in database var excp = Assert.Throws <AggregateException>(() => jobOfferFacade.CreateAsync(new JobOfferDto() { Id = 1 }).Wait()); Assert.Contains("The instance of entity type 'JobOffer' cannot be tracked " + "because another instance with the same key value for {'Id'} is already being tracked.", excp.Message); unit.Dispose(); }
public BusinessProfile(Business b1, int offers) { InitializeComponent(); lblBusinessName.Text = b1.Name; lblBusinessCategory.Text = b1.BusinessCategory.Name; lblOffersShared.Text = offers.ToString(); lblBusinessType.Text = b1.BusinessType.Type; lblTechOffers.Text = JobOfferService.GetJobBsyCategoryAndBusinessName("Technology", b1.Name).ToString(); MessageBox.Show(LoggedData.LoggedJobSeeker.City + " " + b1.Name); lblCityOffersNum.Text = JobOfferService.GetOffersByCityAndBusinessName(b1.Name, LoggedData.LoggedJobSeeker.City).Count.ToString(); }
public void CallInheritedFromGenericRepositoryGetByCompanyIdMethodIsCalled_WhenInvokedWithValidArgs() { //Arrange var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedMapper = new Mock <IMapper>(); var jobOfferService = new JobOfferService(mockedUnitOfWork.Object, mockedMapper.Object); var mockedJobOfferRepository = new Mock <IJobOfferRepository>(); //Act mockedUnitOfWork.Setup(x => x.JobOfferRepository).Returns(mockedJobOfferRepository.Object); jobOfferService.GetByCompanyId(1); mockedJobOfferRepository.Verify(x => x.GetByCompanyId(It.IsAny <int>()), Times.Once); }
private void lblBusinessName_Click(object sender, EventArgs e) { //profile viwer added ViewerService.AddProfileViewer(new Entities.ProfileViewer(offerGlobal.Business, LoggedData.LoggedJobSeeker)); var business = BusinessService.SearchByBusinessName(offerGlobal.Business.Name); int offersNum = JobOfferService.GetOffersByBusinessName(offerGlobal.Business.Name).Count; // MessageBox.Show(business.Name); BusinessProfile b1 = new BusinessProfile(business, offersNum); b1.Show(); }
public void ReturnFalse_WhenExceptionOccuresByMethodExecution() { //Arrange var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedMapper = new Mock <IMapper>(); var jobOfferService = new JobOfferService(mockedUnitOfWork.Object, mockedMapper.Object); //Act mockedUnitOfWork.Setup(x => x.JobOfferRepository).Throws(new Exception()); //Assert Assert.IsFalse(jobOfferService.DeleteById(1)); }
public void ReturnFalse_WhenExceptionOccured() { //Arrange var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedMapper = new Mock <IMapper>(); var jobOfferService = new JobOfferService(mockedUnitOfWork.Object, mockedMapper.Object); var mockedJobOfferModel = new Mock <JobOfferModel>(); //Act mockedUnitOfWork.Setup(x => x.JobOfferRepository).Throws(new Exception()); //Assert Assert.IsFalse(jobOfferService.Update(mockedJobOfferModel.Object)); }
public YourJobOffers() { InitializeComponent(); // //var offer = new JobOffer("title", "Helo world",new Business("Interex",null,new Category("Category"),null) // , new Address("Prishtina", "hello", 1000),new Category("Category name")); // MessageBox.Show(LoggedData.LoggedBusiness.Name); foreach (var item in JobOfferService.GetOffersByBusinessName(LoggedData.LoggedBusiness.Name)) { flowLayoutPanel1.Controls.Add(new OfferComponent(item)); } flowLayoutPanel1.Refresh(); }
public void ReturnExpectedValue_WhenInvoked() { //Arrange var mockedJobOfferModel = new Mock <JobOfferModel>(); var mockedJobOfferRepository = new Mock <IJobOfferRepository>(); var mockedJobOffer = new Mock <JobOffer>(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedMapper = new Mock <IMapper>(); var jobOfferService = new JobOfferService(mockedUnitOfWork.Object, mockedMapper.Object); //Act & Assert mockedUnitOfWork.Setup(x => x.JobOfferRepository).Returns(mockedJobOfferRepository.Object); mockedJobOfferRepository.Setup(x => x.GetById(It.IsAny <int>())).Returns(mockedJobOffer.Object); mockedMapper.Setup(x => x.Map <JobOfferModel>(mockedJobOffer.Object)).Returns(mockedJobOfferModel.Object); Assert.AreEqual(mockedJobOfferModel.Object, jobOfferService.GetById(1)); }
private void btnPromote_Click(object sender, EventArgs e) { if (JobOfferService.GetOfferById(Convert.ToInt32(lblId.Text)).Promoted) { btnPromote.BackColor = Color.White; btnPromote.ForeColor = Color.Black; JobOfferService.GetOfferById(Convert.ToInt32(lblId.Text)).Promoted = false; } else { JobOfferService.GetOfferById(Convert.ToInt32(lblId.Text)).Promoted = true; btnPromote.BackColor = Color.DarkSlateGray; btnPromote.ForeColor = Color.White; MessageBox.Show("Promoted"); } }
public void MakeAllChainCalls_WhenInvoked() { //Arrange var mockedJobOfferModel = new Mock <JobOfferModel>(); var mockedJobOfferRepository = new Mock <IJobOfferRepository>(); var mockedJobOffer = new Mock <JobOffer>(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedMapper = new Mock <IMapper>(); var jobOfferService = new JobOfferService(mockedUnitOfWork.Object, mockedMapper.Object); //Act & Assert mockedUnitOfWork.Setup(x => x.JobOfferRepository).Returns(mockedJobOfferRepository.Object); mockedJobOfferRepository.Setup(x => x.GetById(It.IsAny <int>())).Returns(mockedJobOffer.Object); mockedMapper.Setup(x => x.Map <JobOfferModel>(mockedJobOffer.Object)).Returns(mockedJobOfferModel.Object); jobOfferService.GetById(1); mockedMapper.Verify(x => x.Map <JobOfferModel>(mockedJobOffer.Object), Times.Once); }
public void CallMapperMapMethod_WhenInvokedWithValidArgs() { //Arrange var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedMapper = new Mock <IMapper>(); var jobOfferService = new JobOfferService(mockedUnitOfWork.Object, mockedMapper.Object); var mockedJobOfferRepository = new Mock <IJobOfferRepository>(); var mockedJobOffer = new Mock <JobOffer>(); var mockedJobOfferModel = new Mock <JobOfferModel>(); //Act mockedMapper.Setup(x => x.Map <JobOffer>(mockedJobOfferModel.Object)).Returns(mockedJobOffer.Object); jobOfferService.Delete(mockedJobOfferModel.Object); //Assert mockedMapper.Verify(x => x.Map <JobOffer>(mockedJobOfferModel.Object), Times.Once); }
public OfferComponent(JobOffer offer) { InitializeComponent(); lblId.Text = offer.Id.ToString(); lblBusinessName.Text = offer.Business.Name; lblTitleJob.Text = offer.Title; lblDescription.Text = offer.Description; lblCategory.Text = "Category: " + offer.Category.Name; lblAddress.Text = offer.Address.City + " - " + offer.Address.Street + " - No: " + offer.Address.PostalCode; if (JobOfferService.GetOfferById(Convert.ToInt32(lblId.Text)).Promoted) { btnPromote.BackColor = Color.White; btnPromote.ForeColor = Color.Black; JobOfferService.GetOfferById(Convert.ToInt32(lblId.Text)).Promoted = false; } }
private void lblStatisticLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { int id = Convert.ToInt32(lblId.Text); // _home.Controls.Clear(); string users = JobOfferService.GetClickedUsersInOfferByOfferId(id).Count.ToString(); // MessageBox.Show("Numri i klikimeve apo vjen sakt " + JobOfferService.GetClickedUsersInOfferByOfferId(id).Count); //foreach (var item in JobOfferService.GetClickedUsersInOfferByOfferId(id)) //{ // users += item.Name + " " + item.LastName + "\n"; //} MessageBox.Show("Users that checked your Offers are:\n " + users); //OfferStatistic o1 = new OfferStatistic(id); //o1.Show(); // MessageBox.Show("Users that clicked on this " + JobOfferService.GetClickedUsersInOfferByOfferId(id).ToString()); }
public ApplicationStatistic() { InitializeComponent(); lblMyOffersShared.Text = JobOfferService.GetOffersByBusinessName(LoggedData.LoggedBusiness.Name).Count.ToString(); lblTechnologyOffersJob.Text = JobOfferService.GetJobBsyCategoryAndBusinessName("Technology", LoggedData.LoggedBusiness.Name).ToString(); lblPristinaOffers.Text = JobOfferService.GetJobBsyCity("Prishtinë").ToString(); //// //Applications statistic lblApplicationsNum.Text = ApplicationService.GetApplicationByBusinessName(LoggedData.LoggedBusiness.Name).Count.ToString(); lblMaleApplications.Text = ApplicationService.GetApplicationsByMale().ToString(); lblRefusedApplications.Text = ApplicationService.ApplicationRefused(LoggedData.LoggedBusiness.Name).ToString(); //female find int femaleCount = ApplicationService.GetApplicationByBusinessName(LoggedData.LoggedBusiness.Name).Count - ApplicationService.GetApplicationsByMale(); lblFemalApplicants.Text = femaleCount.ToString(); }
public void ExecuteMethodAndReturnTrue_WhenInvokedWithValidArgs() { //Arrange var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedMapper = new Mock <IMapper>(); var jobOfferService = new JobOfferService(mockedUnitOfWork.Object, mockedMapper.Object); var mockedJobOfferRepository = new Mock <IJobOfferRepository>(); var mockedJobOffer = new Mock <JobOffer>(); var mockedJobOfferModel = new Mock <JobOfferModel>(); //Act mockedMapper.Setup(x => x.Map <JobOffer>(mockedJobOfferModel.Object)).Returns(mockedJobOffer.Object); mockedUnitOfWork.Setup(x => x.JobOfferRepository).Returns(mockedJobOfferRepository.Object); mockedJobOfferRepository.Setup(x => x.Update(mockedJobOffer.Object)); mockedUnitOfWork.Setup(x => x.SaveChanges()); //Assert Assert.IsTrue(jobOfferService.Delete(mockedJobOfferModel.Object)); }
public void GetAllJobOffersMappedToJobOfferModels_WhenInvoked() { //Arrange var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedMapper = new Mock <IMapper>(); var jobOfferService = new JobOfferService(mockedUnitOfWork.Object, mockedMapper.Object); var mockedJobOfferRepository = new Mock <IJobOfferRepository>(); var mockedJobOffer = new Mock <JobOffer>(); //Act mockedUnitOfWork.Setup(x => x.JobOfferRepository).Returns(mockedJobOfferRepository.Object); mockedJobOfferRepository.Setup(x => x.GetAllOrderedByRating()).Returns(new List <JobOffer>() { mockedJobOffer.Object }); //Assert var collectionOfJobOffers = new List <JobOfferModel>(jobOfferService.GetAll()); Assert.AreEqual(1, collectionOfJobOffers.Count); }
public void ReturnCollectionWithAllJobOffersMappedToJobOfferModels_WhenInvoked() { //Arrange var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedMapper = new Mock <IMapper>(); var jobOfferService = new JobOfferService(mockedUnitOfWork.Object, mockedMapper.Object); var mockedJobOfferRepository = new Mock <IJobOfferRepository>(); var mockedJobOffer = new Mock <JobOffer>(); var mockedJobOfferModel = new Mock <JobOfferModel>(); //Act mockedUnitOfWork.Setup(x => x.JobOfferRepository).Returns(mockedJobOfferRepository.Object); mockedJobOfferRepository.Setup(x => x.GetByCompanyId(It.IsAny <int>())).Returns(new List <JobOffer>() { mockedJobOffer.Object }); //Assert var collectionOfJobOfferModels = new List <JobOfferModel>(jobOfferService.GetByCompanyId(1)); Assert.AreEqual(1, collectionOfJobOfferModels.Count); }
public StatisticJobCategory() { InitializeComponent(); lblConstructionNumIndustry.Text = JobOfferService.GetJobBsyCategory("Construction").ToString(); lblEnergyNumIndustry.Text = JobOfferService.GetJobBsyCategory("Energy").ToString(); lblFinanceNumIndustry.Text = JobOfferService.GetJobBsyCategory("Finance").ToString(); lblHealthNumIndustry.Text = JobOfferService.GetJobBsyCategory("Health").ToString(); lblHospitalityNumIndustry.Text = JobOfferService.GetJobBsyCategory("Hospitality").ToString(); lblMediaNumIndustry.Text = JobOfferService.GetJobBsyCategory("Media").ToString(); lblTechNumIndustry.Text = JobOfferService.GetJobBsyCategory("Technology").ToString(); /// part cities /// ë /// lblPejaJobsNum.Text = JobOfferService.GetJobBsyCity("Pejë").ToString(); lblPodujevaJobsNum.Text = JobOfferService.GetJobBsyCity("Podujevë").ToString(); lblPrizrenJobsNum.Text = JobOfferService.GetJobBsyCity("Prizren").ToString(); lblMitrovicaJobsNum.Text = JobOfferService.GetJobBsyCity("Mitrovicë").ToString(); lblFerizajJobsNum.Text = JobOfferService.GetJobBsyCity("Ferizajë").ToString(); lblGJakovaJobsNum.Text = JobOfferService.GetJobBsyCity("Gjakovë").ToString(); lblPrishtinaJobsNum.Text = JobOfferService.GetJobBsyCity("Prishtinë").ToString(); }
private void btnShowStatistic_Click(object sender, EventArgs e) { int id = Convert.ToInt32(lblId.ToString()); MessageBox.Show("Users that clicked on this " + JobOfferService.GetClickedUsersInOfferByOfferId(id).ToString()); }
public void JobOfferServiceTests() { // Addition var unit = new UnitOfWork(GetInMemoryOptions()); var jobOfferService = new JobOfferService(unit, new JobOfferQueryObject(unit)); var c1 = new JobOffer() { Name = "Lol" }; Assert.Null(c1.Id); jobOfferService.CreateAsync(c1).Wait(); unit.SaveChanges(); Assert.NotEqual(-1, c1.Id); Assert.Equal("Lol", unit.JobOfferRepository.GetById(c1.Id ?? -1).Name); Seeder.Seed(unit); var c2 = new JobOffer() { Name = "New addition" }; Assert.Null(c2.Id); jobOfferService.CreateAsync(c2).Wait(); unit.SaveChanges(); Assert.NotEqual(-1, c2.Id); Assert.Equal("New addition", unit.JobOfferRepository.GetById(c2.Id ?? -1).Name); // Getter Assert.Equal(unit.JobOfferRepository.GetById(1).Name, jobOfferService.GetByIdAsync(1).Result.Name); Assert.Equal(unit.JobOfferRepository.GetById(3).Name, jobOfferService.GetByIdAsync(3).Result.Name); Assert.Equal(unit.JobOfferRepository.GetById(2).Name, jobOfferService.GetByIdAsync(2).Result.Name); Assert.Equal(unit.JobOfferRepository.GetById(2).Description, jobOfferService.GetByIdAsync(2).Result.Description); Assert.Equal(unit.JobOfferRepository.GetById(2).CompanyId, jobOfferService.GetByIdAsync(2).Result.CompanyId); // Update c1.Name = "new Lol"; jobOfferService.UpdateAsync(c1).Wait(); unit.SaveChanges(); Assert.Equal("new Lol", unit.JobOfferRepository.GetById(c1.Id ?? -1).Name); Assert.Equal("new Lol", unit.JobOfferQuery .FilterByNameContains("Lol") .ExecuteAsync() .Result .First() .Name); var appleOffer = unit.JobOfferQuery.FilterByNameContains("Apple") .OrderBy(o => o.Name) .ExecuteAsync() .Result .First(); Assert.NotNull(appleOffer); Assert.Equal("Software development at Apple", appleOffer.Name); appleOffer.Name = "Not Apple"; jobOfferService.UpdateAsync(appleOffer).Wait(); unit.SaveChanges(); Assert.Equal("Not Apple", unit.JobOfferRepository.GetById(appleOffer.Id ?? -1).Name); Assert.Equal(new List <string>() { "Not Apple", "Well-paid position at Apple" }, unit.JobOfferQuery .FilterByNameContains("Apple") .OrderBy(o => o.Name) .ExecuteAsync() .Result .Select(o => o.Name)); // Delete int size = unit.JobOfferRepository.GetAll().Count(); jobOfferService.DeleteAsync(c1.Id ?? -1).Wait(); Assert.Equal(size - 1, unit.JobOfferRepository.GetAll().Count()); }
public JobOffersController(JobOfferService jobOfferService) { _jobOfferService = jobOfferService; }
public JobOfferFacade(UnitOfWork unitOfWork, JobOfferService jobOfferService, IMapper mapper) { this.unitOfWork = unitOfWork; this.jobOfferService = jobOfferService; this.mapper = mapper; }