Ejemplo n.º 1
0
        private void UploadResume(TestResume resume)
        {
            Guid fileReferenceId;

            // Upload the file.

            const string fileName = "Resume.doc";

            using (var tempFiles = _filesCommand.SaveTempFile(resume.GetData(), fileName))
            {
                var files = new NameValueCollection {
                    { "file", tempFiles.FilePaths[0] }
                };
                fileReferenceId = new JavaScriptSerializer().Deserialize <JsonResumeModel>(Post(_uploadUrl, null, files)).Id;
            }

            // Parse the file.

            var parsedResumeId = new JavaScriptSerializer().Deserialize <JsonParsedResumeModel>(Post(_parseUrl, new NameValueCollection {
                { "fileReferenceId", fileReferenceId.ToString() }
            })).Id.Value;

            // Submit the form.

            Get(_joinUrl);

            Browser.SetFormVariable(_joinFormId, "fileReferenceId", fileReferenceId.ToString(), false);
            Browser.SetFormVariable(_joinFormId, "parsedResumeId", parsedResumeId.ToString(), false);
            Browser.Submit(_joinFormId);
        }
Ejemplo n.º 2
0
 private Guid Upload(TestResume resume, string fileName)
 {
     using (var files = _filesCommand.SaveTempFile(resume.GetData(), fileName))
     {
         var path = files.FilePaths[0];
         return(Upload(path));
     }
 }
Ejemplo n.º 3
0
        private FileReference GetResumeFile(TestResume testResume)
        {
            const string fileName = "resume.doc";
            var          data     = testResume.GetData();

            using (var stream = new MemoryStream(data))
            {
                return(_filesCommand.SaveFile(FileType.Resume, new StreamFileContents(stream), fileName));
            }
        }
Ejemplo n.º 4
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);
                }
            }
        }
Ejemplo n.º 5
0
        private void AssertFile(Stream stream, TestResume testResume)
        {
            Assert.AreEqual("application/msword", GetContentType());

            var contents = new byte[0];

            using (var reader = new BinaryReader(stream))
            {
                var buffer = new byte[1024];
                var read   = reader.Read(buffer, 0, 1024);
                while (read != 0)
                {
                    contents = contents.Concat(buffer.Take(read)).ToArray();
                    read     = reader.Read(buffer, 0, 1024);
                }
            }

            // Check got resume file.

            Assert.IsTrue(testResume.GetData().SequenceEqual(contents));
        }