コード例 #1
0
        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]);
コード例 #2
0
        public void ConvertToString_WithAnyUlid_ShouldReturnCanonicalRepresentation()
        {
            var source = Ulid.Generate();
            var result = this.subject.ConvertToString(source);

            Assert.Equal(source.ToString(), result);
        }
コード例 #3
0
        public void ConvertFromString_WithValidCanonicalRepresentation_ShouldReturnCorrespondingUlid()
        {
            var source = Ulid.Generate();
            var result = this.subject.ConvertFromString(source.ToString());

            Assert.Equal(source, result);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public void Timestamp_FromInstanceSpecifiedTimestampInGenerate_ShouldReturnTheSameValue(long timestamp)
        {
            var subject = Ulid.Generate(timestamp);

            Assert.Equal(timestamp, subject.Timestamp);
        }
コード例 #6
0
 public Task <int> InvokeAsync(InvocationContext context)
 {
     Console.WriteLine(Ulid.Generate());
     return(Task.FromResult(0));
 }