1- // Licensed to the Xtensive LLC under one or more agreements .
2- // The Xtensive LLC licenses this file to you under the MIT license.
3- // See the LICENSE file in the project root for more information.
1+ // Copyright (C) 2020 Xtensive LLC.
2+ // This code is distributed under MIT license terms .
3+ // See the License.txt file in the project root for more information.
44
55using System ;
66using System . Collections . Generic ;
77using System . Linq ;
88using NUnit . Framework ;
99using Xtensive . Orm . Configuration ;
10+ using Xtensive . Orm . Tests . Issues . MaterializationMethodTestsModel ;
1011
1112namespace Xtensive . Orm . Tests . Issues
1213{
@@ -24,51 +25,50 @@ public Person(Session session) : base(session) { }
2425 public string Name { get ; set ; }
2526 }
2627
27- }
28-
29- public class PersonModel
30- {
31- public int Id { get ; set ; }
32- public string Name { get ; set ; }
33- }
28+ public class PersonModel
29+ {
30+ public int Id { get ; set ; }
31+ public string Name { get ; set ; }
32+ }
3433
35- public abstract class ServiceBase < TEntity , TModel > where TModel : class , new ( ) where TEntity : class , IEntity
36- {
37- public IList < TModel > GetAllViaPrivate ( Session session ) =>
38- session . Query . All < TEntity > ( ) . Select ( i => PrivateSelect ( i ) ) . ToList ( ) ;
34+ public abstract class ServiceBase < TEntity , TModel > where TModel : class , new ( ) where TEntity : class , IEntity
35+ {
36+ public IList < TModel > GetAllViaPrivate ( Session session ) =>
37+ session . Query . All < TEntity > ( ) . Select ( i => PrivateSelect ( i ) ) . ToList ( ) ;
3938
40- public IList < TModel > GetAllViaPublic ( Session session ) =>
41- session . Query . All < TEntity > ( ) . Select ( i => PublicSelect ( i ) ) . ToList ( ) ;
39+ public IList < TModel > GetAllViaPublic ( Session session ) =>
40+ session . Query . All < TEntity > ( ) . Select ( i => PublicSelect ( i ) ) . ToList ( ) ;
4241
43- public IList < TModel > GetAllViaProtected ( Session session ) =>
44- session . Query . All < TEntity > ( ) . Select ( i => ProtectedSelect ( i ) ) . ToList ( ) ;
42+ public IList < TModel > GetAllViaProtected ( Session session ) =>
43+ session . Query . All < TEntity > ( ) . Select ( i => ProtectedSelect ( i ) ) . ToList ( ) ;
4544
46- public IList < TModel > GetAllViaInternal ( Session session ) =>
47- session . Query . All < TEntity > ( ) . Select ( i => InternalSelect ( i ) ) . ToList ( ) ;
45+ public IList < TModel > GetAllViaInternal ( Session session ) =>
46+ session . Query . All < TEntity > ( ) . Select ( i => InternalSelect ( i ) ) . ToList ( ) ;
4847
49- public IList < TModel > GetAllViaProtectedInternal ( Session session ) =>
50- session . Query . All < TEntity > ( ) . Select ( i => ProtectedInternalSelect ( i ) ) . ToList ( ) ;
48+ public IList < TModel > GetAllViaProtectedInternal ( Session session ) =>
49+ session . Query . All < TEntity > ( ) . Select ( i => ProtectedInternalSelect ( i ) ) . ToList ( ) ;
5150
52- private TModel PrivateSelect ( TEntity entity ) => ProtectedSelect ( entity ) ;
53- public TModel PublicSelect ( TEntity entity ) => ProtectedSelect ( entity ) ;
54- internal TModel InternalSelect ( TEntity entity ) => ProtectedSelect ( entity ) ;
55- protected internal TModel ProtectedInternalSelect ( TEntity entity ) => ProtectedSelect ( entity ) ;
51+ private TModel PrivateSelect ( TEntity entity ) => ProtectedSelect ( entity ) ;
52+ public TModel PublicSelect ( TEntity entity ) => ProtectedSelect ( entity ) ;
53+ internal TModel InternalSelect ( TEntity entity ) => ProtectedSelect ( entity ) ;
54+ protected internal TModel ProtectedInternalSelect ( TEntity entity ) => ProtectedSelect ( entity ) ;
5655
57- protected abstract TModel ProtectedSelect ( TEntity entity ) ;
58- }
56+ protected abstract TModel ProtectedSelect ( TEntity entity ) ;
57+ }
5958
60- public class PersonService : ServiceBase < MaterializationMethodTestsModel . Person , PersonModel >
61- {
62- protected override PersonModel ProtectedSelect ( MaterializationMethodTestsModel . Person entity ) =>
63- new PersonModel { Id = entity . Id , Name = entity . Name } ;
59+ public class PersonService : ServiceBase < Person , PersonModel >
60+ {
61+ protected override PersonModel ProtectedSelect ( Person entity ) =>
62+ new PersonModel { Id = entity . Id , Name = entity . Name } ;
63+ }
6464 }
6565
66- public class ServiceMaterializationMethodTests : AutoBuildTest
66+ public class MaterializationMethodTest : AutoBuildTest
6767 {
6868 protected override DomainConfiguration BuildConfiguration ( )
6969 {
7070 var configuration = base . BuildConfiguration ( ) ;
71- var personType = typeof ( MaterializationMethodTestsModel . Person ) ;
71+ var personType = typeof ( Person ) ;
7272 configuration . Types . Register ( personType . Assembly , personType . Namespace ) ;
7373 return configuration ;
7474 }
@@ -85,6 +85,7 @@ protected override DomainConfiguration BuildConfiguration()
8585 ( service , session ) => service . GetAllViaProtectedInternal ( session ) ) ;
8686 }
8787
88+ [ Test ]
8889 [ TestCaseSource ( nameof ( DataExtractorMethods ) ) ]
8990 public void MaterializationByMethodOfBaseService (
9091 ( string name , Func < PersonService , Session , IList < PersonModel > > getPeopleMethod ) testCase )
0 commit comments