OLD | NEW |
1 #region Copyright notice and license | 1 #region Copyright notice and license |
2 // Protocol Buffers - Google's data interchange format | 2 // Protocol Buffers - Google's data interchange format |
3 // Copyright 2015 Google Inc. All rights reserved. | 3 // Copyright 2015 Google Inc. All rights reserved. |
4 // https://developers.google.com/protocol-buffers/ | 4 // https://developers.google.com/protocol-buffers/ |
5 // | 5 // |
6 // Redistribution and use in source and binary forms, with or without | 6 // Redistribution and use in source and binary forms, with or without |
7 // modification, are permitted provided that the following conditions are | 7 // modification, are permitted provided that the following conditions are |
8 // met: | 8 // met: |
9 // | 9 // |
10 // * Redistributions of source code must retain the above copyright | 10 // * Redistributions of source code must retain the above copyright |
(...skipping 16 matching lines...) Expand all Loading... |
27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 #endregion | 31 #endregion |
32 using NUnit.Framework; | 32 using NUnit.Framework; |
33 using System; | 33 using System; |
34 using System.Collections.Generic; | 34 using System.Collections.Generic; |
35 using System.Reflection; | 35 using System.Reflection; |
36 | 36 |
| 37 #if !DOTNET35 |
37 namespace Google.Protobuf.Compatibility | 38 namespace Google.Protobuf.Compatibility |
38 { | 39 { |
39 public class TypeExtensionsTest | 40 public class TypeExtensionsTest |
40 { | 41 { |
41 public class DerivedList : List<string> { } | 42 public class DerivedList : List<string> { } |
42 public string PublicProperty { get; set; } | 43 public string PublicProperty { get; set; } |
43 private string PrivateProperty { get; set; } | 44 private string PrivateProperty { get; set; } |
44 | 45 |
45 public void PublicMethod() | 46 public void PublicMethod() |
46 { | 47 { |
47 } | 48 } |
48 | 49 |
49 private void PrivateMethod() | 50 private void PrivateMethod() |
50 { | 51 { |
51 } | 52 } |
52 | 53 |
53 [Test] | 54 [Test] |
54 [TestCase(typeof(int), true)] | |
55 [TestCase(typeof(int?), true)] | |
56 [TestCase(typeof(Nullable<>), true)] | |
57 [TestCase(typeof(WireFormat.WireType), true)] | |
58 [TestCase(typeof(string), false)] | |
59 [TestCase(typeof(object), false)] | |
60 [TestCase(typeof(Enum), false)] | |
61 [TestCase(typeof(ValueType), false)] | |
62 [TestCase(typeof(TypeExtensionsTest), false)] | |
63 [TestCase(typeof(Action), false)] | |
64 [TestCase(typeof(Action<>), false)] | |
65 [TestCase(typeof(IDisposable), false)] | |
66 public void IsValueType(Type type, bool expected) | |
67 { | |
68 Assert.AreEqual(expected, TypeExtensions.IsValueType(type)); | |
69 } | |
70 | |
71 [Test] | |
72 [TestCase(typeof(object), typeof(string), true)] | 55 [TestCase(typeof(object), typeof(string), true)] |
73 [TestCase(typeof(object), typeof(int), true)] | 56 [TestCase(typeof(object), typeof(int), true)] |
74 [TestCase(typeof(string), typeof(string), true)] | 57 [TestCase(typeof(string), typeof(string), true)] |
75 [TestCase(typeof(string), typeof(object), false)] | 58 [TestCase(typeof(string), typeof(object), false)] |
76 [TestCase(typeof(string), typeof(int), false)] | 59 [TestCase(typeof(string), typeof(int), false)] |
77 [TestCase(typeof(int), typeof(int), true)] | 60 [TestCase(typeof(int), typeof(int), true)] |
78 [TestCase(typeof(ValueType), typeof(int), true)] | 61 [TestCase(typeof(ValueType), typeof(int), true)] |
79 [TestCase(typeof(long), typeof(int), false)] // | 62 [TestCase(typeof(long), typeof(int), false)] // |
80 public void IsAssignableFrom(Type target, Type argument, bool expected) | 63 public void IsAssignableFrom(Type target, Type argument, bool expected) |
81 { | 64 { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 107 } |
125 | 108 |
126 [Test] | 109 [Test] |
127 [TestCase(typeof(List<string>), "IndexOf")] | 110 [TestCase(typeof(List<string>), "IndexOf")] |
128 public void GetMethod_Ambiguous(Type type, string name) | 111 public void GetMethod_Ambiguous(Type type, string name) |
129 { | 112 { |
130 Assert.Throws<AmbiguousMatchException>(() => TypeExtensions.GetMetho
d(type, name)); | 113 Assert.Throws<AmbiguousMatchException>(() => TypeExtensions.GetMetho
d(type, name)); |
131 } | 114 } |
132 } | 115 } |
133 } | 116 } |
| 117 #endif |
OLD | NEW |