예제 #1
0
        /// <summary>
        /// Builds a FastCgi Request whose communication medium is a socket.
        /// The supplied <paramref name="recordFactory"/> is used to build the records that represent the incoming data.
        /// </summary>
        /// <param name="recordFactory">
        /// The factory used to create records. This object's life cycle is controlled by this request.
        /// That means that when this request is disposed, so will this record factory be.
        /// </param>
        public SocketRequest(Socket s, RecordFactory recordFactory)
            : base(recordFactory)
        {
            if (s == null)
            {
                throw new ArgumentNullException("s");
            }

            this.Socket = s;
        }
예제 #2
0
        private void LoadRecords(XPathNavigator xml)
        {
            var recordNodes = xml.Select("/qdbapi/table/records/record");

            foreach (XPathNavigator recordNode in recordNodes)
            {
                var record = RecordFactory.CreateInstance(Application, this, Columns, recordNode);
                Records.Add(record);
            }
        }
예제 #3
0
        public void Create_CreateRecordFuncThrowsException_ExceptionIsPropogated()
        {
            var source       = new object();
            var record       = new object();
            var createRecord = new Func <object, object, object>((src, rt) => throw new InternalTestFailureException());

            var recordFactory = new RecordFactory(createRecord);

            recordFactory.Create(source);
        }
        public RecordFactoryAndRequest(RecordFactory reader, Socket sock, Fos.Logging.IServerLogger logger)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");
            else if (sock == null)
                throw new ArgumentNullException("sock");

            RecordFactory = reader;
            FosRequest = new FosRequest(sock, logger);
        }
예제 #5
0
        /// <summary>
        /// Searches all of the /data/*.dat files in content.ggpk for user strings that can be translated. Also fills
        /// out 'fileRecordMap' with valid datName -> FileRecord mappings.
        /// </summary>
        private void CollectTranslatableStrings()
        {
            AllDatTranslations = new Dictionary <string, DatTranslation>();
            fileRecordMap      = new Dictionary <string, FileRecord>();

            foreach (var recordOffset in content.RecordOffsets)
            {
                var record = recordOffset.Value as FileRecord;

                if (record == null || record.ContainingDirectory == null || record.DataLength == 12 || Path.GetExtension(record.Name) != ".dat")
                {
                    continue;
                }

                // Make sure parser for .dat type actually exists
                if (!RecordFactory.HasRecordInfo(record.Name))
                {
                    continue;
                }

                if (record.ContainingDirectory.Name != "Data")
                {
                    continue;
                }

                // We'll need this .dat FileRecord later on so we're storing it in a map of fileName -> FileRecord
                fileRecordMap.Add(record.Name, record);

                List <string> translatableStrings;

                try
                {
                    translatableStrings = GetTranslatableStringsFromDatFile(record);
                }
                catch (Exception ex)
                {
                    OutputLine(string.Format(Settings.Strings["CollectTranslatableStrings_FailedReading"], record.Name, ex.Message));
                    continue;
                }

                var newDatTranslation = new DatTranslation();
                newDatTranslation.DatName      = record.Name;
                newDatTranslation.Translations = new List <Translation>();

                foreach (var str in translatableStrings)
                {
                    newDatTranslation.Translations.Add(new Translation(str));
                }

                if (translatableStrings.Count > 0)
                {
                    AllDatTranslations.Add(record.Name, newDatTranslation);
                }
            }
        }
예제 #6
0
        public MockApp(string user, long clusterTimeStamp, int uniqId)
            : base()
        {
            this.user = user;
            // Add an application and the corresponding containers
            RecordFactory recordFactory = RecordFactoryProvider.GetRecordFactory(new Configuration
                                                                                     ());

            this.appId = BuilderUtils.NewApplicationId(recordFactory, clusterTimeStamp, uniqId
                                                       );
            appState = ApplicationState.New;
        }
예제 #7
0
        public void Create_RecordTypeProviderIsNotProvided_RecordIsCreated()
        {
            var source       = new object();
            var record       = new object();
            var createRecord = new Func <object, object, object>((src, rt) => src.Equals(source) ? record : null);

            var recordFactory = new RecordFactory(createRecord);

            var returnedRecord = recordFactory.Create(source);

            Assert.AreEqual(record, returnedRecord);
        }
예제 #8
0
        private async void BTNCreteDBTable_Click(object sender, RoutedEventArgs e)
        {
            HeaderCreator headerCreator = new HeaderCreator(filePath);

            HeaderLV.Items.Clear();
            List <string> header = headerCreator.CreateHeader();

            foreach (string line in header)
            {
                HeaderLV.Items.Add(line);
            }
            try
            {
                string        connectionString = DBConnectionString.Text;
                RecordFactory creator          = new RecordFactory(filePath);

                CreateTableInDB tableCreator = new CreateTableInDB(connectionString);
                await tableCreator.CreateTable(@"If not exists (select name from sysobjects where name = 'Precipitation') CREATE TABLE Precipitation (Xref int, Yref int, Date date, Value int);");

                var ATimer = new System.Windows.Threading.DispatcherTimer();
                ATimer.Tick    += ATimer_Tick;
                ATimer.Interval = new TimeSpan(0, 0, 0, 1);
                ATimer.Start();

                InsertRecordToDBTable recordInsert = new InsertRecordToDBTable(connectionString);
                while (creator.EndOfFile == false)
                {
                    await recordInsert.InsertRecordToTable(creator.GetNextRecord());
                }
                ATimer.Stop();
                MessageBox.Show("Finished adding records to DB.");
                recordInsert.CloseConnection();

                GetDataFromTable getData = new GetDataFromTable(connectionString);
                await getData.GetData("SELECT * FROM Precipitation ORDER BY Xref, Yref, Date ASC");

                while (getData.reader.Read())
                {
                    var data = new Record((int)getData.reader["Xref"], (int)getData.reader["Yref"], (DateTime)getData.reader["Date"], (int)getData.reader["Value"]);
                    GeneratedTable.Items.Add(data);
                }
                getData.CloseConnection();
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #9
0
        /// <summary>
        /// Builds a FastCgi Request that uses the supplied <paramref name="recordFactory"/> to build the records
        /// that represent the incoming data.
        /// </summary>
        /// <param name="recordFactory">
        /// The factory used to create records. This object's life cycle is controlled by this request.
        /// That means that when this request is disposed, so will this record factory be.
        /// </param>
        public FastCgiRequest(RecordFactory recordFactory)
        {
            if (recordFactory == null)
            {
                throw new ArgumentNullException("recordFactory");
            }

            RecordFactory        = recordFactory;
            BeginRequestSent     = false;
            BeginRequestReceived = false;
            EndRequestSent       = false;
            EndRequestReceived   = false;
        }
예제 #10
0
        public void TestNonZeroPadding_bug46987()
        {
            Record[] recs =
            {
                new BOFRecord(),
                new WriteAccessRecord(),             // need *something* between BOF and EOF
                EOFRecord.instance,
                BOFRecord.CreateSheetBOF(),
                EOFRecord.instance,
            };
            MemoryStream baos = new MemoryStream();

            for (int i = 0; i < recs.Length; i++)
            {
                byte[] data = recs[i].Serialize();
                baos.Write(data, 0, data.Length);
            }
            //simulate the bad padding at the end of the workbook stream in attachment 23483 of bug 46987
            baos.WriteByte(0x00);
            baos.WriteByte(0x11);
            baos.WriteByte(0x00);
            baos.WriteByte(0x02);
            for (int i = 0; i < 192; i++)
            {
                baos.WriteByte(0x00);
            }


            POIFSFileSystem fs = new POIFSFileSystem();
            Stream          is1;

            fs.CreateDocument(new MemoryStream(baos.ToArray()), "dummy");
            is1 = fs.Root.CreatePOIFSDocumentReader("dummy");


            List <Record> outRecs;

            try
            {
                outRecs = RecordFactory.CreateRecords(is1);
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Buffer underrun - requested 512 bytes but 192 was available"))
                {
                    throw new AssertionException("Identified bug 46987");
                }
                throw e;
            }
            Assert.AreEqual(5, outRecs.Count);
        }
예제 #11
0
        private TransformResult CreateRichStringRecord(RichTextInfo richTextInfo, CellRenderingDetails details)
        {
            StringWrapperBIFF8 stringWrapperBIFF = richTextInfo.CompleteRun();

            if (stringWrapperBIFF.Cch > 32767)
            {
                throw new ReportRenderingException(ExcelRenderRes.MaxStringLengthExceeded(details.Row.ToString(CultureInfo.InvariantCulture), details.Column.ToString(CultureInfo.InvariantCulture)));
            }
            int isst = this.m_stringHandler.AddString(stringWrapperBIFF);

            this.OnCellBegin(253, details.Column);
            RecordFactory.LABELSST(details.Output, (ushort)details.Row, (ushort)details.Column, details.Ixfe, (uint)isst);
            return(TransformResult.Handled);
        }
예제 #12
0
        public void Create_RecordTypeProviderThrowsException_ExceptionIsPropogated()
        {
            var source             = new object();
            var record             = new object();
            var recordType         = "RecordType";
            var createRecord       = new Func <object, object, object>((src, rt) => src.Equals(source) && rt.Equals(recordType) ? record : null);
            var recordTypeProvider = MockRepository.GenerateMock <IRecordTypeProvider>();

            recordTypeProvider.Stub(x => x.GetRecordType(Arg <object> .Is.Anything)).Throw(new InternalTestFailureException());

            var recordFactory = new RecordFactory(createRecord, recordTypeProvider);

            recordFactory.Create(source);
        }
예제 #13
0
        public RecordFactoryAndRequest(RecordFactory reader, Socket sock, Fos.Logging.IServerLogger logger)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            else if (sock == null)
            {
                throw new ArgumentNullException("sock");
            }

            RecordFactory = reader;
            FosRequest    = new FosRequest(sock, logger);
        }
예제 #14
0
        public static NodeStatus CreateNodeStatus(NodeId nodeId, IList <ContainerStatus> containers
                                                  )
        {
            RecordFactory recordFactory = RecordFactoryProvider.GetRecordFactory(null);
            NodeStatus    nodeStatus    = recordFactory.NewRecordInstance <NodeStatus>();

            nodeStatus.SetNodeId(nodeId);
            nodeStatus.SetContainersStatuses(containers);
            NodeHealthStatus nodeHealthStatus = recordFactory.NewRecordInstance <NodeHealthStatus
                                                                                 >();

            nodeHealthStatus.SetIsNodeHealthy(true);
            nodeStatus.SetNodeHealthStatus(nodeHealthStatus);
            return(nodeStatus);
        }
예제 #15
0
        public void TestMismatchedRowNumbers()
        {
            var recordFactory = new RecordFactory();

            var input = "5" + Environment.NewLine +
                        "VEST,001B,20120101,1000,0.45" + Environment.NewLine +
                        "VEST,002B,20130101,1000,0.50" + Environment.NewLine +
                        "VEST,001B,20130101,1500,0.50" + Environment.NewLine +
                        "VEST,003B,20130101,1000,0.50" + Environment.NewLine +
                        "20140101,1.00";

            var inputService = new InputReaderService(recordFactory);

            var result = inputService.ReadInput(input);
        }
예제 #16
0
        /// <exception cref="System.IO.IOException"/>
        public MockContainer(ApplicationAttemptId appAttemptId, Dispatcher dispatcher, Configuration
                             conf, string user, ApplicationId appId, int uniqId)
        {
            this.user          = user;
            this.recordFactory = RecordFactoryProvider.GetRecordFactory(conf);
            this.id            = BuilderUtils.NewContainerId(recordFactory, appId, appAttemptId, uniqId);
            this.launchContext = recordFactory.NewRecordInstance <ContainerLaunchContext>();
            long currentTime = Runtime.CurrentTimeMillis();

            this.containerTokenIdentifier = BuilderUtils.NewContainerTokenIdentifier(BuilderUtils
                                                                                     .NewContainerToken(id, "127.0.0.1", 1234, user, BuilderUtils.NewResource(1024, 1
                                                                                                                                                              ), currentTime + 10000, 123, Sharpen.Runtime.GetBytesForString("password"), currentTime
                                                                                                        ));
            this.state = ContainerState.New;
        }
예제 #17
0
        //getters and setters for UI Controls.



        private void InitialiseUIControls()

        {
            UIErrorHelper.CheckedExec(delegate()

            {
                RecordPanelDictionary = new Dictionary <RecordType, Panel>()
                {
                    { RecordType.VMDNS_RR_TYPE_A, ARecord },

                    { RecordType.VMDNS_RR_TYPE_AAAA, AAAARecord },

                    { RecordType.VMDNS_RR_TYPE_CNAME, CNameRecord },

                    { RecordType.VMDNS_RR_TYPE_NS, NSRecord },

                    { RecordType.VMDNS_RR_TYPE_PTR, PTRRecord },

                    { RecordType.VMDNS_RR_TYPE_SRV, SRVRecord },

                    { RecordType.VMDNS_RR_TYPE_SOA, SOARecord }
                };

                Panel panel = RecordPanelDictionary[recordType];

                panel.Visible = true;



                RecordFactory factory = new RecordFactory();

                recordObject = factory.GetRecord(recordType);

                recordObject.RecordPanel = panel;

                recordObject.AddRecordFrm = this;

                if (isViewMode && recordObject != null)

                {
                    recordObject.SetUIFieldsFromRecordData(Record);

                    AddButton.Visible = false;

                    recordObject.SetUIFieldsEditability(false);
                }
            });
        }
예제 #18
0
 /// <param name="resource">the local resource that contains the original remote path</param>
 /// <param name="localPath">
 /// the path in the local filesystem where the resource is
 /// localized
 /// </param>
 /// <param name="fs">the filesystem of the shared cache</param>
 /// <param name="localFs">the local filesystem</param>
 public SharedCacheUploader(LocalResource resource, Path localPath, string user, Configuration
                            conf, SCMUploaderProtocol scmClient, FileSystem fs, FileSystem localFs)
 {
     this.resource           = resource;
     this.localPath          = localPath;
     this.user               = user;
     this.conf               = conf;
     this.scmClient          = scmClient;
     this.fs                 = fs;
     this.sharedCacheRootDir = conf.Get(YarnConfiguration.SharedCacheRoot, YarnConfiguration
                                        .DefaultSharedCacheRoot);
     this.nestedLevel   = SharedCacheUtil.GetCacheDepth(conf);
     this.checksum      = SharedCacheChecksumFactory.GetChecksum(conf);
     this.localFs       = localFs;
     this.recordFactory = RecordFactoryProvider.GetRecordFactory(null);
 }
예제 #19
0
        public void SetRowProperties(int rowIndex, int heightIn20thPoints, byte rowOutlineLevel, bool collapsed, bool autoSize)
        {
            m_numRowsThisBlock++;
            int  num      = rowIndex - m_rowIndexStartOfBlock;
            long position = m_startOfBlock + num * 20;

            m_worksheetOut.BaseStream.Position = position;
            RecordFactory.ROW(m_worksheetOut, (ushort)rowIndex, m_worksheet.ColFirst, m_worksheet.ColLast, (ushort)heightIn20thPoints, rowOutlineLevel, collapsed, autoSize);
            m_worksheetOut.BaseStream.Seek(0L, SeekOrigin.End);
            m_worksheet.MaxRowOutline = Math.Max(m_worksheet.MaxRowOutline, rowOutlineLevel);
            FinishRow();
            if (m_numRowsThisBlock == 32)
            {
                CalcAndWriteDBCells();
            }
        }
예제 #20
0
        /// <summary>
        /// Reload XML file reread .dat file with new definitions
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void reload_XML_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                RecordFactory.UpdateRecordsInfo();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace, "XML Reload Failed",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            // reset .dat Viewer
            Reset(FileName, _data);
        }
예제 #21
0
        public void BeginRequestRecordInBlocks()
        {
            var beginRec = new BeginRequestRecord(1);

            BeginRequestRecord builtRecord = null;

            var byteReader = new RecordFactory();

            foreach (var recData in beginRec.GetBytes())
            {
                builtRecord = (BeginRequestRecord)byteReader.Read(recData).SingleOrDefault();
            }

            Assert.AreNotEqual(null, builtRecord);
            Assert.AreEqual(beginRec, builtRecord);
        }
        private static TaskAttemptCompletionEvent CreateTce(int eventId, bool isMap, TaskAttemptCompletionEventStatus
                                                            status)
        {
            JobId  jid = MRBuilderUtils.NewJobId(12345, 1, 1);
            TaskId tid = MRBuilderUtils.NewTaskId(jid, 0, isMap ? TaskType.Map : TaskType.Reduce
                                                  );
            TaskAttemptId attemptId        = MRBuilderUtils.NewTaskAttemptId(tid, 0);
            RecordFactory recordFactory    = RecordFactoryProvider.GetRecordFactory(null);
            TaskAttemptCompletionEvent tce = recordFactory.NewRecordInstance <TaskAttemptCompletionEvent
                                                                              >();

            tce.SetEventId(eventId);
            tce.SetAttemptId(attemptId);
            tce.SetStatus(status);
            return(tce);
        }
예제 #23
0
        /**
         * Create an array of records from an input stream
         *
         * @param in the InputStream from which the records will be
         *           obtained
         *
         * @exception RecordFormatException on error Processing the
         *            InputStream
         */
        public void ProcessRecords(Stream in1)
        {
            Record last_record = null;

            RecordInputStream recStream = new RecordInputStream(in1);

            while (recStream.HasNextRecord)
            {
                recStream.NextRecord();
                Record[] recs = RecordFactory.CreateRecord(recStream);   // handle MulRK records
                if (recs.Length > 1)
                {
                    for (int k = 0; k < recs.Length; k++)
                    {
                        if (last_record != null)
                        {
                            if (!ProcessRecord(last_record))
                            {
                                return;
                            }
                        }
                        last_record = recs[k];   // do to keep the algorithm homogeneous...you can't
                    }                            // actually continue a number record anyhow.
                }
                else
                {
                    Record record = recs[0];

                    if (record != null)
                    {
                        if (last_record != null)
                        {
                            if (!ProcessRecord(last_record))
                            {
                                return;
                            }
                        }
                        last_record = record;
                    }
                }
            }

            if (last_record != null)
            {
                ProcessRecord(last_record);
            }
        }
예제 #24
0
        public virtual void TestPbRecordFactory()
        {
            RecordFactory pbRecordFactory = RecordFactoryPBImpl.Get();

            try
            {
                LocalizerHeartbeatResponse response = pbRecordFactory.NewRecordInstance <LocalizerHeartbeatResponse
                                                                                         >();
                NUnit.Framework.Assert.AreEqual(typeof(LocalizerHeartbeatResponsePBImpl), response
                                                .GetType());
            }
            catch (YarnRuntimeException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
                NUnit.Framework.Assert.Fail("Failed to crete record");
            }
        }
예제 #25
0
        /// <exception cref="System.Exception"/>
        private ContainerLocalizer SetupContainerLocalizerForTest()
        {
            // mocked generics
            // don't actually create dirs
            Org.Mockito.Mockito.DoNothing().When(spylfs).Mkdir(Matchers.IsA <Path>(), Matchers.IsA
                                                               <FsPermission>(), Matchers.AnyBoolean());
            Configuration conf = new Configuration();
            FileContext   lfs  = FileContext.GetFileContext(spylfs, conf);

            localDirs = new AList <Path>();
            for (int i = 0; i < 4; ++i)
            {
                localDirs.AddItem(lfs.MakeQualified(new Path(basedir, i + string.Empty)));
            }
            RecordFactory      mockRF      = GetMockLocalizerRecordFactory();
            ContainerLocalizer concreteLoc = new ContainerLocalizer(lfs, appUser, appId, containerId
                                                                    , localDirs, mockRF);
            ContainerLocalizer localizer = Org.Mockito.Mockito.Spy(concreteLoc);

            // return credential stream instead of opening local file
            random = new Random();
            long seed = random.NextLong();

            System.Console.Out.WriteLine("SEED: " + seed);
            random.SetSeed(seed);
            DataInputBuffer appTokens = CreateFakeCredentials(random, 10);

            tokenPath = lfs.MakeQualified(new Path(string.Format(ContainerLocalizer.TokenFileNameFmt
                                                                 , containerId)));
            Org.Mockito.Mockito.DoReturn(new FSDataInputStream(new FakeFSDataInputStream(appTokens
                                                                                         ))).When(spylfs).Open(tokenPath);
            nmProxy = Org.Mockito.Mockito.Mock <LocalizationProtocol>();
            Org.Mockito.Mockito.DoReturn(nmProxy).When(localizer).GetProxy(nmAddr);
            Org.Mockito.Mockito.DoNothing().When(localizer).Sleep(Matchers.AnyInt());
            // return result instantly for deterministic test
            ExecutorService          syncExec = Org.Mockito.Mockito.Mock <ExecutorService>();
            CompletionService <Path> cs       = Org.Mockito.Mockito.Mock <CompletionService>();

            Org.Mockito.Mockito.When(cs.Submit(Matchers.IsA <Callable>())).ThenAnswer(new _Answer_279
                                                                                          ());
            Org.Mockito.Mockito.DoReturn(syncExec).When(localizer).CreateDownloadThreadPool();
            Org.Mockito.Mockito.DoReturn(cs).When(localizer).CreateCompletionService(syncExec
                                                                                     );
            return(localizer);
        }
예제 #26
0
        public void TestCreateRecord()
        {
            BOFRecord bof = new BOFRecord();

            bof.Build           = ((short)0);
            bof.BuildYear       = ((short)1999);
            bof.RequiredVersion = (123);
            bof.Type            = (BOFRecord.TYPE_WORKBOOK);
            bof.Version         = ((short)0x06);
            bof.HistoryBitMask  = (BOFRecord.HISTORY_MASK);

            byte[] bytes = bof.Serialize();

            Record[] records = RecordFactory.CreateRecord(TestcaseRecordInputStream.Create(bytes));

            Assert.IsTrue(records.Length == 1, "record.Length must be 1, was =" + records.Length);
            Assert.IsTrue(CompareRec(bof, records[0]), "record is the same");
        }
예제 #27
0
 public void AddRow(int rowIndex)
 {
     if (m_startOfBlock == -1)
     {
         m_startOfBlock         = m_worksheetOut.BaseStream.Position;
         m_startOfFirstCellData = -20L;
         m_rowIndexStartOfBlock = rowIndex;
     }
     if (m_worksheet.RowFirst > rowIndex)
     {
         m_worksheet.RowFirst = (ushort)rowIndex;
     }
     if (m_worksheet.RowLast < rowIndex)
     {
         m_worksheet.RowLast = (ushort)rowIndex;
     }
     m_startOfFirstCellData += RecordFactory.ROW(m_worksheetOut, (ushort)rowIndex, m_worksheet.ColFirst, m_worksheet.ColLast, 0, 0, collapsed: false, autoSize: false);
 }
        public void TestUnexpectedBytes_bug47251()
        {
            string hex = "" +
                         "09 08 10 00 00 06 05 00 EC 15 CD 07 C1 C0 00 00 06 03 00 00 " + //BOF
                         "E2 00 02 00 B0 04 " +                                           //INTERFACEEND with extra two bytes
                         "0A 00 00 00";                                                   // EOF

            byte[]        data    = HexRead.ReadFromString(hex);
            List <Record> records = RecordFactory.CreateRecords(new MemoryStream(data));

            Assert.AreEqual(3, records.Count);
            Record rec1 = records[(1)];

            Assert.AreEqual(typeof(InterfaceHdrRecord), rec1.GetType());
            InterfaceHdrRecord r = (InterfaceHdrRecord)rec1;

            Assert.AreEqual("[E1, 00, 02, 00, B0, 04]", HexDump.ToHex(r.Serialize()));
        }
예제 #29
0
        public void Create_RecordTypeProviderIsProvided_RecordIsCreated()
        {
            var source             = new object();
            var record             = new object();
            var recordType         = "RecordType";
            var createRecord       = new Func <object, object, object>((src, rt) => src.Equals(source) && rt.Equals(recordType) ? record : null);
            var recordTypeProvider = MockRepository.GenerateMock <IRecordTypeProvider>();

            recordTypeProvider.Expect(x => x.GetRecordType(Arg <object> .Is.Equal(source))).Return(recordType).Repeat.Once();

            var recordFactory = new RecordFactory(createRecord, recordTypeProvider);

            var returnedRecord = recordFactory.Create(source);

            recordTypeProvider.VerifyAllExpectations();

            Assert.AreEqual(record, returnedRecord);
        }
 public void AddRow(int rowIndex)
 {
     if (this.m_startOfBlock == -1)
     {
         this.m_startOfBlock         = this.m_worksheetOut.BaseStream.Position;
         this.m_startOfFirstCellData = -20L;
         this.m_rowIndexStartOfBlock = rowIndex;
     }
     if (this.m_worksheet.RowFirst > rowIndex)
     {
         this.m_worksheet.RowFirst = (ushort)rowIndex;
     }
     if (this.m_worksheet.RowLast < rowIndex)
     {
         this.m_worksheet.RowLast = (ushort)rowIndex;
     }
     this.m_startOfFirstCellData += RecordFactory.ROW(this.m_worksheetOut, (ushort)rowIndex, this.m_worksheet.ColFirst, this.m_worksheet.ColLast, 0, 0, false, false);
 }
예제 #31
0
        public void CreateAndReadParamsWithManyParameters()
        {
            int numParams = 100;

            using (var paramsRec = new ParamsRecord(1))
            {
                using (var writer = new NvpWriter(paramsRec.Contents))
                {
                    for (int i = 0; i < numParams; ++i)
                    {
                        writer.Write("TEST" + i, "WHATEVER" + i);
                    }
                }

                var bytes  = paramsRec.GetBytes().ToList();
                var header = bytes[0];
                int endOfRecord;
                using (var receivedRec = (ParamsRecord)RecordFactory.CreateRecordFromHeader(header.Array, header.Offset, header.Count, out endOfRecord))
                {
                    Assert.AreEqual(paramsRec.ContentLength, receivedRec.ContentLength);
                    for (int i = 1; i < bytes.Count; ++i)
                    {
                        Assert.AreEqual(-1, endOfRecord);
                        receivedRec.FeedBytes(bytes[i].Array, bytes[i].Offset, bytes[i].Count, out endOfRecord);
                    }

                    int paramsCount = 0;
                    receivedRec.Contents.Position = 0;
                    using (var reader = new NvpReader(receivedRec.Contents))
                    {
                        NameValuePair par;
                        while ((par = reader.Read()) != null)
                        {
                            Assert.AreEqual("TEST" + paramsCount, par.Name);
                            Assert.AreEqual("WHATEVER" + paramsCount, par.Value);
                            paramsCount++;
                        }
                    }

                    Assert.AreEqual(numParams, paramsCount);
                }
            }
        }