Exemple #1
0
    public void When_same_input_and_same_namespace_then_should_create_same_guid()
    {
        var sut = new DeterministicGuidFactory(Guid.Parse("0E9C9913-06AF-4E24-A7CE-1AB5A06E35D0"));

        var guid1 = sut.Create("foo");

        var guid2 = sut.Create("foo");

        guid2.ShouldBe(guid1);
    }
Exemple #2
0
    /// <summary>
    /// Creates a deterministic GUID from the supplied input. The input is converted to a byte array using UTF8 encding.
    /// A consumer supplying the same input will get the same GUID as return.
    /// </summary>
    /// <param name="deterministicGuidFactory">A deterministicGuidFactory.</param>
    /// <param name="input">Source input.</param>
    /// <returns></returns>
    public static Guid Create(this DeterministicGuidFactory deterministicGuidFactory, string input)
    {
        if (input == null)
        {
            throw new ArgumentNullException(nameof(input));
        }

        var bytes = Encoding.UTF8.GetBytes(input);

        return(deterministicGuidFactory.Create(bytes));
    }