Example #1
0
 private static string GetHashPostfix(string originalName)
 {
     // return a persistant hash code so that the code stays stable
     // and comparable between different compiler versions.
     // also 4 characters should suffice.
     return("_" + Math.Abs(HashCodeUtility.GetPersistentHashCode(originalName))
            .ToString("0000").Substring(0, 4));
 }
Example #2
0
 public void GetPersistentIntHashCode(int nValue, int nExpected)
 {
     Assert.AreEqual(nExpected, HashCodeUtility.GetPersistentHashCode((sbyte)nValue));
     Assert.AreEqual(nExpected, HashCodeUtility.GetPersistentHashCode((short)nValue));
     if (nValue >= 0)
     {
         Assert.AreEqual(nExpected, HashCodeUtility.GetPersistentHashCode((char)nValue));
     }
     Assert.AreEqual(nExpected, HashCodeUtility.GetPersistentHashCode(nValue));
 }
 public void GetPersistentIntHashCode(int value, int expected)
 {
     Assert.That(HashCodeUtility.GetPersistentHashCode((sbyte)value), Is.EqualTo(expected));
     Assert.That(HashCodeUtility.GetPersistentHashCode((short)value), Is.EqualTo(expected));
     if (value >= 0)
     {
         Assert.That(HashCodeUtility.GetPersistentHashCode((char)value), Is.EqualTo(expected));
     }
     Assert.That(HashCodeUtility.GetPersistentHashCode(value), Is.EqualTo(expected));
 }
        public void Should_generate_from_relative_uri()
        {
            var report = new ErrorReportEntity(1, "kffk", DateTime.UtcNow, new ErrorReportException(), new[]
            {
                new ErrorReportContextCollection("Yadayada",
                                                 new Dictionary <string, string>
                {
                    { "Url", "/some/path?hada=yada" },
                    { "HttpCode", "404" }
                })
            });

            var sut  = new HttpErrorGenerator();
            var code = sut.GenerateHashCode(report);

            var source = $"404;/some/path";

            code.HashCode.Should().Be(HashCodeUtility.GetPersistentHashCode(source).ToString("X"));
        }
Example #5
0
 public void GetPersistentBoolHashCode(bool value, int expected)
 {
     Assert.AreEqual(expected, HashCodeUtility.GetPersistentHashCode(value));
 }
Example #6
0
 public void GetPersistentLongHashCode(long nValue, int nExpected)
 {
     Assert.AreEqual(nExpected, HashCodeUtility.GetPersistentHashCode(nValue));
 }
 public void GetPersistentHash(string value, int expected)
 {
     Assert.That(HashCodeUtility.GetPersistentHashCode(value), Is.EqualTo(expected));
 }