public void CreateRandom64Bit_CreatesValid64BitId() { var traceId = TraceId.CreateRandomDataDogCompatible(); using (new AssertionScope()) { FluentActions.Invoking(() => Convert.ToUInt64(traceId.ToString(), fromBase: 10)).Should().NotThrow(); } }
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()); } }
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())); } }
public TraceId GenerateNewTraceId() => TraceId.CreateRandomDataDogCompatible();