﻿using System.Reflection;
using Xunit;

namespace System.Text.Utf8.Tests
{
    public class TypeConstraintsTests
    {
        [Fact]
        public void Utf8StringIsAStruct()
        {
            var utf8String = "anyString"u8;
            Assert.True(utf8String.GetType().GetTypeInfo().IsValueType);
        }

        [Fact]
        public void Utf8StringCodeUnitsEnumeratorIsAStruct()
        {
            var utf8String = "anyString"u8;
            var utf8CodeUnitsEnumerator = utf8String.GetEnumerator();
            Assert.True(utf8String.GetType().GetTypeInfo().IsValueType);
        }

        [Fact]
        public void Utf8StringCodePointEnumerableIsAStruct()
        {
            var utf8String = "anyString"u8;
            Assert.True(utf8String.CodePoints.GetType().GetTypeInfo().IsValueType);
        }

        [Fact]
        public void Utf8StringCodePointEnumeratorIsAStruct()
        {
            var utf8String = "anyString"u8;
            var utf8CodePointEnumerator = utf8String.CodePoints.GetEnumerator();
            Assert.True(utf8CodePointEnumerator.GetType().GetTypeInfo().IsValueType);
        }

        [Fact]
        public void Utf8StringReverseCodePointEnumeratorIsAStruct()
        {
            var utf8String = "anyString"u8;
            var utf8CodePointEnumerator = utf8String.CodePoints.GetReverseEnumerator();
            Assert.True(utf8CodePointEnumerator.GetType().GetTypeInfo().IsValueType);
        }
    }
}

﻿using System.Reflection;
using Xunit;

namespace System.Text.Utf8.Tests
{
    public class TypeConstraintsTests
    {
        private Utf8String _anyUtf8String;

        public TypeConstraintsTests()
        {
            _anyUtf8String = "anyString"u8;
        }

        [Fact]
        public void Utf8StringIsAStruct()
        {
            Assert.True(_anyUtf8String.GetType().GetTypeInfo().IsValueType);
        }

        [Fact]
        public void Utf8StringCodeUnitsEnumeratorIsAStruct()
        {
            var utf8CodeUnitsEnumerator = _anyUtf8String.GetEnumerator();
            Assert.True(_anyUtf8String.GetType().GetTypeInfo().IsValueType);
        }

        [Fact]
        public void Utf8StringCodePointEnumerableIsAStruct()
        {
            Assert.True(_anyUtf8String.CodePoints.GetType().GetTypeInfo().IsValueType);
        }

        [Fact]
        public void Utf8StringCodePointEnumeratorIsAStruct()
        {
            var utf8CodePointEnumerator = _anyUtf8String.CodePoints.GetEnumerator();
            Assert.True(utf8CodePointEnumerator.GetType().GetTypeInfo().IsValueType);
        }

        [Fact]
        public void Utf8StringReverseCodePointEnumeratorIsAStruct()
        {
            var utf8CodePointEnumerator = _anyUtf8String.CodePoints.GetReverseEnumerator();
            Assert.True(utf8CodePointEnumerator.GetType().GetTypeInfo().IsValueType);
        }
    }
}

Replace hard coded string with field in utf8string tests where the value is irrelevant
Replace hard coded string with field in utf8string tests where the value is irrelevant
