public void Generate_WithTimestampSameAsPrevious_ShouldIncreaseRandomness() { var timestamp = 1616419012412; var result1 = Ulid.Generate(timestamp); var result2 = Ulid.Generate(timestamp); Assert.Equal(result1.ToByteArray()[..^ 2], result2.ToByteArray()[..^ 2]);
public void ConvertToString_WithAnyUlid_ShouldReturnCanonicalRepresentation() { var source = Ulid.Generate(); var result = this.subject.ConvertToString(source); Assert.Equal(source.ToString(), result); }
public void ConvertFromString_WithValidCanonicalRepresentation_ShouldReturnCorrespondingUlid() { var source = Ulid.Generate(); var result = this.subject.ConvertFromString(source.ToString()); Assert.Equal(source, result); }
public void Time_FromInstanceSpecifiedTimestampInGenerate_ShouldReturnDateTimeRepresentThatTimestamp() { var subject = Ulid.Generate(1620900032009); var result = subject.Time; Assert.Equal(new DateTime(2021, 5, 13, 10, 0, 32, 9, DateTimeKind.Utc), result); Assert.Equal(DateTimeKind.Utc, result.Kind); }
public void Timestamp_FromInstanceSpecifiedTimestampInGenerate_ShouldReturnTheSameValue(long timestamp) { var subject = Ulid.Generate(timestamp); Assert.Equal(timestamp, subject.Timestamp); }
public Task <int> InvokeAsync(InvocationContext context) { Console.WriteLine(Ulid.Generate()); return(Task.FromResult(0)); }