public void UpdateFile() { m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder); m_Index.DeleteIndex(); m_Index.Activate(); DateTime creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc); DateTime modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc); StackHashProduct product1 = new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293"); StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, 20, creationDateTime, "File1.dll", "2.3.4.5"); m_Index.AddProduct(product1); m_Index.AddFile(product1, file1); StackHashFile dbFile1 = m_Index.GetFile(product1, file1.Id); Assert.AreEqual(0, file1.CompareTo(dbFile1)); StackHashFile file2 = new StackHashFile(creationDateTime.AddDays(1), modifiedDateTime.AddDays(2), 20, creationDateTime.AddDays(3), "File2.dll", "1.3.4.5"); m_Index.AddFile(product1, file2); StackHashFile dbFile2 = m_Index.GetFile(product1, file2.Id); Assert.AreEqual(0, file2.CompareTo(dbFile2)); Assert.AreNotEqual(0, file1.CompareTo(dbFile2)); }
public void GetFilesForProduct2FilesOnly1ForSelectedProduct() { m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder); m_Index.DeleteIndex(); m_Index.Activate(); DateTime creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc); DateTime modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc); StackHashProduct product1 = new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293"); StackHashProduct product2 = new StackHashProduct(creationDateTime, modifiedDateTime, null, 2, "TestProduct1", 21, 31, "2.10.02123.1293"); StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, 20, creationDateTime, "File1.dll", "2.3.4.5"); StackHashFile file2 = new StackHashFile(creationDateTime, modifiedDateTime, 21, creationDateTime, "File2.dll", "2.3.4.5"); m_Index.AddProduct(product1); m_Index.AddProduct(product2); m_Index.AddFile(product1, file1); m_Index.AddFile(product2, file2); StackHashFileCollection files = m_Index.LoadFileList(product1); Assert.AreNotEqual(null, files); Assert.AreEqual(1, files.Count); Assert.AreEqual(0, file1.CompareTo(files[0])); files = m_Index.LoadFileList(product2); Assert.AreNotEqual(null, files); Assert.AreEqual(1, files.Count); Assert.AreEqual(0, file2.CompareTo(files[0])); }
public void FileExistsForDifferentProduct() { m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder); m_Index.DeleteIndex(); m_Index.Activate(); DateTime creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc); DateTime modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc); StackHashProduct product1 = new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293"); StackHashProduct product2 = new StackHashProduct(creationDateTime, modifiedDateTime, null, 2, "TestProduct1", 21, 31, "2.10.02123.1293"); StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, 20, creationDateTime, "File1.dll", "2.3.4.5"); m_Index.AddProduct(product1); m_Index.AddProduct(product2); m_Index.AddFile(product1, file1); StackHashFile dbFile1 = m_Index.GetFile(product1, file1.Id); Assert.AreEqual(0, file1.CompareTo(dbFile1)); Assert.AreEqual(true, m_Index.FileExists(product1, file1)); Assert.AreEqual(false, m_Index.FileExists(product2, file1)); }
private void checkIndexData(IErrorIndex index) { int numProducts = 100; int cabId = 12345678; int fileId = 2000; int eventId = 1000; for (int productCount = 0; productCount < numProducts; productCount++) { StackHashProduct retrievedProduct = index.GetProduct(productCount + 10); DateTime creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc); DateTime modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc); StackHashProduct product1 = new StackHashProduct(creationDateTime, modifiedDateTime, null, (productCount + 10), "TestProduct1", 20, 30, "2.10.02123.1293"); Assert.AreEqual(0, product1.CompareTo(retrievedProduct)); StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, fileId++, creationDateTime, "FileName", "1.2.3.4"); StackHashFile retrievedFile = index.GetFile(product1, file1.Id); Assert.AreEqual(0, file1.CompareTo(retrievedFile)); StackHashEventSignature eventSignature = new StackHashEventSignature(); eventSignature.Parameters = new StackHashParameterCollection(); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationName, "AppName")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationVersion, "1.2.3.4")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationTimeStamp, creationDateTime.ToString())); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleName, "ModuleName")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleVersion, "2.3.4.5")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleTimeStamp, creationDateTime.ToString())); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamExceptionCode, "1234")); eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamOffset, "0x1234")); eventSignature.InterpretParameters(); StackHashEvent thisEvent = new StackHashEvent(creationDateTime, modifiedDateTime, "CLR20", eventId++, eventSignature, 1, file1.Id); StackHashEvent retrievedEvent = index.GetEvent(product1, file1, thisEvent); Assert.AreEqual(0, thisEvent.CompareTo(retrievedEvent)); StackHashCab cab = new StackHashCab(creationDateTime, modifiedDateTime, thisEvent.Id, thisEvent.EventTypeName, "cab12345_23232.cab", cabId++, 12000); cab.DumpAnalysis = new StackHashDumpAnalysis("2 days, 5 hours, 2 mins", "1 hour, 2 mins", "2.120.222.1121212", "Microsoft Windows Vista X64 6.0.212121212 (Build 2500)", "64 bit windows"); cab.CabDownloaded = true; StackHashCab retrievedCab = index.GetCab(product1, file1, thisEvent, cab.Id); Assert.AreEqual(0, cab.CompareTo(retrievedCab)); String cabFolder = index.GetCabFolder(product1, file1, thisEvent, cab); String cabFileName = index.GetCabFileName(product1, file1, thisEvent, cab); Assert.AreEqual(true, Directory.Exists(cabFolder)); Assert.AreEqual(true, File.Exists(cabFileName)); } }