|
1 |
| -using System; |
2 | 1 | using System.Collections;
|
3 | 2 | using System.Collections.Generic;
|
4 | 3 | using NHibernate.Transform;
|
@@ -41,6 +40,43 @@ public struct TestStruct
|
41 | 40 | public string Something { get; set; }
|
42 | 41 | }
|
43 | 42 |
|
| 43 | + public class PublicPropertiesSimpleDTO |
| 44 | + { |
| 45 | + public object Id { get; set; } |
| 46 | + public string Name { get; set; } |
| 47 | + } |
| 48 | + |
| 49 | + public class PrivateFieldsSimpleDTO |
| 50 | + { |
| 51 | + private object id; |
| 52 | + private string name; |
| 53 | + |
| 54 | + public object Id { get { return id; } } |
| 55 | + public string Name { get { return name; } } |
| 56 | + } |
| 57 | + |
| 58 | + public class BasePublicPropsSimpleDTO |
| 59 | + { |
| 60 | + public object Id { get; set; } |
| 61 | + } |
| 62 | + |
| 63 | + public class PublicInheritedPropertiesSimpleDTO : BasePublicPropsSimpleDTO |
| 64 | + { |
| 65 | + public string Name { get; set; } |
| 66 | + } |
| 67 | + |
| 68 | + public class BasePrivateFieldSimpleDTO |
| 69 | + { |
| 70 | + private object id; |
| 71 | + public object Id { get { return id; } } |
| 72 | + } |
| 73 | + |
| 74 | + public class PrivateInheritedFieldsSimpleDTO : BasePrivateFieldSimpleDTO |
| 75 | + { |
| 76 | + private string name; |
| 77 | + public string Name { get { return name; } } |
| 78 | + } |
| 79 | + |
44 | 80 | #region Overrides of TestCase
|
45 | 81 |
|
46 | 82 | protected override IList Mappings
|
@@ -77,6 +113,99 @@ public void WorkWithOutPublicParameterLessCtor()
|
77 | 113 | }
|
78 | 114 | }
|
79 | 115 |
|
| 116 | + [Test] |
| 117 | + public void ToPublicProperties_WithoutAnyProjections() |
| 118 | + { |
| 119 | + try |
| 120 | + { |
| 121 | + Setup(); |
| 122 | + |
| 123 | + using (ISession s = OpenSession()) |
| 124 | + { |
| 125 | + var transformer = Transformers.AliasToBean<PublicPropertiesSimpleDTO>(); |
| 126 | + IList<PublicPropertiesSimpleDTO> l = s.CreateSQLQuery("select * from Simple") |
| 127 | + .SetResultTransformer(transformer) |
| 128 | + .List<PublicPropertiesSimpleDTO>(); |
| 129 | + Assert.That(l.Count, Is.EqualTo(2)); |
| 130 | + Assert.That(l, Has.All.Not.Null); |
| 131 | + } |
| 132 | + } |
| 133 | + finally |
| 134 | + { |
| 135 | + Cleanup(); |
| 136 | + } |
| 137 | + } |
| 138 | + |
| 139 | + [Test] |
| 140 | + public void ToPrivateFields_WithoutAnyProjections() |
| 141 | + { |
| 142 | + try |
| 143 | + { |
| 144 | + Setup(); |
| 145 | + |
| 146 | + using (ISession s = OpenSession()) |
| 147 | + { |
| 148 | + var transformer = Transformers.AliasToBean<PrivateFieldsSimpleDTO>(); |
| 149 | + IList<PrivateFieldsSimpleDTO> l = s.CreateSQLQuery("select * from Simple") |
| 150 | + .SetResultTransformer(transformer) |
| 151 | + .List<PrivateFieldsSimpleDTO>(); |
| 152 | + Assert.That(l.Count, Is.EqualTo(2)); |
| 153 | + Assert.That(l, Has.All.Not.Null); |
| 154 | + } |
| 155 | + } |
| 156 | + finally |
| 157 | + { |
| 158 | + Cleanup(); |
| 159 | + } |
| 160 | + } |
| 161 | + |
| 162 | + [Test] |
| 163 | + public void ToInheritedPublicProperties_WithoutProjections() |
| 164 | + { |
| 165 | + try |
| 166 | + { |
| 167 | + Setup(); |
| 168 | + |
| 169 | + using (ISession s = OpenSession()) |
| 170 | + { |
| 171 | + var transformer = Transformers.AliasToBean<PublicInheritedPropertiesSimpleDTO>(); |
| 172 | + IList<PublicInheritedPropertiesSimpleDTO> l = s.CreateSQLQuery("select * from Simple") |
| 173 | + .SetResultTransformer(transformer) |
| 174 | + .List<PublicInheritedPropertiesSimpleDTO>(); |
| 175 | + Assert.That(l.Count, Is.EqualTo(2)); |
| 176 | + Assert.That(l, Has.All.Not.Null); |
| 177 | + } |
| 178 | + } |
| 179 | + finally |
| 180 | + { |
| 181 | + Cleanup(); |
| 182 | + } |
| 183 | + } |
| 184 | + |
| 185 | + [Test] |
| 186 | + public void ToInheritedPrivateFields_WithoutProjections() |
| 187 | + { |
| 188 | + try |
| 189 | + { |
| 190 | + Setup(); |
| 191 | + |
| 192 | + using (ISession s = OpenSession()) |
| 193 | + { |
| 194 | + var transformer = Transformers.AliasToBean<PrivateInheritedFieldsSimpleDTO>(); |
| 195 | + IList<PrivateInheritedFieldsSimpleDTO> l = s.CreateSQLQuery("select * from Simple") |
| 196 | + .SetResultTransformer(transformer) |
| 197 | + .List<PrivateInheritedFieldsSimpleDTO>(); |
| 198 | + Assert.That(l.Count, Is.EqualTo(2)); |
| 199 | + Assert.That(l, Has.All.Not.Null); |
| 200 | + Assert.That(l, Has.All.Property("Id").Not.Null); |
| 201 | + } |
| 202 | + } |
| 203 | + finally |
| 204 | + { |
| 205 | + Cleanup(); |
| 206 | + } |
| 207 | + } |
| 208 | + |
80 | 209 | [Test]
|
81 | 210 | public void WorkWithPublicParameterLessCtor()
|
82 | 211 | {
|
|
0 commit comments