public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest2: Calling GetHashCode multiple times should return the same hash value"); try { byte[] bytes = new byte[c_SIZE_OF_ARRAY]; TestLibrary.Generator.GetBytes(-55, bytes); Guid guid = new Guid(bytes); int hashCode1 = guid.GetHashCode(); int hashCode2 = guid.GetHashCode(); if (hashCode1 != hashCode2) { TestLibrary.TestFramework.LogError("002.1", "Calling GetHashCode multiple times does not return the same hash value"); TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLES] hashCode1 = " + hashCode1 + ", hashCode2 = " + hashCode2); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return retVal; }
public BlockchainKey(Guid guid, UInt256 rootBlockHash) { this._guid = guid; this._rootBlockHash = rootBlockHash; this.hashCode = guid.GetHashCode() ^ rootBlockHash.GetHashCode(); }
public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest1: GetHashCode should return the same value for two equal instances"); try { byte[] bytes = new byte[c_SIZE_OF_ARRAY]; TestLibrary.Generator.GetBytes(-55, bytes); Guid guid1 = new Guid(bytes); Guid guid2 = new Guid(bytes); int hashCode1 = guid1.GetHashCode(); int hashCode2 = guid2.GetHashCode(); if (hashCode1 != hashCode2) { TestLibrary.TestFramework.LogError("001.1", "GetHashCode does not return the same value for two equal instances"); TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLES] hashCode1 = " + hashCode1 + ", hashCode2 = " + hashCode2); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return retVal; }
public void GivenAnImageObject_ThenItIsHashCodeIsEqualToItsId() { var id = new Guid(); var img = new Media {Id= id}; Assert.That(img.GetHashCode(), Is.EqualTo(id.GetHashCode())); }
public CPSProject( VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectDisplayName, string projectFilePath, IVsHierarchy hierarchy, string language, Guid projectGuid, string commandLineForOptions, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base(projectTracker, reportExternalErrorCreatorOpt, projectDisplayName, projectFilePath, hierarchy, language, projectGuid, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt) { // Initialize the options. SetCommandLineArguments(commandLineForOptions); // We need to ensure that the bin output path for the project has been initialized before we hookup the project with the project tracker. // If we were unable to set the output path from SetCommandLineArguments (due to null output file name or directory in the given commandLineForOptions), // we set a default unique output path. if (this.TryGetBinOutputPath() == null) { var uniqueDefaultOutputPath = PathUtilities.CombinePathsUnchecked(Path.GetTempPath(), projectDisplayName + projectGuid.GetHashCode().ToString()); SetOutputPathAndRelatedData(objOutputPath: uniqueDefaultOutputPath, hasSameBinAndObjOutputPaths: true); } Contract.ThrowIfNull(this.TryGetBinOutputPath()); // Now hook up the project to the project tracker. projectTracker.AddProject(this); _lastDesignTimeBuildSucceeded = true; }
public bool Test(Guid guid) { var hash1 = guid.GetHashCode(); var hash2 = Hash(guid); var bits = Enumerable.Range(1, hashCount) .Select(i => (uint)DoubleHashToBitNumber(hash1, hash2, i)) .Distinct(); return bits.All(bitSet.Contains); }
/// <summary> /// 获得一次初始向量用于加密 /// </summary> /// <param name="n">长度</param> /// <returns>初始向量字符串</returns> public static string getInitVector(int n) { StringBuilder buf = new StringBuilder(); var guid = new Guid(); Random rnd = new Random(guid.GetHashCode()); for (int i = 0; i < n; i++) { buf.Append(arrChar[rnd.Next(0, arrChar.Length)].ToString()); } return buf.ToString(); }
public bool SetAndTest(Guid guid) { var hash1 = guid.GetHashCode(); var hash2 = Hash(guid); var bits = Enumerable.Range(1, hashCount) .Select(i => (uint)DoubleHashToBitNumber(hash1, hash2, i)) .Distinct(); bool result = false; foreach (var bit in bits) { result |= bitSet.TrySet(bit); } return result; }
public void CreateId() { while (true) { System.Guid newGuid = System.Guid.NewGuid(); if (newGuid != System.Guid.Empty) { SetId(newGuid.GetHashCode()); break; } } }
public void Heartbeat(Guid origin, int processId) { lock (startedProcesses) { var process = startedProcesses.Where(x => x.ProcessId == processId).SingleOrDefault(); if (process != null) process.RegisterHeartbeat(origin); else { var processName = origin.GetHashCode(); var proc = SkynetProcess.FromId(processId, processName.ToString()); startedProcesses.Add(proc); proc.RegisterHeartbeat(origin); } } }
public void Value_type_Guid() { var helper = new IdHelperForValueType<Guid>(); var guid1 = new Guid("005faa88-a529-4065-9d04-72a96316988b"); var guid2 = new Guid("64b9dd7a-f46e-448b-b6e5-ddd3f83ec508"); Assert.AreEqual(false, helper.IsNull(Guid.Empty)); Assert.AreEqual(true, helper.IsDefaultValue(Guid.Empty)); Assert.AreEqual(false, helper.IsDefaultValue(guid1)); Assert.AreEqual(true, helper.AreEqual(Guid.Empty, Guid.Empty)); Assert.AreEqual(true, helper.AreEqual(guid1, guid1)); Assert.AreEqual(-1, helper.Compare(Guid.Empty, guid1)); Assert.AreEqual(+1, helper.Compare(guid2, Guid.Empty)); Assert.That(helper.Compare(Guid.Empty, Guid.Empty), Is.EqualTo(0)); Assert.AreEqual(0, helper.Compare(guid2, guid2)); Assert.AreEqual(Guid.Empty.GetHashCode(), helper.GetHashCode(Guid.Empty)); Assert.AreEqual(guid1.GetHashCode(), helper.GetHashCode(guid1)); }
public override int GetHashCode() { return(_id == null ? -1 : _id.GetHashCode()); }
public int GetHashCode(object x) { Guid value = new Guid(x.ToString()); return value.GetHashCode(); }
private Bucket getBucket(Guid key) { var idx = Math.Abs(key.GetHashCode() % m_BucketCount); //todo IMPORTANT!!!!! replace with more efficient Bucket determination call from NFX.IntMath return m_Buckets[idx]; }
public static int Compute(Guid value) { return(value.GetHashCode()); }
private static async Task CreateSaleLineAsync(DbConnection connection, Guid saleHeaderId, string employee, DateTimeOffset date, int index) { var random = new Random(date.GetHashCode() + saleHeaderId.GetHashCode() + employee.GetHashCode() + index); var product = products[random.Next(0, products.Count - 1)]; await connection.CreateCommand("INSERT INTO [tc_sale_line]([id],[sale_id],[product_name],[product_description],[product_detail],[unit_price],[quantity],[status],[created],[created_by],[modified],[modified_by])" + "VALUES(@id,@sale_id,@product_name,@product_description,@product_detail,@unit_price,@quantity,@status,@created,@created_by,@modified,@modified_by)") .AddParameter("@id", DbType.Guid, 0, Guid.NewGuid()) .AddParameter("@sale_id", DbType.Guid, 0, saleHeaderId) .AddParameter("@product_name", DbType.String, 64, product) .AddParameter("@product_description", DbType.String, 1024, descriptions[random.Next(0, descriptions.Count - 1)]) .AddParameter("@product_detail", DbType.Xml, 0, GenerateProductDetail(random, product)) .AddParameter("@unit_price", DbType.Currency, 0, (decimal)Math.Round((random.NextDouble() + .1D) * random.Next(10000, 10000 * 10000))) .AddParameter("@quantity", DbType.Int32, 0, random.Next(1, 3)) .AddParameter("@status", DbType.Byte, 0, states[random.Next(0, states.Count - 1)]) .AddParameter("@created", DbType.DateTimeOffset, 0, date) .AddParameter("@created_by", DbType.String, 64, employee) .AddParameter("@modified", DbType.DateTimeOffset, 0, date) .AddParameter("@modified_by", DbType.String, 64, employee) .ExecuteNonQueryAsync(); }
private static async Task CreateContactAsync(DbConnection connection, Guid saleHeaderId, string employee, DateTimeOffset date, int index) { var random = new Random(date.GetHashCode() + saleHeaderId.GetHashCode() + employee.GetHashCode() + index); var method = methods[random.Next(0, methods.Count - 1)]; await connection.CreateCommand("INSERT INTO [tc_customer_contact]([id],[sale_id],[method],[value],[created],[created_by],[modified],[modified_by])" + "VALUES(@id,@sale_id,@method,@value,@created,@created_by,@modified,@modified_by)") .AddParameter("@id", DbType.Guid, 0, Guid.NewGuid()) .AddParameter("@sale_id", DbType.Guid, 0, saleHeaderId) .AddParameter("@method", DbType.Byte, 0, method) .AddParameter("@value", DbType.String, 1024, GenerateRandomMethodValue(random, method)) .AddParameter("@status", DbType.Byte, 0, states[random.Next(0, states.Count - 1)]) .AddParameter("@created", DbType.DateTimeOffset, 0, date) .AddParameter("@created_by", DbType.String, 64, employee) .AddParameter("@modified", DbType.DateTimeOffset, 0, date) .AddParameter("@modified_by", DbType.String, 64, employee) .ExecuteNonQueryAsync(); }
public static void TestEquals(Guid guid1, object obj, bool expected) { if (obj is Guid) { Guid guid2 = (Guid)obj; Assert.Equal(expected, guid1.Equals(guid2)); Assert.Equal(expected, guid1 == guid2); Assert.Equal(!expected, guid1 != guid2); Assert.Equal(expected, guid1.GetHashCode().Equals(guid2.GetHashCode())); } Assert.Equal(expected, guid1.Equals(obj)); }
/// <summary> /// Gets a hashcode value based on the combination of the message's ID and RebroadcastID /// </summary> /// <param name="MessageID">The Message ID</param> /// <param name="BroadcastID">The Message Broadcast ID</param> /// <returns>The hashcode value</returns> private static int GetMergedHashCode(Guid MessageID, Guid BroadcastID) { byte[] composite = new byte[256]; MessageID.ToByteArray().CopyTo(composite, 0); BroadcastID.ToByteArray().CopyTo(composite, 128); //merge composite into a single guid by calculating hash //always create a brand new hash algorithm for use in a muli-threaded environment System.Security.Cryptography.HashAlgorithm hashAlg = System.Security.Cryptography.MD5.Create(); Guid newUnique = new Guid( hashAlg.ComputeHash(composite)); hashAlg = null; //return the new Guid's hashcode return newUnique.GetHashCode(); }
public Human( System.Guid _id, VirusSpreading.City _layer, Mars.Interfaces.Layer.RegisterAgent _register, Mars.Interfaces.Layer.UnregisterAgent _unregister, Mars.Components.Environments.SpatialHashEnvironment <Human> _HumanEnvironment, int Human_gain_by_age, int Vulnerable_class_ratio, int Obey_ratio, int Government_announce_date, int Initial_infected_rate, int Infection_rate1, int Infection_rate2 , double xcor = 0, double ycor = 0, int freq = 1) { _City = _layer; ID = _id; Position = Mars.Interfaces.Environment.Position.CreatePosition(xcor, ycor); _Random = new System.Random(ID.GetHashCode()); this.Human_gain_by_age = Human_gain_by_age; this.Vulnerable_class_ratio = Vulnerable_class_ratio; this.Obey_ratio = Obey_ratio; this.Government_announce_date = Government_announce_date; this.Initial_infected_rate = Initial_infected_rate; this.Infection_rate1 = Infection_rate1; this.Infection_rate2 = Infection_rate2; _City._HumanEnvironment.Insert(this); _register(_layer, this, freq); _isAlive = true; _executionFrequency = freq; { new System.Func <System.Tuple <double, double> >(() => { var _taget35_1049 = new System.Tuple <int, int>(_Random.Next(city.DimensionX() ), _Random.Next(city.DimensionY() ) ); var _object35_1049 = this; _City._HumanEnvironment.PosAt(_object35_1049, _taget35_1049.Item1, _taget35_1049.Item2 ); return(new Tuple <double, double>(Position.X, Position.Y)); }).Invoke(); R0 = 0; Ticks = 0; LossTicks = 0; int Class = _Random.Next(100); if (Class < Vulnerable_class_ratio) { { Energy = _Random.Next(Human_gain_by_age); Vulnerable = true ; } ; } else { { Energy = _Random.Next(Human_gain_by_age) + 40 ; } ; }; int infect = _Random.Next(100); if (infect < Initial_infected_rate) { { Infected = true ; } ; } ; } }
public override int GetHashCode() { return(value.GetHashCode()); }
/// <summary> /// Override to encode session ID GUID into string representation /// </summary> protected virtual string EncodeSessionID(Guid id) { ulong csum = ((ulong)id.GetHashCode() << 32) | (uint)ExternalRandomGenerator.Instance.NextRandomInteger; var encoded = new ELink(csum, id.ToByteArray()); return encoded.Link; }
public void GetHashCode_Same () { Guid copy = new Guid (Guid.Empty.ToString ()); Assert.AreEqual (Guid.Empty.GetHashCode (), copy.GetHashCode (), "GetHashCode"); }
public ConfigKey(Guid itemID, BaseContext context) { _ItemID = itemID; _Context = context; _HashCode = _Context.GetHashCode() ^ _ItemID.GetHashCode(); }
public static int Compute(Guid?value) { return(value?.GetHashCode() ?? -1); }
public override int GetHashCode() { return((_wellKnownSid == false) ? _objectGuid.GetHashCode() : (_domainName.GetHashCode() ^ _sid.GetHashCode())); }
/// <summary> /// Override to decode session ID GUID from string representation. Return null if conversion not possible /// </summary> protected virtual Guid? DecodeSessionID(string id) { ELink encoded; Guid guid; try { encoded = new ELink(id); guid = new Guid(encoded.Metadata); } catch { return null; } var csum = (int)(encoded.ID >> 32); if (guid.GetHashCode()==csum) return guid; return null; }
public void SetId(Guid id) { Id = id; x = id.GetHashCode(); }
private Color GetColor(Guid guid) { Color c = Color.FromArgb(guid.GetHashCode()); c = Color.FromArgb(255, c.R % 128 + 127, c.G % 128 + 127, c.B % 128 + 127); return c; }
public static int GetRandomId(bool hasGivenGuid, Guid guid,int lenth) { int result=Math.Abs(guid.GetHashCode()); return result; }
public Boolean runTest() { Console.WriteLine( "Co1186ctor_String.cs runTest() started." ); StringBuilder sblMsg = null; int iCountErrors = 0; int iCountTestcases = 0; int iErrorBits = 0; Guid guid2; Guid guid3; try { do { ++iCountTestcases; guid2 = Guid.NewGuid(); ++iCountTestcases; guid3 = new Guid( guid2.ToString() ); ++iCountTestcases; if ( ! guid2.Equals( guid3 ) ) { ++iCountErrors; Console.WriteLine( "POINTTOBREAK: E_251wn! (Co1186ctor_String)" ); sblMsg = new StringBuilder( "EXTENDEDINFO: (E_251wn ,Co1186ctor_String) guid2.ToString()==" ); sblMsg.Append( guid2.ToString() ); sblMsg.Append( " ,guid3.ToString()==" ); sblMsg.Append( guid3.ToString() ); Console.WriteLine( sblMsg.ToString() ); } ++iCountTestcases; if ( guid2.GetHashCode() != guid3.GetHashCode() ) { ++iCountErrors; Console.WriteLine( "POINTTOBREAK: E_228kc! (Co1186ctor_String)" ); sblMsg = new StringBuilder( "EXTENDEDINFO: (E_228kc ,Co1186ctor_String) guid2.ToString()==" ); sblMsg.Append( guid2.ToString() ); sblMsg.Append( " ,guid3.ToString()==" ); sblMsg.Append( guid3.ToString() ); Console.WriteLine( sblMsg.ToString() ); } try { ++iCountTestcases; guid2 = new Guid( "123456Ab 1629-11d2-8879-00c04fb990b0" ); ++iCountErrors; Console.WriteLine( "POINTTOBREAK: E_312to! (Co1186ctor_String)" ); } catch ( FormatException ) {} catch ( Exception exc ) { ++iCountErrors; Console.WriteLine( "POINTTOBREAK: E_311so! (Co1186ctor_String)" ); sblMsg = new StringBuilder( "EXTENDEDINFO: (E_311so ,Co1186ctor_String) exc.ToString()==" ); sblMsg.Append( exc.ToString() ); Console.WriteLine( sblMsg.ToString() ); } try { ++iCountTestcases; guid2 = new Guid( "123456A-1629-11d2-8879-00c04fb990b0" ); ++iCountErrors; Console.WriteLine( "POINTTOBREAK: E_323yp! (Co1186ctor_String)" ); } catch ( FormatException ) {} catch ( Exception exc ) { ++iCountErrors; Console.WriteLine( "POINTTOBREAK: E_324rp! (Co1186ctor_String)" ); sblMsg = new StringBuilder( "EXTENDEDINFO: (E_324rp ,Co1186ctor_String) exc.ToString()==" ); sblMsg.Append( exc.ToString() ); Console.WriteLine( sblMsg.ToString() ); } try { ++iCountTestcases; guid2 = new Guid( "123456Az-1629-11d2-8879-00c04fb990b0" ); ++iCountErrors; Console.WriteLine( "POINTTOBREAK: E_334if! (Co1186ctor_String)" ); } catch ( FormatException ) {} catch ( Exception exc ) { ++iCountErrors; Console.WriteLine( "POINTTOBREAK: E_335nf! (Co1186ctor_String)" ); sblMsg = new StringBuilder( "EXTENDEDINFO: (E_335nf ,Co1186ctor_String) exc.ToString()==" ); sblMsg.Append( exc.ToString() ); Console.WriteLine( sblMsg.ToString() ); } ++iCountTestcases; guid2 = new Guid( s_strGuid2 ); guid3 = new Guid( s_strGuid2 ); ++iCountTestcases; if ( ! guid2.Equals( guid3 ) ) { ++iCountErrors; Console.WriteLine( "POINTTOBREAK: E_241xl! (Co1186ctor_String)" ); sblMsg = new StringBuilder( "EXTENDEDINFO: (E_241xl ,Co1186ctor_String) guid2.ToString()==" ); sblMsg.Append( guid2.ToString() ); sblMsg.Append( " ,guid3.ToString()==" ); sblMsg.Append( guid3.ToString() ); Console.WriteLine( sblMsg.ToString() ); } ++iCountTestcases; if ( 0 != String.Compare( guid2.ToString(), s_strGuid2 , true ) ) { ++iCountErrors; Console.WriteLine( "POINTTOBREAK: E_266uj! (Co1186ctor_String)" ); sblMsg = new StringBuilder( "EXTENDEDINFO: (E_266uj ,Co1186ctor_String) guid2.ToString()==" ); sblMsg.Append( guid2.ToString() ); Console.WriteLine( sblMsg.ToString() ); } ++iCountTestcases; if ( guid2.GetHashCode() != 0x41D47C9 ) { ++iCountErrors; Console.WriteLine( "POINTTOBREAK: E_237hg! (Co1186ctor_String)" ); sblMsg = new StringBuilder( "EXTENDEDINFO: (E_237hg ,Co1186ctor_String) guid2.ToString()==" ); sblMsg.Append( guid2.ToString() ); Console.WriteLine( sblMsg.ToString() ); } iCountTestcases++; try { new Guid((String)null); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_587yb! ArgumentNullException expected"); } catch (ArgumentNullException aExc) { Console.WriteLine("Info_298ch! Caught expected ArgumentNullException, exc=="+aExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_2098c! ArgumentNullException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { new Guid("123456123445"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_209ux! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_298hw! Caught expected FormatException , exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_09u2d! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { new Guid("{00000000-0000-0000-0000-000000000000"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_298hd! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_029uc! Caught expected FormatException, exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_29hcs! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { new Guid("{00000000-0000-0000-0000-000000000000}0"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_28hxx! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_1289x! Caught expected FormatException, exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine( "POINTTOBREAK: Error_298cy! FormatException expected, got exc=="+exc.ToString()); } try { new Guid("00000000-0000-0000-0000-0000000000000"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_239uu! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_3498f! Caught expected FormatException, exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: ERror_20jf9 FormatException expected, got exc=="+exc.ToString()); } try { new Guid("0000000-00000-0000-0000-000000000000"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_208cx! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_298hc! Caught expected FormatException, exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_389ux! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { new Guid("00000000-00000-000-0000-000000000000"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_2hx83! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_298hx! Caught expected FormatException, exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_r98hc! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { new Guid("00000000-0000-00000-000-000000000000"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_27hxy! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_298fh! Caught expected FormatException, exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_9yc88! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { new Guid("00000000-0000-0000-00000-00000000000"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_28yc8! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_98y8e! Caught expected FormatException, exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_8938x! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { new Guid("00000000-0000-0000-0000-00L000000000"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_209ux! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_290xh! Caught expected FormatException, exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_019uz! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { new Guid("0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_109sj! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_9828z! Caught expected FormatException, exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_209uz! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { new Guid("{00000000d,0x0000}"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_109us! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_1099x! Caught expected FormatException, exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_2875v! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { Guid g = new Guid("{0x,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_1098u! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_10uzx! Caught expected FormatException , exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_109ux! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { Guid g = new Guid("{0x0000,0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_1890u! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_18yx2! Caught expected FormatException, exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTTOBREAK: Error_109ux! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { Guid g = new Guid("{0x0000,0x0000,0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_1890u! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_18yx2! Caught expected FormatException, exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTTOBREAK: Error_109ux! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { Guid g = new Guid("{0x0000,0x0000,0x0000, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_98s81! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_98v81! Cauht expected FormatException, exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_010x9! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { Guid g = new Guid("{0x0000,0x0000,0x0000,{0x00,0x00,00,0x00,0x00,0x00,0x00,0x00}}"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_2998s! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_2091x! Caught expected FormatException , exc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_109uc! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { Guid g = new Guid("{0x0000,0x0000,0x0000,{0x00,0x00,0x00,0x,0x00,0x00,0x00,0x00}}"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_1908x! FormatException expected"); } catch (FormatException fExc) { Console.WriteLine("Info_198yc! Caught expected FormatException, fExc=="+fExc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_18yv8! FormatException expected, got exc=="+exc.ToString()); } iCountTestcases++; try { Guid g = new Guid("{0x0000,0x0000,0x0000,{0x00,0x00,0xk0,0x00,0x00,0x00,0x00,0x00}}"); iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_9058c! FormatException expected"); } catch (FormatException fexc) { Console.WriteLine("Info_298gr! Caught expected FormatException , fexc=="+fexc.Message); } catch (Exception exc) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_298g7! FormatException expected, got exc=="+exc.ToString()); } Guid gg = new Guid("{0x11111111,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x11}}"); iCountTestcases++; if(!gg.ToString().Equals("11111111-0000-0000-0000-000000000011")) { iCountErrors++; Console.WriteLine("POINTTOBREAK: Error_398hc! Incorrect guid=="+gg.ToString()); } } while (false); } catch( Exception exc_general ) { ++iCountErrors; Console.WriteLine( "POINTTOBREAK: find error E_876yxw, general exception error! (Co1186ctor_String)" ); sblMsg = new StringBuilder( "EXTENDEDINFO: (E_876yxw ,Co1186ctor_String) exc_general.ToString()==" ); sblMsg.Append( exc_general.ToString() ); Console.WriteLine( sblMsg.ToString() ); } if ( iErrorBits != 0 ) { ++iCountErrors; Console.WriteLine( "POINTTOBREAK: find error E_678xy (Co1186ctor_String)" ); sblMsg = new StringBuilder( "EXTENDEDINFO: (E_678xy ,Co1186ctor_String) iErrorBits==" ); sblMsg.Append( iErrorBits ); Console.WriteLine( sblMsg.ToString() ); } if ( iCountErrors == 0 ) { Console.Write( "Guid\\Co1186ctor_String.cs: paSs. iCountTestcases==" ); Console.WriteLine( iCountTestcases ); return true; } else { Console.Write( "Co1186ctor_String.cs iCountErrors==" ); Console.WriteLine( iCountErrors ); Console.WriteLine( "Co1186ctor_String.cs FAiL !" ); return false; } }
public int GetNextRevision(Guid gd, int revision) { var hash = gd.GetHashCode(); ISequentialIntServiceNode node; node = nodes.FirstOrDefault(x => x.Intervals.Where(y => y.Start <= hash && y.End >= hash).ToList().Count == 1); if (node == null) { foreach (var service in services) { var requestedNode = service.GetServiceNode(hash); if (requestedNode != null) { node = requestedNode; break; } } } if (node == null) { Console.WriteLine("Can't find node for this hash: " + hash); return -1; } return node.GetNextRevision(gd, revision); }
public Boolean runTest() { Console.Error.WriteLine( "Co1188GetHashCode_Dupl2.cs runTest() started." ); StringBuilder sblMsg = new StringBuilder( 99 ); int iCountErrors = 0; int iCountTestcases = 0; int iErrorBits = 0; Guid guid2; Guid guid3; try { do { ++iCountTestcases; guid2 = Guid.NewGuid(); ++iCountTestcases; guid3 = new Guid( guid2.ToString() ); ++iCountTestcases; if ( ! guid2.Equals( guid3 ) ) { ++iCountErrors; Console.Error.WriteLine( "POINTTOBREAK: E_251wn! (Co1188GetHashCode_Dupl2)" ); sblMsg.Length = 0 ; sblMsg.Append( "EXTENDEDINFO: (E_251wn ,Co1188GetHashCode_Dupl2) guid2.ToString()==" ); sblMsg.Append( guid2.ToString() ); sblMsg.Append( " ,guid3.ToString()==" ); sblMsg.Append( guid3.ToString() ); Console.Error.WriteLine( sblMsg.ToString() ); } ++iCountTestcases; if ( guid2.GetHashCode() != guid3.GetHashCode() ) { ++iCountErrors; Console.Error.WriteLine( "POINTTOBREAK: E_228kc! (Co1188GetHashCode_Dupl2)" ); sblMsg.Length = 0 ; sblMsg.Append( "EXTENDEDINFO: (E_228kc ,Co1188GetHashCode_Dupl2) guid2.ToString()==" ); sblMsg.Append( guid2.ToString() ); sblMsg.Append( " ,guid3.ToString()==" ); sblMsg.Append( guid3.ToString() ); Console.Error.WriteLine( sblMsg.ToString() ); } ++iCountTestcases; guid2 = new Guid( s_strGuid2 ); guid3 = new Guid( s_strGuid2 ); ++iCountTestcases; if ( ! guid2.Equals( guid3 ) ) { ++iCountErrors; Console.Error.WriteLine( "POINTTOBREAK: E_241xl! (Co1188GetHashCode_Dupl2)" ); sblMsg.Length = 0 ; sblMsg.Append( "EXTENDEDINFO: (E_241xl ,Co1188GetHashCode_Dupl2) guid2.ToString()==" ); sblMsg.Append( guid2.ToString() ); sblMsg.Append( " ,guid3.ToString()==" ); sblMsg.Append( guid3.ToString() ); Console.Error.WriteLine( sblMsg.ToString() ); } ++iCountTestcases; if ( 0 != String.Compare( guid2.ToString(), s_strGuid2 , true ) ) { ++iCountErrors; Console.Error.WriteLine( "POINTTOBREAK: E_266uj! (Co1188GetHashCode_Dupl2)" ); sblMsg.Length = 0 ; sblMsg.Append( "EXTENDEDINFO: (E_266uj ,Co1188GetHashCode_Dupl2) guid2.ToString()==" ); sblMsg.Append( guid2.ToString() ); Console.Error.WriteLine( sblMsg.ToString() ); } ++iCountTestcases; if ( guid2.GetHashCode() != 0x41D47C9 ) { ++iCountErrors; Console.Error.WriteLine( "POINTTOBREAK: E_237hg! (Co1188GetHashCode_Dupl2)" ); sblMsg.Length = 0 ; sblMsg.Append( "EXTENDEDINFO: (E_237hg ,Co1188GetHashCode_Dupl2) guid2.ToString()==" ); sblMsg.Append( guid2.ToString() ); Console.Error.WriteLine( sblMsg.ToString() ); } } while (false); } catch( Exception exc_general ) { ++iCountErrors; Console.Error.WriteLine( "POINTTOBREAK: find error E_876yxw, general exception error! (Co1188GetHashCode_Dupl2)" ); sblMsg.Length = 0 ; sblMsg.Append( "EXTENDEDINFO: (E_876yxw ,Co1188GetHashCode_Dupl2) exc_general.ToString()==" ); sblMsg.Append( exc_general.ToString() ); Console.Error.WriteLine( sblMsg.ToString() ); } if ( iErrorBits != 0 ) { ++iCountErrors; Console.Error.WriteLine( "POINTTOBREAK: find error E_678xy (Co1188GetHashCode_Dupl2)" ); sblMsg.Length = 0 ; sblMsg.Append( "EXTENDEDINFO: (E_678xy ,Co1188GetHashCode_Dupl2) iErrorBits==" ); sblMsg.Append( iErrorBits ); Console.Error.WriteLine( sblMsg.ToString() ); } if ( iCountErrors == 0 ) { sblMsg.Length = 0 ; sblMsg.Append( "Guid\\Co1188GetHashCode_Dupl2.cs: paSs. iCountTestcases==" ); sblMsg.Append( iCountTestcases ); Console.Error.WriteLine( sblMsg.ToString() ); return true; } else { sblMsg.Length = 0 ; sblMsg.Append( "Co1188GetHashCode_Dupl2.cs iCountErrors==" ); sblMsg.Append( iCountErrors ); Console.Error.WriteLine( sblMsg.ToString() ); Console.Error.WriteLine( "Co1188GetHashCode_Dupl2.cs FAiL !" ); return false; } }
private Bucket getBucket(Guid key) { var idx = (key.GetHashCode() & CoreConsts.ABS_HASH_MASK) % m_BucketCount; return m_Buckets[idx]; }