Example #1
0
        public virtual ActionResult PurchaseContact(int jigsawId, string contactName, string prevUrl)
        {
            JigsawUserPointsViewModel points;

            try { points = _getUserPointsProc.Execute(new GetJigsawUserPointsParams {
                    RequestingUserId = CurrentUserId
                }); }
            catch (JigsawException ex)
            {
                if (!(ex is JigsawCredentialsNotFoundException) && !(ex is InvalidJigsawCredentialsException))
                {
                    throw;
                }

                return(RedirectToAction(MVC.ContactSearch.Jigsaw.Authenticate(Request.RawUrl)));
            }

            if (points == null)
            {
                throw new JigsawException("User Jigsaw Points structure was null");
            }

            var model = new JigsawContactPurchaseViewModel
            {
                Points            = points.Points,
                PurchasePointsUrl = points.PurchasePointsUrl,
                JigsawContactId   = jigsawId,
                JigsawContactName = contactName,
                ReturnUrl         = prevUrl
            };

            return(View(model));
        }
        public virtual ActionResult Details(int id)
        {
            var model = _milestoneQuery.Execute(new MilestoneIdParams {
                MilestoneId = id, RequestingUserId = CurrentUserId
            });

            return(View(model));
        }
Example #3
0
        public virtual ActionResult Details(int jigsawId, int?mergeCompanyId = null)
        {
            var model = _companyDetailsProcess.Execute(new JigsawCompanyDetailsParams {
                RequestingUserId = CurrentUserId, JigsawId = jigsawId
            });

            ViewBag.MergeCompanyId = mergeCompanyId;
            return(View(model));
        }
Example #4
0
        public void InvalidKey_Result_When_FillPerfect_Key_Doesnt_Match_For_Any_User()
        {
            // Act
            var result = _activationProc.Execute(new ActivateFillPerfectKeyParams {
                FillPerfectKey = Guid.NewGuid(), MachineId = "1234"
            });

            // Verify
            Assert.AreEqual(FillPerfectActivationResult.InvalidKey, result.Result, "Process returned an incorrect result");
        }
Example #5
0
 private void BackupRepository(string localBackupRepositoryFolder)
 {
     _logger.Info("Backup to: " + localBackupRepositoryFolder);
     using (new ChangeCurrentDirectory(localBackupRepositoryFolder))
     {
         _process.Reset();
         _process.Execute("git.exe", "fetch", true, localBackupRepositoryFolder);
         _logger.Info(_process.StandardOutput);
     }
 }
        public virtual ActionResult List()
        {
            var user          = _userByIdQuery.WithUserId(CurrentUserId).Execute();
            var milestoneList = _milestoneListQuery.Execute(new ByOrganizationIdParams
            {
                OrganizationId   = (int)user.OrganizationId,
                RequestingUserId = user.Id
            });

            return(View(milestoneList));
        }
        public void Token_Not_Valid_When_User_Has_No_LinkedIn_Token()
        {
            // Act
            var result = _process.Execute(new VerifyUserLinkedInAccessTokenParams {
                UserId = _user.Id
            });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsFalse(result.AccessTokenValid, "Process incorrectly specified the access token as valid");
        }
Example #8
0
        public virtual ActionResult HideDocumentFromMembers(int docId)
        {
            _orgDocVisibilityProcess.Execute(new OrgMemberDocVisibilityByOrgAdminParams
            {
                RequestingUserId   = CurrentUserId,
                OfficialDocumentId = docId,
                ShowToMembers      = false
            });

            return(RedirectToAction(MVC.Organization.Dashboard.Index()));
        }
Example #9
0
        public virtual ActionResult Index()
        {
            // If the user doesn't have a valid LinkedIn OAuth token, redirect them to get it
            if (!_verifyTokenProcess.Execute(new VerifyUserLinkedInAccessTokenParams {
                UserId = CurrentUserId
            }).AccessTokenValid)
            {
                return(RedirectToAction(MVC.PositionSearch.LinkedIn.AuthorizationAlert()));
            }

            return(View());
        }
Example #10
0
        public void Start_Rpc_Server_Before_Running_Tests()
        {
            var dotNetTestRunner      = new DotNetTestRunner(_rpcServerMock, _process);
            var testProjectOutputPath = "bin/debug";
            var coverageContext       = new CoverageContext();

            dotNetTestRunner.Run(coverageContext, testProjectOutputPath);

            Received.InOrder(() =>
            {
                _rpcServerMock.Start(Arg.Any <CoverageContext>());
                _process.Execute(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>());
            });
        }
Example #11
0
        public virtual ActionResult GetMemberStats(int organizationId)
        {
            var stats = _memberStatsProcess.Execute(new OrganizationMemberStatisticsParams
            {
                OrganizationId   = organizationId,
                RequestingUserId = CurrentUserId
            });

            return(Json(new
            {
                aaData = stats.MemberStats
                         .Select(x => new object[]
                {
                    "<img class=\"btnDetails\" src=\"" + Url.Content("~/Content/Images/details_open.png") + "\" />",
                    Server.HtmlEncode(x.FullName),
                    Server.HtmlEncode(x.Email),
                    x.Metrics.NumCompaniesCreated,
                    x.Metrics.NumContactsCreated,
                    x.Metrics.NumApplyTasksCreated,
                    x.Metrics.NumApplyTasksCompleted,
                    x.Metrics.NumPhoneInterviewTasksCreated,
                    x.Metrics.NumInPersonInterviewTasksCreated
                })
                         .ToArray()
            }, JsonRequestBehavior.AllowGet));
        }
Example #12
0
        public virtual ActionResult AddCompany(AddCompanyViewModel model)
        {
            if (model.ExistingCompanyId == 0 && !model.CreateNewCompany)
            {
                ModelState.AddModelError("", "You must either mark to create a new company, or select a company to sync with");
            }

            if (!ModelState.IsValid)
            {
                var jobSearch = _context.Users.Where(x => x.Id == CurrentUserId).Select(x => x.LastVisitedJobSearch).Single();
                model.CreateCompanyList(jobSearch);
                return(View(model));
            }

            if (model.CreateNewCompany)
            {
                var result = _addCompanyProcess.Execute(new AddJigsawCompanyParams {
                    JigsawId = model.JigsawId, RequestingUserId = CurrentUserId
                });
                return(RedirectToAction(MVC.CompanySearch.Jigsaw.AddCompanySuccess(result.CompanyId, result.CompanyName)));
            }

            // else
            return(RedirectToAction(MVC.CompanySearch.Jigsaw.Sync(model.ExistingCompanyId, model.JigsawId)));
        }
Example #13
0
        public virtual ActionResult PerformSearch(PositionSearchQueryViewModel searchParams, int pageNum = 0)
        {
            if (!_verifyTokenProcess.Execute(new VerifyUserLinkedInAccessTokenParams {
                UserId = CurrentUserId
            }).AccessTokenValid)
            {
                return(RedirectToAction(MVC.PositionSearch.LinkedIn.AuthorizationAlert()));
            }

            if (!ModelState.IsValid)
            {
                return(View(new PerformedSearchViewModel {
                    SearchQuery = searchParams
                }));
            }

            var results = _searchProcess.Execute(new LinkedInPositionSearchParams
            {
                RequestingUserId = CurrentUserId,
                Keywords         = searchParams.Keywords,
                CountryCode      = searchParams.SelectedCountryCode,
                ZipCode          = searchParams.PostalCode,
                ResultsPageNum   = pageNum
            });

            var model = new PerformedSearchViewModel
            {
                SearchQuery = searchParams,
                Results     = results
            };

            return(View(model));
        }
Example #14
0
        public virtual ActionResult Edit(EditPositionViewModel model)
        {
            PositionDisplayViewModel editedModel;

            model.RequestedUserId = CurrentUserId;

            if (string.IsNullOrWhiteSpace(model.Title))
            {
                model.Company = new CompanySummaryViewModel(_companyByIdQuery.WithCompanyId(model.Company.Id).Execute());
                return(View(model));
            }

            try
            {
                if (model.Id == 0)
                {
                    editedModel = _createProcess.Execute(Mapper.Map <EditPositionViewModel, CreatePositionParams>(model));
                }
                else
                {
                    editedModel = _editProcess.Execute(Mapper.Map <EditPositionViewModel, EditPositionParams>(model));
                }
            }
            catch (UserNotAuthorizedForEntityException ex)
            {
                ViewBag.EntityType = ex.EntityType.Name;
                return(View(MVC.Shared.Views.EntityNotFound));
            }

            return(RedirectToAction(MVC.Position.Details(editedModel.Id)));
        }
        public void Can_Save_Jigsaw_Encrypted_Credentials_For_User()
        {
            // Setup
            string username = "******";
            string unencryptedPass = "******";
            byte[] expectedKey = Convert.FromBase64String("LHRqdBadRUVh3cdMYoeuYVng/qQlgvBReEAg5JvO48E=");
            byte[] expectedIV = Convert.FromBase64String("CB7hOrmWxs2riRF26Imn7w==");

            var encryptionMock = new Mock<EncryptionUtils>();
            encryptionMock.Setup(x => x.EncryptStringToBytes_AES(unencryptedPass, expectedKey, expectedIV)).Returns(new byte[] { Convert.ToByte(true) });

            var user = new User();
            _context.Users.Add(user);
            _context.SaveChanges();

            _process = new JigsawAuthProcesses(_context, encryptionMock.Object);

            // Act
            var result = _process.Execute(new SaveJigsawUserCredentialsParams
            {
                RequestingUserId = user.Id,
                JigsawUsername = username,
                JigsawPassword = unencryptedPass
            });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.IsTrue(result.WasSuccessful, "Process' result was not successful");

            var jigsaw = _context.JigsawAccountDetails.SingleOrDefault();
            Assert.IsNotNull(jigsaw, "No jigsaw credentials entity was created");
            Assert.AreEqual(username, jigsaw.Username, "Jigsaw username was incorrect");
            Assert.AreEqual(Convert.ToBase64String(new byte[] { Convert.ToByte(true) }), jigsaw.EncryptedPassword, "Jigsaw password was incorrect");
        }
        public virtual JsonResult GetNewFpContactResponses()
        {
            var results = _getDbFpContactResponseProc.Execute(new GetFpContactResponsesParams
            {
                RequestingUserId = CurrentUserId,
                GetNewResponses  = true
            });

            var data = results.Results
                       .Select(x => new object[]
            {
                x.Id,
                HttpUtility.HtmlEncode(x.Name),
                HttpUtility.HtmlEncode(x.Email),
                HttpUtility.HtmlEncode(x.School),
                HttpUtility.HtmlEncode(x.Program),
                x.ReceivedDate.ToLongDateString(),
                x.RepliedDate != null ? x.RepliedDate.Value.ToLongDateString() : "",
                string.Format("<a href=\"{0}\" class=\"inlineBlue\">Reply</a>", Url.Action(MVC.FillPerfect.FpContactResponse.CreateAccount(x.Id))),
                string.Format("<a href=\"{0}\" class=\"inlineBlue\">Delete</a>", Url.Action(MVC.FillPerfect.FpContactResponse.DeleteResponse(x.Id)))
            });

            return(Json(new
            {
                iTotalRecords = results.TotalResultsCount,
                aaData = data.ToArray()
            }, JsonRequestBehavior.AllowGet));
        }
        public void Can_Get_Decrypted_Credentials()
        {
            // Setup
            string decryptedString = "decrypted string";
            string username        = "******";
            string encryptedString = "w6AnE3eWg1urf54jkTejCku+JT3gPT78e9MAkUa8fsI=";

            byte[] expectedKey           = Convert.FromBase64String("LHRqdBadRUVh3cdMYoeuYVng/qQlgvBReEAg5JvO48E=");
            byte[] expectedIV            = Convert.FromBase64String("CB7hOrmWxs2riRF26Imn7w==");
            byte[] expectedEncryptedPass = Convert.FromBase64String(encryptedString);

            var encryptionMock = new Mock <EncryptionUtils>();

            encryptionMock.Setup(x => x.DecryptStringFromBytes_AES(expectedEncryptedPass, expectedKey, expectedIV)).Returns(decryptedString);

            var user   = new User();
            var jigsaw = new JigsawAccountDetails {
                AssociatedUser = user, Username = username, EncryptedPassword = encryptedString
            };

            _context.JigsawAccountDetails.Add(jigsaw);
            _context.SaveChanges();

            _process = new JigsawAuthProcesses(_context, encryptionMock.Object);

            // Act
            var result = _process.Execute(new GetUserJigsawCredentialsParams {
                RequestingUserId = user.Id
            });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.AreEqual(username, result.JigsawUsername, "An incorrect username was returned");
            Assert.AreEqual(decryptedString, result.JigsawPassword, "An incorrect password was returned");
        }
        public void Jigsaw_Credentials_Gets_Updated_If_One_Exists_For_User()
        {
            // Setup
            var encryptionMock = new Mock <EncryptionUtils>();

            encryptionMock.Setup(x => x.EncryptStringToBytes_AES(It.IsAny <string>(), It.IsAny <byte[]>(), It.IsAny <byte[]>())).Returns(new byte[] { Convert.ToByte(true) });

            var user = new User {
                JigsawAccountDetails = new JigsawAccountDetails {
                    Username = "******", EncryptedPassword = "******"
                }
            };

            _context.Users.Add(user);
            _context.SaveChanges();

            _process = new JigsawAuthProcesses(_context, encryptionMock.Object);

            // Act
            var result = _process.Execute(new SaveJigsawUserCredentialsParams
            {
                RequestingUserId = user.Id,
                JigsawUsername   = "******",
                JigsawPassword   = "******"
            });

            // Verify
            Assert.AreEqual(1, _context.JigsawAccountDetails.Count(), "Incorrect number of jigsaw records exist");
            Assert.AreEqual("a", user.JigsawAccountDetails.Username, "Jigsaw username was incorrect");
            Assert.AreEqual(Convert.ToBase64String(new byte[] { Convert.ToByte(true) }), user.JigsawAccountDetails.EncryptedPassword, "Jigsaw password was incorrect");
        }
        static void Main(string[] args)
        {
            System.Console.Write("NxN matrix. Enter N: ");
            var n = Convert.ToInt32(System.Console.ReadLine());

            int[,] array = new int[n, n];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    System.Console.Write("element - [{0},{1}] : ", i, j);
                    array[i, j] = Convert.ToInt32(System.Console.ReadLine());
                }
            }

            /*int[,] array = new[,]
             * {
             *  {0, 1, 2, 2, 3},
             *  {3, 3, 4, 4, 4},
             *  {3, 2, 1, 2, 6},
             *  {3, 1, 2, 1, 4},
             *  {3, 1, 2, 1, 4},
             * };*/

            _progress.ProcessProgressedEvent += ProgressBar;

            var result = _process.Execute(array);

            System.Console.WriteLine("Result: " + result.ToString());
            System.Console.ReadLine();
        }
Example #20
0
        public virtual ActionResult Authenticate(JigsawAuthenticateViewModel model)
        {
            try
            {
                _saveCredentialsProc.Execute(new SaveJigsawUserCredentialsParams
                {
                    RequestingUserId = CurrentUserId,
                    JigsawUsername   = model.Username,
                    JigsawPassword   = model.Password
                });
            }
            catch (InvalidJigsawCredentialsException)
            {
                ModelState.AddModelError("login", "The provided credentials could not be used to log into Jigsaw");
                return(View(model));
            }

            // Authentication was successful, go to the return url if one specified
            if (!string.IsNullOrWhiteSpace(model.ReturnUrl))
            {
                return(Redirect(model.ReturnUrl));
            }

            return(RedirectToAction(MVC.ContactSearch.Jigsaw.Index()));
        }
        public void Jigsaw_Credentials_Gets_Updated_If_One_Exists_For_User()
        {
            // Setup
            var encryptionMock = new Mock<EncryptionUtils>();
            encryptionMock.Setup(x => x.EncryptStringToBytes_AES(It.IsAny<string>(), It.IsAny<byte[]>(), It.IsAny<byte[]>())).Returns(new byte[] { Convert.ToByte(true) });

            var user = new User { JigsawAccountDetails = new JigsawAccountDetails { Username = "******", EncryptedPassword = "******" } };
            _context.Users.Add(user);
            _context.SaveChanges();

            _process = new JigsawAuthProcesses(_context, encryptionMock.Object);

            // Act
            var result = _process.Execute(new SaveJigsawUserCredentialsParams
            {
                RequestingUserId = user.Id,
                JigsawUsername = "******",
                JigsawPassword = "******"
            });

            // Verify
            Assert.AreEqual(1, _context.JigsawAccountDetails.Count(), "Incorrect number of jigsaw records exist");
            Assert.AreEqual("a", user.JigsawAccountDetails.Username, "Jigsaw username was incorrect");
            Assert.AreEqual(Convert.ToBase64String(new byte[] { Convert.ToByte(true) }), user.JigsawAccountDetails.EncryptedPassword, "Jigsaw password was incorrect");
        }
        public void Can_Get_Decrypted_Credentials()
        {
            // Setup
            string decryptedString = "decrypted string";
            string username = "******";
            string encryptedString = "w6AnE3eWg1urf54jkTejCku+JT3gPT78e9MAkUa8fsI=";
            byte[] expectedKey = Convert.FromBase64String("LHRqdBadRUVh3cdMYoeuYVng/qQlgvBReEAg5JvO48E=");
            byte[] expectedIV = Convert.FromBase64String("CB7hOrmWxs2riRF26Imn7w==");
            byte[] expectedEncryptedPass = Convert.FromBase64String(encryptedString);

            var encryptionMock = new Mock<EncryptionUtils>();
            encryptionMock.Setup(x => x.DecryptStringFromBytes_AES(expectedEncryptedPass, expectedKey, expectedIV)).Returns(decryptedString);

            var user = new User();
            var jigsaw = new JigsawAccountDetails { AssociatedUser = user, Username = username, EncryptedPassword = encryptedString };
            _context.JigsawAccountDetails.Add(jigsaw);
            _context.SaveChanges();

            _process = new JigsawAuthProcesses(_context, encryptionMock.Object);

            // Act
            var result = _process.Execute(new GetUserJigsawCredentialsParams { RequestingUserId = user.Id });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.AreEqual(username, result.JigsawUsername, "An incorrect username was returned");
            Assert.AreEqual(decryptedString, result.JigsawPassword, "An incorrect password was returned");
        }
Example #23
0
        public virtual ActionResult AddPosition(AddPositionViewModel model)
        {
            if (!_verifyTokenProcess.Execute(new VerifyUserLinkedInAccessTokenParams {
                UserId = CurrentUserId
            }).AccessTokenValid)
            {
                return(RedirectToAction(MVC.PositionSearch.LinkedIn.AuthorizationAlert()));
            }

            if (!model.CreateNewCompany && model.SelectedCompany <= 0)
            {
                ModelState.AddModelError("company", "You must either select to add a new company entry, or select an existing company to add the position to");
            }

            if (!ModelState.IsValid)
            {
                var user      = _context.Users.Where(x => x.Id == CurrentUserId).Single();
                var companies = _companyByJobSearchQuery.WithJobSearchId((int)user.LastVisitedJobSearchId).Execute();
                model.SetCompanyList(companies);
                return(View(model));
            }

            var result = _addPositionProcess.Execute(new AddLinkedInPositionParams
            {
                RequestingUserId  = CurrentUserId,
                CreateNewCompany  = model.CreateNewCompany,
                PositionId        = model.PositionId,
                ExistingCompanyId = model.SelectedCompany
            });

            return(RedirectToAction(MVC.PositionSearch.LinkedIn.AddPositionSuccessful(result.CompanyId, result.CompanyName, result.PositionId, result.PositionTitle)));
        }
        public virtual ActionResult Index()
        {
            var model = _getFpLicensesProc.Execute(new GetOrderableFillPerfectLicensesParams {
                RequestingUserID = CurrentUserId
            });

            return(View(model));
        }
Example #25
0
        public virtual ActionResult About()
        {
            var model = _userVisibleDocsProcess.Execute(new ByUserIdParams {
                UserId = CurrentUserId
            });

            return(View(model));
        }
Example #26
0
        public virtual ActionResult List()
        {
            var positions = _getPositionListProcess.Execute(new GetPositionListForUserParams {
                UserId = CurrentUserId
            });

            return(View(positions));
        }
        public void License_Request_Returns_InvalidKey_When_No_User_Has_Specified_Key()
        {
            // Act
            var result = _getKeyProc.Execute(new GetFillPerfectLicenseByKeyParams {
                FillPerfectKey = Guid.NewGuid()
            });

            // Verify
            Assert.AreEqual(FillPerfectLicenseError.InvalidKey, result.Error, "Incorrect license error returned");
        }
Example #28
0
        public void Can_Retrieve_Positions_From_LinkedIn()
        {
            // Act
            var result = _process.Execute(new LinkedInPositionSearchParams
            {
                RequestingUserId = _user.Id,
                Keywords         = "Software Engineer",
                CountryCode      = "us",
                ResultsPageNum   = 2
            });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.AreEqual(2, result.PageNum, "The view model's page number was incorrect");
            Assert.IsNotNull(result.Results, "The result list was null");
            Assert.AreEqual(result.PageSize, result.Results.Count, "Result list had an incorrect number of results");
            Assert.AreEqual(ExternalDataSource.LinkedIn, result.DataSource, "Result had an incorrect position data source value");
        }
        public virtual ActionResult Index()
        {
            // Only get new emails from the email box if running on production
            if (Convert.ToBoolean(ConfigurationManager.AppSettings["IsProduction"]))
            {
                _fetchResponseProc.Execute(new FetchFpContactResponseEmailsParams());
            }

            return(View());
        }
Example #30
0
        public static T ObserveInteractions<T>(IProcess<T> processToObserve, IOutcome outcomeToModify)
        {
            if (processToObserve == null) { throw new ArgumentNullException(nameof(processToObserve), ProvidedNullProcess); }
            if (outcomeToModify  == null) { throw new ArgumentNullException(nameof(outcomeToModify),  ProvidedNullOutcome); }

            StartNewEvent(outcomeToModify);

            try     { return processToObserve.Execute(); }
            finally { ConcludeCurrentEvent();            }
        }
Example #31
0
        public virtual ActionResult BeginAuthorization()
        {
            _startLiAuthProcess.Execute(new StartLinkedInUserAuthParams
            {
                RequestingUserId = CurrentUserId,
                ReturnUrl        = new Uri(Request.Url.Scheme + "://" + Request.Url.Authority + Url.Action(MVC.PositionSearch.LinkedIn.ProcessAuthorization()))
            });

            // Shouldn't be hit
            return(null);
        }
        public void Can_Retrieve_Job_Details_From_Linked_In()
        {
            // Setup
            string positionId     = "217456";
            string expTitle       = "Research Manager supporting Forbes.com worldwide online ad sales team";
            string expLocation    = "Greater New York City Area";
            string expCompanyName = "Forbes.com Inc.";
            //string expCompanyId = "21836";
            DateTime expPostDate     = new DateTime(2007, 1, 14);
            string   expExperience   = "Mid-Senior level";
            string   expJobType      = "Full-time";
            string   expJobFunctions = "Research";
            string   expIndustries   = "Online Media";
            string   expDescription  = @"Forbes.com Research Manager<br><br>Based in New York, the research manager is responsible for managing all research services and projects, with an opportunity to be part of an expanding research department. This position serves as a strategic partner with Forbes.com’s worldwide advertising sales team.  This position plays a central role in maintaining Forbes.com’s position as a pioneer in original research for the online business leadership market.<br><br>Primary Job Responsibilities:<br><br>Lead and present strategic primary research efforts to support sales. <br><br>Manage the department and extensive requests generated by sales including ad effectiveness research.<br><br>Manage budgets and relationships with third party research vendors (e.g., CMR, MMX, NNR, Dynamic Logic, InsightExpress).  <br><br>Set strategies and best practices for media and ad effectiveness research.<br><br>Represent Forbes.com on major industry committees (e.g., IAB, ARF, OPA)<br> <br>Skills and Qualifications:<br><br>·         Strong understanding of both online and offline media research<br><br>·         Excellent presentation skills <br><br>·         Strong market research and survey research experience<br><br>·         Strong strategic and analytical skills as well as detail oriented<br><br>·         Desire to work in a fast-paced, fun and demanding environment.<br><br>·         High energy level and great interpersonal skills.";

            // Act
            var result = _process.Execute(new LinkedInPositionDetailsParams {
                RequestingUserId = _user.Id, PositionId = positionId
            });

            // Verify
            Assert.IsNotNull(result, "Process returned a null result");
            Assert.AreEqual(positionId, result.Id, "Position's id value was incorrect");
            Assert.AreEqual(expTitle, result.Title, "Position's title was incorrect");
            Assert.AreEqual(expLocation, result.Location, "Position's location was incorrect");
            Assert.AreEqual(expCompanyName, result.CompanyName, "Position's company name was incorrect");
            //Assert.AreEqual(expCompanyId, result.CompanyId, "Position's company id was incorrect");
            Assert.AreEqual(expPostDate, result.PostedDate, "Position's posted date was incorrect");
            Assert.AreEqual(expExperience, result.ExperienceLevel, "Position's experience level was incorrect");
            Assert.AreEqual(expJobType, result.JobType, "Position's job type was incorrect");
            Assert.AreEqual(expJobFunctions, result.JobFunctions, "Position's job functions was incorrect");
            Assert.AreEqual(expIndustries, result.Industries, "Position's industries was incorrect");
            Assert.AreEqual(expDescription, result.Description, "Position's description was incorrect");
            Assert.IsFalse(result.IsActive, "Position was incorrect set as active");

            Assert.AreEqual("CNaU-cXF34", result.JobPosterId, "Job poster id was incorrect");
            Assert.AreEqual("Bruce R.", result.JobPosterName, "Job poster name was incorrect");
            Assert.AreEqual("Chief Insights Officer at Forbes", result.JobPosterHeadline, "Job poster's headline was incorrect");

            Assert.AreEqual(ExternalDataSource.LinkedIn, result.DataSource, "Position's data source was incorrect");
        }
        public void Returns_Null_If_No_Credentials_Exist()
        {
            // Setup
            var encryptionMock = new Mock<EncryptionUtils>();
            _process = new JigsawAuthProcesses(_context, encryptionMock.Object);

            // Act
            var result = _process.Execute(new GetUserJigsawCredentialsParams { RequestingUserId = 1 });

            // Verify
            Assert.IsNull(result);
        }
Example #34
0
        /// <summary>
        /// Executes the query
        /// </summary>
        /// <returns></returns>
        public virtual Contact Execute()
        {
            // Check if the user is authorized for the contact
            if (!_contactAuthProcess.Execute(new ContactAutorizationParams {
                ContactId = _contactId, RequestingUserId = _userId
            }).UserAuthorized)
            {
                return(null);
            }

            return(_unitOfWork.Contacts.Fetch().Where(x => x.Id == _contactId).SingleOrDefault());
        }
        public void Throws_EntityNotFoundException_When_User_Not_Found()
        {
            // Setup
            var encryptionMock = new Mock<EncryptionUtils>();
            encryptionMock.Setup(x => x.EncryptStringToBytes_AES(It.IsAny<string>(), It.IsAny<byte[]>(), It.IsAny<byte[]>())).Returns(new byte[] { Convert.ToByte(true) });

            var user = new User { JigsawAccountDetails = new JigsawAccountDetails { Username = "******", EncryptedPassword = "******" } };
            _context.Users.Add(user);
            _context.SaveChanges();

            int id = user.Id + 101;
            _process = new JigsawAuthProcesses(_context, encryptionMock.Object);

            // Act
            try
            {
                _process.Execute(new SaveJigsawUserCredentialsParams { RequestingUserId = id });
                Assert.Fail("No exception was thrown");
            }

            // Verify
            catch (MJLEntityNotFoundException ex)
            {
                Assert.AreEqual(typeof(User), ex.EntityType, "Exception's entity type value was incorrect");
                Assert.AreEqual(id.ToString(), ex.IdValue, "Exception's id value was incorrect");
            }
        }