コード例 #1
0
        public void CreateRandom64Bit_CreatesValid64BitId()
        {
            var traceId = TraceId.CreateRandomDataDogCompatible();

            using (new AssertionScope())
            {
                FluentActions.Invoking(() => Convert.ToUInt64(traceId.ToString(), fromBase: 10)).Should().NotThrow();
            }
        }
コード例 #2
0
        public void Equals_WorksCorrectlyBetween64And128BitIds()
        {
            var traceId1 = TraceId.CreateRandomDataDogCompatible();
            var traceId2 = TraceId.CreateFromString(TraceId.Zero.Lower.ToString("x16") + traceId1.Lower.ToString("x16"));

            using (new AssertionScope())
            {
                traceId1.Lower.Should().Be(traceId2.Lower);
                traceId1.Should().NotBe(TraceId.CreateFromString(traceId2.ToString()));
                traceId2.Should().NotBe(TraceId.CreateDataDogCompatibleFromDecimalString(traceId1.ToString()));
                traceId1.GetHashCode().Should().NotBe(traceId2.GetHashCode());
            }
        }
コード例 #3
0
        public void Equals_WorksCorrectlyFor64BitId()
        {
            var traceId1 = TraceId.CreateRandomDataDogCompatible();
            var traceId2 = TraceId.CreateRandomDataDogCompatible();

            using (new AssertionScope())
            {
                traceId1.Should().Be(TraceId.CreateDataDogCompatibleFromDecimalString(traceId1.ToString()));
                traceId1.GetHashCode().Should().Be(TraceId.CreateDataDogCompatibleFromDecimalString(traceId1.ToString()).GetHashCode());
                traceId2.Should().Be(TraceId.CreateDataDogCompatibleFromDecimalString(traceId2.ToString()));
                traceId2.GetHashCode().Should().Be(TraceId.CreateDataDogCompatibleFromDecimalString(traceId2.ToString()).GetHashCode());
                traceId1.Should().NotBe(TraceId.CreateDataDogCompatibleFromDecimalString(traceId2.ToString()));
                traceId2.Should().NotBe(TraceId.CreateDataDogCompatibleFromDecimalString(traceId1.ToString()));
            }
        }
コード例 #4
0
 public TraceId GenerateNewTraceId() => TraceId.CreateRandomDataDogCompatible();