Example #1
0
        public void ToStringP(byte[] correctBytes)
        {
            var uuid           = new Uuid(correctBytes);
            var expectedString = UuidTestsUtils.GetStringP(correctBytes);

            var actualString = uuid.ToString("P");

            Assert.AreEqual(expectedString, actualString);
        }
Example #2
0
        public void ToStringEmptyFormat(byte[] correctBytes)
        {
            var uuid           = new Uuid(correctBytes);
            var expectedString = UuidTestsUtils.GetStringN(correctBytes);

            var actualString = uuid.ToString(string.Empty);

            Assert.AreEqual(expectedString, actualString);
        }
        public void TryFormatNullFormat(byte[] correctBytes)
        {
            var         uuid           = new Uuid(correctBytes);
            var         expectedString = UuidTestsUtils.GetStringN(correctBytes);
            Span <char> buffer         = stackalloc char[32];

            Assert.True(uuid.TryFormat(buffer, out int charsWritten));
            Assert.AreEqual(32, charsWritten);
            Assert.AreEqual(expectedString, new string(buffer));
        }
        public void TryFormatPCorrect(byte[] correctBytes)
        {
            var         uuid           = new Uuid(correctBytes);
            var         expectedString = UuidTestsUtils.GetStringP(correctBytes);
            Span <char> buffer         = stackalloc char[38];

            Assert.True(uuid.TryFormat(buffer, out int charsWritten, new ReadOnlySpan <char>(new[] { 'P' })));
            Assert.AreEqual(38, charsWritten);
            Assert.AreEqual(expectedString, new string(buffer));
        }
Example #5
0
        public void TryFormatBCorrect(byte[] correctBytes)
        {
            var    uuid           = new Uuid(correctBytes);
            string expectedString = UuidTestsUtils.GetStringB(correctBytes);
            char * bufferPtr      = stackalloc char[38];
            var    spanBuffer     = new Span <char>(bufferPtr, 38);

            Assert.True(uuid.TryFormat(spanBuffer, out int charsWritten, new ReadOnlySpan <char>(new[] { 'B' })));
            Assert.AreEqual(38, charsWritten);
            Assert.AreEqual(expectedString, new string(bufferPtr, 0, 38));
        }
Example #6
0
        public void TryFormatEmptyFormat(byte[] correctBytes)
        {
            var    uuid           = new Uuid(correctBytes);
            string expectedString = UuidTestsUtils.GetStringN(correctBytes);
            char * bufferPtr      = stackalloc char[32];
            var    spanBuffer     = new Span <char>(bufferPtr, 32);

            Assert.True(uuid.TryFormat(spanBuffer, out int charsWritten, ReadOnlySpan <char> .Empty));
            Assert.AreEqual(32, charsWritten);
            Assert.AreEqual(expectedString, new string(bufferPtr, 0, 32));
        }