Exemplo n.º 1
0
        public void TestUploadInvalidExtension()
        {
            const string file  = @"Test\Data\Resumes\ProfessionalResume.xyz";
            var          model = Upload(FileSystem.GetAbsolutePath(file, RuntimeEnvironment.GetSourceFolder()));

            AssertJsonError(model, null, "The resume extension '.xyz' is not supported.");
        }
Exemplo n.º 2
0
        public void TestUploadTooLarge()
        {
            const string file  = @"Test\Data\Resumes\TooLarge.doc";
            var          model = Upload(FileSystem.GetAbsolutePath(file, RuntimeEnvironment.GetSourceFolder()));

            AssertJsonError(model, null, "The size of the file exceeds the maximum allowed of 2MB.");
        }
Exemplo n.º 3
0
        public void TestUpload()
        {
            const string file     = @"Test\Data\Resumes\ProfessionalResume.doc";
            var          fileName = Path.GetFileName(file);
            var          model    = Upload(FileSystem.GetAbsolutePath(file, RuntimeEnvironment.GetSourceFolder()));

            AssertModel(fileName, model);
            AssertFile(fileName, "application/msword", model.Id);
        }
Exemplo n.º 4
0
        public static T LoadData <T>(string name)
            where T : VerticalTestData, new()
        {
            var data     = new T();
            var folder   = Path.Combine(Path.Combine(RuntimeEnvironment.GetSourceFolder(), @"Test\Data\Verticals"), name);
            var dataFile = Path.Combine(folder, "VerticalData.xml");

            LoadData(dataFile, data);
            return(data);
        }
Exemplo n.º 5
0
        public void TestAuthorisation()
        {
            // Upload.

            const string file  = @"Test\Data\Resumes\ProfessionalResume.doc";
            var          model = Upload(FileSystem.GetAbsolutePath(file, RuntimeEnvironment.GetSourceFolder()));

            AssertJsonError(model, null, "100", "The user is not logged in.");

            // Parse.

            AssertJsonError(Parse(HttpStatusCode.Forbidden, Guid.NewGuid()), null, "100", "The user is not logged in.");
        }
Exemplo n.º 6
0
        public static void SetupApplications(WebSite currentWebSite)
        {
            ApplicationSetUp.SetSourceRootPath(RuntimeEnvironment.GetSourceFolder());

            var details = new Dictionary <WebSite, WebSiteDetails>();

            foreach (WebSite webSite in Enum.GetValues(typeof(WebSite)))
            {
                details.Add(webSite, new WebSiteDetails("localhost", -1, null));
            }

            ApplicationSetUp.SetWebSites(details);
            ApplicationSetUp.SetCurrentApplication(currentWebSite);
        }
Exemplo n.º 7
0
        private static string GetEmailsFolder(string community)
        {
            var emailsFolder = FileSystem.GetAbsolutePath(@"Test\Emails", RuntimeEnvironment.GetSourceFolder());

            if (!string.IsNullOrEmpty(community))
            {
                emailsFolder = Path.Combine(emailsFolder, community);
            }
            if (!Directory.Exists(emailsFolder))
            {
                Directory.CreateDirectory(emailsFolder);
            }
            return(emailsFolder);
        }
Exemplo n.º 8
0
        public static void SetupApplications(WebSite currentWebSite)
        {
            ApplicationSetUp.SetSourceRootPath(RuntimeEnvironment.GetSourceFolder());

            var details = new Dictionary <WebSite, WebSiteDetails>();

            foreach (WebSite webSite in Enum.GetValues(typeof(WebSite)))
            {
                var host            = Instance.GetProperty(GetWebSitePrefix(webSite) + ".host", true);
                var port            = Instance.GetIntProperty(GetWebSitePrefix(webSite) + ".port", -1);
                var applicationPath = Instance.GetProperty(GetWebSitePrefix(webSite) + ".applicationpath", true);

                details.Add(webSite, new WebSiteDetails(host, port, applicationPath));
            }

            ApplicationSetUp.SetWebSites(details);
            ApplicationSetUp.SetCurrentApplication(currentWebSite);
        }
Exemplo n.º 9
0
        public string GetSourcePath(string property)
        {
            string value = GetProperty(property);

            if (FileSystem.IsAbsolutePath(value))
            {
                return(value);
            }

            var sourceFolder = RuntimeEnvironment.GetSourceFolder();

            if (sourceFolder == null)
            {
                throw new ApplicationException(string.Format("The value of the '{0}' application property is a relative path ('{1}'),"
                                                             + " but the source root directory does not exist. If you have moved the binaries from the directory or machine"
                                                             + " where they were built the property will have to be an absolute path.", property, value));
            }

            return(FileSystem.GetAbsolutePath(value, sourceFolder));
        }
Exemplo n.º 10
0
        private static IEnumerable <string> GetEmails()
        {
            var emails = new List <string>();

            // Search through all template files.

            var folder = FileSystem.GetAbsolutePath(@"Apps\Config", RuntimeEnvironment.GetSourceFolder());

            foreach (var file in Directory.GetFiles(folder, "email-template*"))
            {
                var document = new XmlDocument();
                document.Load(file);

                foreach (XmlNode xmlNode in document.SelectNodes("/ContentItems/TemplateContentItems/TemplateContentItem/@Name"))
                {
                    if (!emails.Contains(xmlNode.Value))
                    {
                        emails.Add(xmlNode.Value);
                    }
                }
            }

            return(emails);
        }
Exemplo n.º 11
0
        public void TestAddLogo()
        {
            var employer = CreateEmployer(null);
            var jobAd    = CreateJobAd(employer, JobAdStatus.Draft);

            Assert.IsNull(jobAd.LogoId);

            LogIn(employer);
            Get(GetJobAdUrl(jobAd.Id));

            var filePath = FileSystem.GetAbsolutePath(@"Test\Data\Photos\ProfilePhoto.jpg", RuntimeEnvironment.GetSourceFolder());

            _logo.FilePath = filePath;
            _saveButton.Click();

            Assert.IsTrue(_logoId.IsVisible);
            var logoId = new Guid(_logoId.Text);

            AssertFile(logoId, filePath);

            jobAd = _jobAdsQuery.GetJobAd <JobAd>(jobAd.Id);
            Assert.AreEqual(logoId, jobAd.LogoId);
            AssertFile(logoId, filePath);
        }
Exemplo n.º 12
0
        public void TestUploadWrongExtension()
        {
            var employer = CreateEmployer(null);
            var jobAd    = CreateJobAd(employer, JobAdStatus.Draft);

            LogIn(employer);
            Get(GetJobAdUrl(jobAd.Id));

            var filePath = FileSystem.GetAbsolutePath(@"Test\Data\Resumes\Complete.doc", RuntimeEnvironment.GetSourceFolder());

            _logo.FilePath = filePath;
            _saveButton.Click();

            AssertUrlWithoutQuery(GetJobAdUrl(jobAd.Id));
            AssertErrorMessage("The extension 'doc' is not supported.");

            Assert.IsFalse(_logoId.IsVisible);
            Assert.AreEqual("", _logo.FilePath);

            jobAd = _jobAdsQuery.GetJobAd <JobAd>(jobAd.Id);
            Assert.IsNull(jobAd.LogoId);
        }
Exemplo n.º 13
0
        public void TestDetach()
        {
            var employer = CreateEmployer(0);

            LogIn(employer);

            var model1 = Attach(FileSystem.GetAbsolutePath(@"Test\Data\Attachments\TextAttachment.txt", RuntimeEnvironment.GetSourceFolder()));
            var model2 = Attach(FileSystem.GetAbsolutePath(@"Test\Data\Attachments\WordAttachment.doc", RuntimeEnvironment.GetSourceFolder()));

            AssertAttachments(employer, model1, model2);

            // Detach the first.

            var model = Detach(model1.Id);

            AssertJsonSuccess(model);

            Assert.IsNull(_employerMemberContactsQuery.GetMessageAttachment(employer, model1.Id));
            AssertAttachments(employer, model2);
        }
Exemplo n.º 14
0
        public void TestMultipleAttachments()
        {
            var employer = CreateEmployer(0);

            LogIn(employer);

            var model1 = Attach(FileSystem.GetAbsolutePath(@"Test\Data\Attachments\TextAttachment.txt", RuntimeEnvironment.GetSourceFolder()));

            AssertModel("TextAttachment.txt", model1);

            var model2 = Attach(FileSystem.GetAbsolutePath(@"Test\Data\Attachments\WordAttachment.doc", RuntimeEnvironment.GetSourceFolder()));

            AssertModel("WordAttachment.doc", model2);

            AssertAttachments(employer, model1, model2);
        }
Exemplo n.º 15
0
        public void TestAttachment()
        {
            var employer = CreateEmployer(0);

            LogIn(employer);

            var model = Attach(FileSystem.GetAbsolutePath(@"Test\Data\Attachments\TextAttachment.txt", RuntimeEnvironment.GetSourceFolder()));

            AssertModel("TextAttachment.txt", model);

            AssertAttachments(employer, model);
        }
Exemplo n.º 16
0
        public void TestSampleJobAds()
        {
            var integratorUser = CreateIntegratorUser(0);
            var employer       = CreateEmployer(0);

            // Load the file.

            string requestXml;

            using (TextReader tr = new StreamReader(FileSystem.GetAbsolutePath(SamplePostJobAdsFile, RuntimeEnvironment.GetSourceFolder())))
            {
                requestXml = tr.ReadToEnd();
            }

            requestXml = requestXml.Replace("jobPosterUserId=\"nizzarecruitment-ats\"", "jobPosterUserId=\"" + employer.GetLoginId() + "\"");

            // Call the service.

            var responseXml = Post(_jobAdsUrl, integratorUser, Password, requestXml);

            // Load the XML.

            var xmlDocument = CreateDocument(responseXml);
            var xmlNsMgr    = CreateNamespaceManager(xmlDocument);

            // Select the top level response element, ensuring there are no errors.

            const WebServiceReturnCode returnCode = WebServiceReturnCode.Success;
            var xmlResponse = SelectResponse(xmlDocument, xmlNsMgr, "PostJobAdsResponse", returnCode);

            // Assert stats.

            var xmlJobAds = xmlResponse.SelectSingleNode("lm:JobAds", xmlNsMgr);

            Assert.IsNotNull(xmlJobAds);
            AssertAttributeValue(xmlJobAds, "added", 157.ToString());
            AssertAttributeValue(xmlJobAds, "updated", 0.ToString());
            AssertAttributeValue(xmlJobAds, "closed", 0.ToString());
            AssertAttributeValue(xmlJobAds, "failed", 0.ToString());
        }
Exemplo n.º 17
0
        private static IEnumerable <string> GetPreviews()
        {
            var folder = FileSystem.GetAbsolutePath(@"Test\Emails", RuntimeEnvironment.GetSourceFolder());

            return(Directory.GetFiles(folder, "*.html").Select(Path.GetFileNameWithoutExtension).ToList());
        }
Exemplo n.º 18
0
        public void TestInvalidExtension()
        {
            var filePath = FileSystem.GetAbsolutePath(@"Test\Data\Resumes\ProfessionalResume.doc", RuntimeEnvironment.GetSourceFolder());

            using (var stream = File.Open(filePath, FileMode.Open))
            {
                _employerLogosCommand.SaveLogo(new StreamFileContents(stream), filePath);
            }
        }
Exemplo n.º 19
0
        public void TestMessagesAttachment()
        {
            var employer = CreateEmployer(0);

            LogIn(employer);

            var fileModel = Attach(FileSystem.GetAbsolutePath(@"Test\Data\Attachments\TextAttachment.txt", RuntimeEnvironment.GetSourceFolder()));

            TestMessagesAttachments(employer, false, new[] { fileModel.Id }, CreateMember(0), CreateMember(1));
        }
Exemplo n.º 20
0
        public void Smtp550Test()
        {
            var status = PostFile(FileSystem.GetAbsolutePath(@"Apps\Management\Test\EmailStatus\TestData\Smtp550Test.eml", RuntimeEnvironment.GetSourceFolder()));

            Assert.AreEqual(HttpStatusCode.NoContent, status);
            Assert.AreEqual("*****@*****.**", _emailVerificationsCommand.Member.GetBestEmailAddress().Address);
            Assert.IsFalse(_emailVerificationsCommand.Member.GetBestEmailAddress().IsVerified);
            StringAssert.StartsWith("smtp; 550 '*****@*****.**' is not a registered gateway user", _emailVerificationsCommand.EmailBounceReason);
        }
Exemplo n.º 21
0
        public void Said550Test()
        {
            var status = PostFile(FileSystem.GetAbsolutePath(@"Apps\Management\Test\EmailStatus\TestData\Said550Test.eml", RuntimeEnvironment.GetSourceFolder()));

            Assert.AreEqual(HttpStatusCode.NoContent, status);
            Assert.AreEqual("*****@*****.**", _emailVerificationsCommand.Member.GetBestEmailAddress().Address);
            Assert.IsFalse(_emailVerificationsCommand.Member.GetBestEmailAddress().IsVerified);
            StringAssert.StartsWith(_emailVerificationsCommand.EmailBounceReason, "X-Postfix; host smtpin.ntlworld.com[81.103.221.10] said: 550");
        }
Exemplo n.º 22
0
        public void HealthTest()
        {
            var status = PostFile(FileSystem.GetAbsolutePath(@"Apps\Management\Test\EmailStatus\TestData\HealthTest.eml", RuntimeEnvironment.GetSourceFolder()));

            Assert.AreEqual(HttpStatusCode.Accepted, status);
        }
Exemplo n.º 23
0
        public void Smtp200Test()
        {
            var status = PostFile(FileSystem.GetAbsolutePath(@"Apps\Management\Test\EmailStatus\TestData\Smtp200Test.eml", RuntimeEnvironment.GetSourceFolder()));

            Assert.AreEqual(HttpStatusCode.NoContent, status);
            Assert.IsNull(_emailVerificationsCommand.Member);
        }
Exemplo n.º 24
0
        public void TestSavePng()
        {
            Guid fileReferenceId;

            var filePath = FileSystem.GetAbsolutePath(@"Test\Data\Photos\ProfilePhoto.png", RuntimeEnvironment.GetSourceFolder());

            using (var stream = File.Open(filePath, FileMode.Open))
            {
                fileReferenceId = _employerLogosCommand.SaveLogo(new StreamFileContents(stream), filePath).Id;
            }

            var fileReference = _filesQuery.GetFileReference(fileReferenceId);

            Assert.AreEqual(Path.GetFileName(filePath), fileReference.FileName);
            Assert.AreEqual("image/png", fileReference.MediaType);
            Assert.AreEqual(".png", fileReference.FileData.FileExtension);
            Assert.AreEqual(FileType.CompanyLogo, fileReference.FileData.FileType);
        }
Exemplo n.º 25
0
        public void TestMessagesAttachmentsWithCopy()
        {
            var employer = CreateEmployer(0);

            LogIn(employer);

            var fileModel1 = Attach(FileSystem.GetAbsolutePath(@"Test\Data\Attachments\TextAttachment.txt", RuntimeEnvironment.GetSourceFolder()));
            var fileModel2 = Attach(FileSystem.GetAbsolutePath(@"Test\Data\Attachments\WordAttachment.doc", RuntimeEnvironment.GetSourceFolder()));

            TestMessagesAttachments(employer, true, new[] { fileModel1.Id, fileModel2.Id }, CreateMember(0), CreateMember(1));
        }
Exemplo n.º 26
0
        private static string GetFileName()
        {
            var exeName = typeof(TaskRunner).Assembly.GetName().Name + ".exe";

            return(Path.Combine(RuntimeEnvironment.GetSourceFolder(), Path.Combine("Apps\\TaskRunner\\bin\\", exeName)));
        }
Exemplo n.º 27
0
        private void Configure()
        {
            const string mainFileName = "application.config";
            const string prefix       = "application-";
            const string suffix       = ".config";

            string envFileName  = prefix + RuntimeEnvironment.GetApplicationEnvironmentName(_environment) + suffix;
            string hostFileName = prefix + RuntimeEnvironment.HostName + suffix;

            LoadApplicationPropertyPath();

            // Read property files as follows (for more details see "GuideToLinkMeConfiguration" on the Wiki):
            // 1) Embedded "application.config"
            // 2) Embedded "application-ENV.config" (the same setting must not be defined in 1 and 2).
            // 3) externalPropertyPath\"application-ENV.config" (overrides whatever is defined in 1 and 2.
            // 4) externalPropertyPath\"application-HOSTNAME.config" (overrides whatever is defined in 1 and 2, but
            // the same setting must not be defined in 3 and 4).
            // 5) sourceRootPath\config\"application-ENV.config" (overrides whatever is defined in 1, 2, 3 and 4.
            // 6) sourceRootPath\config\"application-HOSTNAME.config" (overrides whatever is defined in
            // 1, 2, 3 and 4, but the same setting must not be defined in 5 and 6).

            _sources = new SortedList <string, string>();

            IDictionary <string, string> embeddedMain = LoadEmbeddedProperties(mainFileName); // 1
            IDictionary <string, string> embeddedEnv  = LoadEmbeddedProperties(envFileName);  // 2

            string[] overridden;
            IDictionary <string, string> tempProperties = CombineProperties(embeddedMain, embeddedEnv,
                                                                            out overridden);

            if (overridden != null)
            {
                throw new ApplicationException(string.Format("The following configuration properties"
                                                             + " were defined in both '{0}' (embedded) and '{1}' (embedded): '{2}'. A given"
                                                             + " property is either environment-specific or not, so it must be defined either in"
                                                             + " '{0}' or in EACH of the environment-specific files.", mainFileName, envFileName,
                                                             string.Join("', '", overridden)));
            }

            IDictionary <string, string> externalProperties = GetExternalProperties(RuntimeEnvironment.HostName,
                                                                                    _externalPropertyPath, envFileName, hostFileName); // 3 + 4

            // Combine the embedded and external properties into (external config files override the
            // embedded ones).

            _properties = CombineProperties(tempProperties, externalProperties, out overridden);

            var sourceFolder = RuntimeEnvironment.GetSourceFolder();

            if (sourceFolder != null)
            {
                string sourceConfigPath = Path.Combine(sourceFolder, "config");
                IDictionary <string, string> sourceProperties = GetExternalProperties(
                    RuntimeEnvironment.HostName, sourceConfigPath, envFileName, hostFileName); // 5 + 6

                // Add in the the properties under <source root>\config, overriding anything else.

                string[] dummy;
                _properties = CombineProperties(_properties, sourceProperties, out dummy);
            }
        }
Exemplo n.º 28
0
        public void TestAddJobAdForCustomCss()
        {
            var cssDir = FileSystem.GetAbsolutePath(@"Apps\Web\ui\styles\Recruiters",
                                                    RuntimeEnvironment.GetSourceFolder());

            if (!Directory.Exists(cssDir))
            {
                throw new DirectoryNotFoundException("The company CSS directory, '" + cssDir + "', does not exist.");
            }

            var cssFiles = Directory.GetFiles(cssDir, "*.css", SearchOption.TopDirectoryOnly);
            var i        = 0;

            Guid?[] integratorUserId = { null, _careerOneQuery.GetIntegratorUser().Id, _integrationCommand.CreateTestIntegratorUser().Id };
            foreach (var cssFile in cssFiles)
            {
                try
                {
                    var fileName = Path.GetFileName(cssFile);
                    var parts    = fileName.Split(new[] { " - " }, StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length == 2)
                    {
                        var orgName = parts[0];
                        orgName = orgName.Replace('(', ' ');
                        orgName = orgName.Replace(')', ' ');
                        try
                        {
                            var orgId    = new Guid(parts[1].Substring(0, parts[1].LastIndexOf(".css")));
                            var pCode    = (int)(new Random(i).NextDouble() * 100);
                            var location = _locationQuery.ResolveLocation(_locationQuery.GetCountry("Australia"),
                                                                          "20" + (pCode < 10 ? "0" : "") + pCode);
                            var org = new Organisation
                            {
                                Id = orgId, Name = orgName, Address = new Address {
                                    Location = location
                                }
                            };
                            _organisationsCommand.CreateOrganisation(org);
                            var employer = _employerAccountsCommand.CreateTestEmployer(i, org);
                            var jobAd    = employer.CreateTestJobAd(orgName + " test job ads", "test suggest job content, test long text, test ellipsis. test suggest job content, test long text, test ellipsis. test suggest job content, test long text, test ellipsis. test suggest job content, test long text, test ellipsis.", _industriesQuery.GetIndustries()[(int)(new Random(i).NextDouble() * 28)], location);
                            var count    = (int)(new Random(i).NextDouble() * 5);
                            var jobTypes = new List <JobTypes>();
                            for (var j = 0; j < count; j++)
                            {
                                jobTypes.Add(new List <JobTypes> {
                                    JobTypes.FullTime, JobTypes.PartTime, JobTypes.Contract, JobTypes.Temp, JobTypes.JobShare
                                }[(int)(new Random(i + j).NextDouble() * 5)]);
                            }
                            var jobType = JobTypes.None;
                            foreach (var jt in jobTypes)
                            {
                                jobType |= jt;
                            }
                            Salary salary;
                            if (i % 2 == 0)
                            {
                                salary = new Salary
                                {
                                    LowerBound = (int)(new Random(i).NextDouble() * 25) * 5000,
                                    UpperBound = (int)((1 - new Random(i + 1).NextDouble()) * 50) * 5000,
                                    Rate       = SalaryRate.Year,
                                    Currency   = Currency.AUD
                                }
                            }
                            ;
                            else
                            {
                                salary = new Salary
                                {
                                    LowerBound = (int)(new Random(i).NextDouble() * 25) * 5,
                                    UpperBound = (int)((1 - new Random(i + 1).NextDouble()) * 50) * 5,
                                    Rate       = SalaryRate.Hour,
                                    Currency   = Currency.AUD
                                }
                            };
                            jobAd.Description.Salary           = salary;
                            jobAd.Description.JobTypes         = jobType;
                            jobAd.Integration.IntegratorUserId = integratorUserId[(int)(new Random(i).NextDouble() * 3)];
                            jobAd.Integration.ExternalApplyUrl = (jobAd.Integration.IntegratorUserId == null ? string.Empty : "http://jobview.careerone.com.au/GetJob.aspx?JobID=103216325&WT.mc_n=AFC_linkme");
                            jobAd.CreatedTime  = DateTime.Now.AddHours(0 - new Random(i).NextDouble() * 100);
                            jobAd.FeatureBoost = (i % 2 == 0) ? JobAdFeatureBoost.Low : JobAdFeatureBoost.None;
                            _jobAdsCommand.PostJobAd(jobAd);
                        }
                        catch (FormatException)
                        {
                        }
                    }
                    i++;
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("Failed to process CSS file '" + cssFile + "'.", ex);
                }
            }
            //add a default jobad (without custom stylesheet)
            var anotherOrg = new Organisation
            {
                Id      = new Guid(),
                Name    = "LinkMe",
                Address = new Address
                {
                    Location = _locationQuery.ResolveLocation(_locationQuery.GetCountry("Australia"),
                                                              "Neutral Bay NSW 2089")
                }
            };

            _organisationsCommand.CreateOrganisation(anotherOrg);
            var anotherEmployer = _employerAccountsCommand.CreateTestEmployer(i, anotherOrg);
            var anotherJobAd    = anotherEmployer.CreateTestJobAd("LinkMe test job ads",
                                                                  "test suggest job content, test long text, test ellipsis. test suggest job content, test long text, test ellipsis. test suggest job content, test long text, test ellipsis. test suggest job content, test long text, test ellipsis.",
                                                                  _industriesQuery.GetIndustries()[(int)(new Random(i).NextDouble() * 28)], _locationQuery.ResolveLocation(_locationQuery.GetCountry("Australia"),
                                                                                                                                                                           "Neutral Bay NSW 2089"));

            anotherJobAd.Integration.IntegratorUserId = integratorUserId[1]; //Career One
            anotherJobAd.Integration.ExternalApplyUrl = "http://jobview.careerone.com.au/GetJob.aspx?JobID=103216325&WT.mc_n=AFC_linkme";
            _jobAdsCommand.PostJobAd(anotherJobAd);
            anotherJobAd = anotherEmployer.CreateTestJobAd("LinkMe test job ads - non CareerOne",
                                                           "test suggest job content, test long text, test ellipsis. test suggest job content, test long text, test ellipsis. test suggest job content, test long text, test ellipsis. test suggest job content, test long text, test ellipsis.",
                                                           _industriesQuery.GetIndustries()[(int)(new Random(i).NextDouble() * 28)], _locationQuery.ResolveLocation(_locationQuery.GetCountry("Australia"),
                                                                                                                                                                    "Neutral Bay NSW 2089"));
            _jobAdsCommand.PostJobAd(anotherJobAd);
        }
Exemplo n.º 29
0
        private void AddLogo(JobAd jobAd)
        {
            var filePath = FileSystem.GetAbsolutePath(@"Test\Data\Photos\ProfilePhoto.jpg", RuntimeEnvironment.GetSourceFolder());

            using (var stream = new MemoryStream())
            {
                using (var writer = new BinaryWriter(stream))
                {
                    // Load the contents from the file.

                    using (var reader = new BinaryReader(File.OpenRead(filePath)))
                    {
                        var count  = 4096;
                        var buffer = new byte[count];
                        while ((count = reader.Read(buffer, 0, count)) > 0)
                        {
                            writer.Write(buffer, 0, count);
                        }
                    }

                    stream.Position = 0;
                    var fileReference = _filesCommand.SaveFile(FileType.CompanyLogo, new StreamFileContents(stream), Path.GetFileName(filePath));

                    jobAd.LogoId = fileReference.Id;
                    _jobAdsCommand.UpdateJobAd(jobAd);
                }
            }
        }
Exemplo n.º 30
0
        private static void Save(TestResume resume)
        {
            var data     = resume.GetData();
            var filePath = FileSystem.GetAbsolutePath(@"Test\Data\Resumes\" + resume.FileName, RuntimeEnvironment.GetSourceFolder());

            using (var stream = new MemoryStream(data))
            {
                stream.Position = 0;
                using (var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    StreamUtil.CopyStream(stream, fileStream);
                }
            }
        }