diff options
author | Jon Skeet <skeet@pobox.com> | 2015-06-09 19:30:44 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2015-06-09 19:30:44 +0100 |
commit | e38294a62d7f37c0661273a9a26fda16d557423f (patch) | |
tree | 316989251907553408e7b32a12792f496333e075 /csharp/src/ProtocolBuffers.Test/GeneratedBuilderTest.cs | |
parent | f52426827e4d5e8da7d205af538799740b5199b9 (diff) | |
download | protobuf-e38294a62d7f37c0661273a9a26fda16d557423f.tar.gz protobuf-e38294a62d7f37c0661273a9a26fda16d557423f.tar.bz2 protobuf-e38294a62d7f37c0661273a9a26fda16d557423f.zip |
First pass at the mutable API. Quite a bit more to do - in particular, it's pretty slow right now.
Diffstat (limited to 'csharp/src/ProtocolBuffers.Test/GeneratedBuilderTest.cs')
-rw-r--r-- | csharp/src/ProtocolBuffers.Test/GeneratedBuilderTest.cs | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/csharp/src/ProtocolBuffers.Test/GeneratedBuilderTest.cs b/csharp/src/ProtocolBuffers.Test/GeneratedBuilderTest.cs deleted file mode 100644 index 257f5001..00000000 --- a/csharp/src/ProtocolBuffers.Test/GeneratedBuilderTest.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System;
-using System.Collections.Generic;
-using Google.ProtocolBuffers.TestProtos;
-using NUnit.Framework;
-
-namespace Google.ProtocolBuffers
-{
- public class GeneratedBuilderTest
- {
- class OneTimeEnumerator<T> : IEnumerable<T>
- {
- readonly T _item;
- bool _enumerated;
- public OneTimeEnumerator(T item)
- {
- _item = item;
- }
- public IEnumerator<T> GetEnumerator()
- {
- Assert.IsFalse(_enumerated);
- _enumerated = true;
- yield return _item;
- }
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- }
-
- [Test]
- public void DoesNotEnumerateTwiceForMessageList()
- {
- TestAllTypes.Builder b = new TestAllTypes.Builder();
- b.AddRangeRepeatedForeignMessage(new OneTimeEnumerator<ForeignMessage>(ForeignMessage.DefaultInstance));
- }
-
- [Test]
- public void DoesNotEnumerateTwiceForPrimitiveList()
- {
- TestAllTypes.Builder b = new TestAllTypes.Builder();
- b.AddRangeRepeatedInt32(new OneTimeEnumerator<int>(1));
- }
-
- [Test]
- public void DoesNotEnumerateTwiceForStringList()
- {
- TestAllTypes.Builder b = new TestAllTypes.Builder();
- b.AddRangeRepeatedString(new OneTimeEnumerator<string>("test"));
- }
-
- [Test]
- public void DoesNotEnumerateTwiceForEnumList()
- {
- TestAllTypes.Builder b = new TestAllTypes.Builder();
- b.AddRangeRepeatedForeignEnum(new OneTimeEnumerator<ForeignEnum>(ForeignEnum.FOREIGN_BAR));
- }
-
- [Test]
- public void DoesNotAddNullToMessageListByAddRange()
- {
- TestAllTypes.Builder b = new TestAllTypes.Builder();
- Assert.Throws<ArgumentNullException>(() => b.AddRangeRepeatedForeignMessage(new ForeignMessage[] { null }));
- }
-
- [Test]
- public void DoesNotAddNullToMessageListByAdd()
- {
- TestAllTypes.Builder b = new TestAllTypes.Builder();
- Assert.Throws<ArgumentNullException>(() => b.AddRepeatedForeignMessage((ForeignMessage)null));
- }
-
- [Test]
- public void DoesNotAddNullToMessageListBySet()
- {
- TestAllTypes.Builder b = new TestAllTypes.Builder();
- b.AddRepeatedForeignMessage(ForeignMessage.DefaultInstance);
- Assert.Throws<ArgumentNullException>(() => b.SetRepeatedForeignMessage(0, (ForeignMessage)null));
- }
-
- [Test]
- public void DoesNotAddNullToStringListByAddRange()
- {
- TestAllTypes.Builder b = new TestAllTypes.Builder();
- Assert.Throws<ArgumentNullException>(() => b.AddRangeRepeatedString(new String[] { null }));
- }
-
- [Test]
- public void DoesNotAddNullToStringListByAdd()
- {
- TestAllTypes.Builder b = new TestAllTypes.Builder();
- Assert.Throws<ArgumentNullException>(() => b.AddRepeatedString(null));
- }
-
- [Test]
- public void DoesNotAddNullToStringListBySet()
- {
- TestAllTypes.Builder b = new TestAllTypes.Builder();
- b.AddRepeatedString("one");
- Assert.Throws<ArgumentNullException>(() => b.SetRepeatedString(0, null));
- }
- }
-}
|