| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | using Google.Apis.Util; |
| | using System.Collections.Generic; |
| | using System.Linq; |
| | using Xunit; |
| |
|
| | namespace Google.Apis.Tests.Apis.Utils |
| | { |
| | |
| | |
| | |
| | public class RepeatableTest |
| | { |
| | |
| | |
| | |
| | [Fact] |
| | public void CreateRepeatableTest() |
| | { |
| | |
| | Assert.NotNull((Repeatable<string>) "Test"); |
| | Assert.NotNull((Repeatable<string>) new[] { "Test1", "Test2" }); |
| | Assert.Null((Repeatable<string>) new string[] { }); |
| |
|
| | |
| | Assert.NotNull((Repeatable<int>)0); |
| | Assert.NotNull((Repeatable<int>)1); |
| | Assert.NotNull((Repeatable<int>) new[] { 1, 2, 3 }); |
| | Assert.Null((Repeatable<int>) new int[] { }); |
| |
|
| | |
| | Repeatable<int> repeatable = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; |
| | int i = 0; |
| | foreach (int value in repeatable) |
| | { |
| | Assert.Equal(++i, value); |
| | } |
| | Assert.Equal(9, i); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | [Fact] |
| | public void TestImplicitConversion() |
| | { |
| | Assert.Equal("Foo", ConcatStrings("Foo", null)); |
| | Assert.Equal("Foobar", ConcatStrings("Foo", "bar")); |
| | Assert.Equal("FoobarTest", ConcatStrings("Foo", new[] { "bar", "Test" })); |
| | } |
| |
|
| | |
| | |
| | |
| | [Fact] |
| | public void TestRepeatedGet() |
| | { |
| | int[] testInput = new[] { 1, 2, 3 }; |
| | Repeatable<int> repeatable = testInput; |
| | |
| | |
| | Assert.Equal(testInput, repeatable); |
| |
|
| | |
| | Assert.Equal(testInput, repeatable); |
| | } |
| |
|
| | |
| | |
| | |
| | [Fact] |
| | public void TestModifiedSource() |
| | { |
| | int[] testInput = new[] { 1, 2, 3 }; |
| | var testList = new List<int>(testInput); |
| | Repeatable<int> repeatable = testList; |
| |
|
| | |
| | Assert.Equal(testInput, repeatable); |
| |
|
| | |
| | testList.RemoveAt(0); |
| | Assert.Equal(testInput, repeatable); |
| | } |
| |
|
| | private static string ConcatStrings(string normalParameter, Repeatable<string> repeatable) |
| | { |
| | if (repeatable == null) |
| | { |
| | return normalParameter; |
| | } |
| |
|
| | return repeatable.Aggregate(normalParameter, (current, str) => current + str); |
| | } |
| | } |
| | } |
| |
|