public void GetCachedQueryTest() { AVRFacade facade; using (new StopwathTransaction("AVRFacade .ctor")) { facade = new AVRFacade(m_Container); } QueryTableHeaderDTO headerDTO; using (new StopwathTransaction("GetCachedQueryTableHeader")) { //fn_AVR_HumanCaseReport headerDTO = facade.GetCachedQueryTableHeader(49539640000000, "en", false); } var headerModel = new QueryTableHeaderModel(headerDTO); Assert.AreEqual(m_FieldCount, headerModel.ColumnCount); Assert.IsTrue(headerModel.ColumnTypeByName.Exists(c => c.Name == "sflHC_FinalDiagnosis")); Type stringType = headerModel.ColumnTypeByName.Find(c => c.Name == "sflHC_FinalDiagnosis").FinalType; Assert.AreEqual(typeof(string), stringType); Assert.IsTrue(headerModel.ColumnTypeByName.Exists(c => c.Name == "sflHC_FinalDiagnosisDate")); stringType = headerModel.ColumnTypeByName.Find(c => c.Name == "sflHC_FinalDiagnosisDate").FinalType; Assert.AreEqual(typeof(DateTime), stringType); for (int i = 0; i < headerDTO.PacketCount; i++) { QueryTablePacketDTO packetDTO; using (new StopwathTransaction("GetCachedQueryTablePacket " + i)) { packetDTO = facade.GetCachedQueryTablePacket(headerModel.QueryCacheId, i, headerDTO.PacketCount); } QueryTablePacketDTO unzipped; using (new StopwathTransaction(string.Format("-Unzip Packet #{0}", i))) { unzipped = BinaryCompressor.Unzip(packetDTO); } StreamTablePacketDTO unzippedStream; using (new StopwathTransaction(string.Format("-Unzip Packet #{0} into stream", i))) { unzippedStream = BinaryCompressor.UnzipStream(packetDTO); } AvrDataTable deserialized = new AvrDataTable(headerModel, 10240); using (new StopwathTransaction(string.Format("--Deserialize Packet #{0}", i))) { BinarySerializer.DeserializeBodyPacket(unzipped, headerModel.ColumnTypes, deserialized); } AvrDataTable deserializedStream = new AvrDataTable(headerModel, 10240); using (new StopwathTransaction(string.Format("--Deserialize Packet #{0} into stream", i))) { BinarySerializer.DeserializeBodyPacket(unzippedStream, headerModel.ColumnTypes, deserializedStream); } Assert.AreNotSame(deserialized, deserializedStream); Assert.AreEqual(deserialized.Count, deserializedStream.Count); Assert.AreEqual(deserialized.Columns.Count, deserializedStream.Columns.Count); int diagnosisIndex = headerModel.ColumnTypeByName .Select(c => c.Name) .TakeWhile(key => key != "sflHC_FinalDiagnosis") .Count(); bool found = false; for (int j = 0; j < deserialized.Count; j++) { var row = (AvrDataRowEx)deserialized[j]; var rowStream = (AvrDataRowEx)deserializedStream[j]; Assert.AreNotSame(row, rowStream); Assert.AreEqual(row.Count, rowStream.Count); for (int k = 0; k < row.Count; k++) { Assert.AreEqual(row[k], rowStream[k]); } if (row[diagnosisIndex].ToString() == "Smallpox") { found = true; } } Assert.IsTrue(found); } }