Răsfoiți Sursa

One more test to ensure DefaultInstance is read-only

csharptest 14 ani în urmă
părinte
comite
3b625064e8
1 a modificat fișierele cu 10 adăugiri și 0 ștergeri
  1. 10 0
      src/ProtocolBuffers.Test/ReusableBuilderTest.cs

+ 10 - 0
src/ProtocolBuffers.Test/ReusableBuilderTest.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Text;
+using Google.ProtocolBuffers.Collections;
 using NUnit.Framework;
 using Google.ProtocolBuffers.TestProtos;
 using Google.ProtocolBuffers.Serialization;
@@ -10,6 +11,15 @@ namespace Google.ProtocolBuffers
     [TestFixture]
     public class ReusableBuilderTest
     {
+        [Test]
+        public void TestModifyDefaultInstance()
+        {
+            //verify that the default instance has correctly been marked as read-only
+            Assert.AreEqual(typeof(PopsicleList<bool>), TestAllTypes.DefaultInstance.RepeatedBoolList.GetType());
+            PopsicleList<bool> list = (PopsicleList<bool>)TestAllTypes.DefaultInstance.RepeatedBoolList;
+            Assert.IsTrue(list.IsReadOnly);
+        }
+
         [Test]
         public void TestUnmodifiedDefaultInstance()
         {