Ejemplo n.º 1
0
        private void SortMb <T>(int totalSize, int blockSize, bool ascending)
            where T : class, IComparable <T>
        {
            using (var temp = new TempFileFactory())
                using (var temp2 = new TempFileFactory())
                    using (var temp3 = new TempFileFactory()) {
                        if (typeof(T) == typeof(OrdersTab))
                        {
                            CreateTempFile(totalSize, temp, ascending);
                        }
                        else
                        {
                            CreateTempFileHeaderFooter(totalSize, temp, ascending);
                        }

                        var sorter = new BigFileSorter(blockSize);
                        sorter.Sort(temp, temp2);

                        var sorter2 = new BigFileSorter <T>(blockSize);
                        sorter2.Sort(temp, temp3);

                        if (!ascending)
                        {
                            ReverseFile(temp);
                        }

                        AssertSameFile(temp, temp2);
                        AssertSameFile(temp, temp3);
                    }
        }
Ejemplo n.º 2
0
        public void TestDosFile()
        {
            var testdata = new SimpleData() {
                Record = "one record only"
            };

            var engine = new DelimitedFileEngine<SimpleData>();
            using (var filename = new TempFileFactory()) {
                String twoRecords = testdata.Record + StringHelper.NewLine + testdata.Record + StringHelper.NewLine;

                ProcessAppend(testdata, engine, filename, twoRecords, "\r\n\r\n", "Dos");
                ProcessAppend(testdata, engine, filename, twoRecords, "\n\n\n", "Unix");
                ProcessAppend(testdata, engine, filename, twoRecords, "\r\r\r", "Macintosh");

                GC.Collect(); //  Clean up the loose file stream from the testing
            }
        }
Ejemplo n.º 3
0
        public void TestDosFile()
        {
            var testdata = new SimpleData {
                Record = "one record only"
            };

            var engine = new DelimitedFileEngine <SimpleData>();

            using (var filename = new TempFileFactory()) {
                string twoRecords = testdata.Record + Environment.NewLine + testdata.Record + Environment.NewLine;

                ProcessAppend(testdata, engine, filename, twoRecords, "\r\n\r\n");
                ProcessAppend(testdata, engine, filename, twoRecords, "\n\n\n");
                ProcessAppend(testdata, engine, filename, twoRecords, "\r\r\r");

                GC.Collect(); //  Clean up the loose file stream from the testing
            }
        }
        public void TestDosFile()
        {
            SimpleData testdata = new SimpleData()
            {
                Record = "one record only"
            };

            var engine = new DelimitedFileEngine <SimpleData>();

            using (var filename = new TempFileFactory())
            {
                String twoRecords = testdata.Record + StringHelper.NewLine + testdata.Record + StringHelper.NewLine;

                ProcessAppend(testdata, engine, filename, twoRecords, "\r\n\r\n", "Dos");
                ProcessAppend(testdata, engine, filename, twoRecords, "\n\n\n", "Unix");
                ProcessAppend(testdata, engine, filename, twoRecords, "\r\r\r", "Macintosh");

                GC.Collect();  //  Clean up the loose file stream from the testing
            }
        }
Ejemplo n.º 5
0
        public void EnumNumeric()
        {
            var engine = new FileHelperEngine <EnumType5>();

            using (var temp = new TempFileFactory())
            {
                EnumType5[] data = new EnumType5[] { new EnumType5()
                                                     {
                                                         EnumValue = Enum2.One
                                                     } };

                //write data to file using approprppriate conversion style
                engine.WriteFile(temp.FileName, data);

                //read data back
                data = engine.ReadFile(temp.FileName);

                Assert.IsAssignableFrom(typeof(EnumType5), data[0]);
                Assert.AreEqual(data[0].EnumValue, Enum2.One);
            }
        }
Ejemplo n.º 6
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            ADConfigurationObject config = null;
            string parameterSetName;

            if ((parameterSetName = base.ParameterSetName) != null)
            {
                if (parameterSetName == "UploadDialPlanPrompts" || parameterSetName == "UploadDialPlanPromptsStream")
                {
                    config = this.DataObject;
                    goto IL_7D;
                }
                if (parameterSetName == "UploadAutoAttendantPrompts" || parameterSetName == "UploadAutoAttendantPromptsStream")
                {
                    config = base.AutoAttendant;
                    goto IL_7D;
                }
            }
            ExAssert.RetailAssert(false, "Invalid parameter set {0}", new object[]
            {
                base.ParameterSetName
            });
            try
            {
IL_7D:
                ITempFile tempFile = null;
                string extension = Path.GetExtension(this.PromptFileName);
                if (string.Equals(extension, ".wav", StringComparison.OrdinalIgnoreCase))
                {
                    tempFile = TempFileFactory.CreateTempWavFile();
                }
                else
                {
                    if (!string.Equals(extension, ".wma", StringComparison.OrdinalIgnoreCase))
                    {
                        throw new InvalidFileNameException(128);
                    }
                    tempFile = TempFileFactory.CreateTempWmaFile();
                }
                using (tempFile)
                {
                    using (FileStream fileStream = new FileStream(tempFile.FilePath, FileMode.Create, FileAccess.Write))
                    {
                        if (this.PromptFileData != null)
                        {
                            fileStream.Write(this.PromptFileData, 0, this.PromptFileData.Length);
                        }
                        else
                        {
                            CommonUtil.CopyStream(this.PromptFileStream, fileStream);
                        }
                    }
                    using (IPublishingSession publishingSession = PublishingPoint.GetPublishingSession(Environment.UserName, config))
                    {
                        publishingSession.Upload(tempFile.FilePath, this.PromptFileName);
                    }
                }
            }
            catch (UnsupportedCustomGreetingSizeFormatException)
            {
                this.HandleOversizeAudioData();
            }
            catch (LocalizedException exception)
            {
                base.WriteError(exception, (ErrorCategory)1000, null);
            }
            catch (SystemException ex)
            {
                if (!this.HandleException(ex))
                {
                    throw;
                }
                base.WriteError(ex, (ErrorCategory)1000, null);
            }
            TaskLogger.LogExit();
        }