public void Test_NullableReadOnlyRefOfT_CreateNullableReadOnlyRefOfT_Ok()
        {
            int value     = 1;
            var reference = new NullableReadOnlyRef <int>(value);

            Assert.IsTrue(reference.HasValue);
            Assert.IsTrue(Unsafe.AreSame(ref value, ref Unsafe.AsRef(reference.Value)));
        }
        public void Test_NullableReadOnlyRefOfT_CreateNullableReadOnlyRefOfT_ImplicitNullableRefCast()
        {
            int value     = 42;
            var reference = new NullableRef <int>(ref value);
            NullableReadOnlyRef <int> nullableRef = reference;

            Assert.IsTrue(nullableRef.HasValue);
            Assert.IsTrue(Unsafe.AreSame(ref reference.Value, ref Unsafe.AsRef(nullableRef.Value)));
        }
        public void Test_NullableReadOnlyRefOfT_CreateNullableReadOnlyRefOfT_Null_Exception()
        {
            NullableReadOnlyRef <int> reference = default;

            _ = reference.Value;
        }
Esempio n. 4
0
        public void Test_NullableReadOnlyRefOfT_CreateNullableReadOnlyRefOfT_Null()
        {
            NullableReadOnlyRef <int> reference = default;

            Assert.IsFalse(reference.HasValue);
        }