public void WithoutMap() { var headerCrator = new HeaderCreator(); Header header = headerCrator.Create(HuffmanEncodeModel.Standard, false, new Dictionary <string, HuffmanCoder.Logic.Entities.OutputValues>()); // Expected: header size - 4 bytes, huffmanEncodeModel - 1 byte, specialSymbol - 1 byte Assert.AreEqual(6, header.Content.Length); }
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); } }
public void OneDoubleSymbolInMap() { var headerCrator = new HeaderCreator(); var map = new Dictionary <string, HuffmanCoder.Logic.Entities.OutputValues>(); map.Add("AA", new HuffmanCoder.Logic.Entities.OutputValues { Counts = 5 }); Header header = headerCrator.Create(HuffmanEncodeModel.Block, false, map); // Expected: header size - 4 bytes, huffmanEncodeModel - 1 byte, specialSymbol - 1 byte, map (AA5) - 4 bytes Assert.AreEqual(10, header.Content.Length); }
public void TwoSymbolsInMap() { var headerCrator = new HeaderCreator(); var map = new Dictionary <string, HuffmanCoder.Logic.Entities.OutputValues>(); map.Add("A", new HuffmanCoder.Logic.Entities.OutputValues { Counts = 5 }); map.Add("B", new HuffmanCoder.Logic.Entities.OutputValues { Counts = 3 }); Header header = headerCrator.Create(HuffmanEncodeModel.Standard, false, map); // Expected: header size - 4 bytes, huffmanEncodeModel - 1 byte, specialSymbol - 1 byte, map (A5B3) - 6 bytes Assert.AreEqual(12, header.Content.Length); }
public void SingleSymbolInMarkovModel() { var headerCrator = new HeaderCreator(); var map = new Dictionary <string, HuffmanCoder.Logic.Entities.OutputValues>(); map.Add("A", new HuffmanCoder.Logic.Entities.OutputValues { Counts = 5 }); map.Add("BC", new HuffmanCoder.Logic.Entities.OutputValues { Counts = 5 }); Header header = headerCrator.Create(HuffmanEncodeModel.Markov, true, map); // Expected: header size - 4 bytes, huffmanEncodeModel - 1 byte, specialSymbol - 1 byte, map (A5BC5) - 8 bytes Assert.AreEqual(13, header.Content.Length); }