本文整理汇总了C#中RepositoryFactory.GetRepository方法的典型用法代码示例。如果您正苦于以下问题:C# RepositoryFactory.GetRepository方法的具体用法?C# RepositoryFactory.GetRepository怎么用?C# RepositoryFactory.GetRepository使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RepositoryFactory
的用法示例。
在下文中一共展示了RepositoryFactory.GetRepository方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Factory_Should_Return_Cached_Repository
public void Factory_Should_Return_Cached_Repository()
{
var factory = new RepositoryFactory(TestEnvironment.GetSqlServerDataProvider());
var repository = factory.GetRepository<Product>();
var cachedRepository = factory.GetRepository<Product>();
Assert.AreEqual(repository, cachedRepository);
}
示例2: Test_GetDao_AllreadyUsed_SameFactoryIsReturned
public void Test_GetDao_AllreadyUsed_SameFactoryIsReturned()
{
var factoryMock = new Mock<IRepositoryFactory>();
var factory = factoryMock.Object;
var sut = new RepositoryFactory(factory, null, NHibernateHelper);
var firstTime = sut.GetRepository<IIdentifiable>();
Assert.That(sut.GetRepository<IIdentifiable>(), Is.SameAs(firstTime));
}
示例3: GrassrootsMembershipService
public GrassrootsMembershipService()
{
var userProfileRepositoryFactory = new RepositoryFactory<IUserProfileRepository>();
userProfileRepository = userProfileRepositoryFactory.GetRepository();
var userRepositoryFactory = new RepositoryFactory<IUserRepository>();
userRepository = userRepositoryFactory.GetRepository();
}
示例4: Factory_Should_Return_Repository
public void Factory_Should_Return_Repository()
{
var factory = new RepositoryFactory(TestEnvironment.GetSqlServerDataProvider());
var repository = factory.GetRepository<Product>();
Assert.IsNotNull(repository);
}
示例5: GrassrootsRoleService
public GrassrootsRoleService()
{
var userProfileRepositoryFactory = new RepositoryFactory<IUserProfileRepository>();
userProfileRepository = userProfileRepositoryFactory.GetRepository();
var userRepositoryFactory = new RepositoryFactory<IUserRepository>();
userRepository = userRepositoryFactory.GetRepository();
var roleRepositoryFactory = new RepositoryFactory<IRoleRepository>();
roleRepository = roleRepositoryFactory.GetRepository();
}
示例6: Test_GetDao_FactorySupplied_VerifySuppliedFactoryCreateIsCalled
public void Test_GetDao_FactorySupplied_VerifySuppliedFactoryCreateIsCalled()
{
var factoryMock = new Mock<IRepositoryFactory>();
var factory = factoryMock.Object;
var sut = new RepositoryFactory(factory, null, NHibernateHelper);
sut.GetRepository<IIdentifiable>();
factoryMock.Verify(x => x.GetRepository<IIdentifiable>());
}
示例7: Must_Return_NULL_For_Invalid_Entity_If_It_Is_Not_In_Context
public void Must_Return_NULL_For_Invalid_Entity_If_It_Is_Not_In_Context()
{
//
// Arrange
//
var mockContext = new Mock<EFDbContext>();
var repositoryFacotory = new RepositoryFactory(mockContext.Object);
//
// Act
//
var result = repositoryFacotory.GetRepository<IModel>();
//
// Assert
//
Assert.IsNotNull(result);
}
示例8: Must_Return_Repository_For_Valid_Entity_Regardless_It_Was_Registered
public void Must_Return_Repository_For_Valid_Entity_Regardless_It_Was_Registered()
{
//
// Arrange
//
var mockDbSet = new Mock<DbSet<IModel>>();
var mockContext = new Mock<EFDbContext>();
mockContext.Setup(x => x.Set<IModel>()).Returns(mockDbSet.Object);
var repositoryFacotory = new RepositoryFactory(mockContext.Object);
//
// Act
//
var result = repositoryFacotory.GetRepository<IModel>();
//
// Assert
//
Assert.IsNotNull(result);
}
示例9: GetRoleSelectList
public static SelectList GetRoleSelectList(int? id)
{
RoleDictionary = new Dictionary<string, string>();
var repositoryFactory = new RepositoryFactory<IOrganizationRepository>();
var repository = repositoryFactory.GetRepository();
var organization = repository.GetDefaultOrganization(readOnly: true);
foreach (var role in organization.Roles)
{
RoleDictionary.Add(new KeyValuePair<string, string>(role.RoleID.ToString(CultureInfo.InvariantCulture), role.Name));
}
return new SelectList(RoleDictionary, "Key", "Value", id);
}
示例10: Must_Return_Repository_When_Registered
public void Must_Return_Repository_When_Registered()
{
//
// Arrange
//
var mockContext = new Mock<EFDbContext>();
var mockRepository = new Mock<IRepository<IModel>>();
var repositoryFactory = new RepositoryFactory(mockContext.Object);
repositoryFactory.SetCustomRepo(mockRepository.Object);
//
// Act
//
var result = repositoryFactory.GetRepository<IModel>();
//
// Assert
//
Assert.IsNotNull(result);
}
示例11: UserProfileService
public UserProfileService()
{
var repositoryFactory = new RepositoryFactory<IUserProfileRepository>();
userProfileRepository = repositoryFactory.GetRepository();
}
示例12: CampaignService
public CampaignService()
{
var repositoryFactory = new RepositoryFactory<ICampaignRepository>();
campaignRepository = repositoryFactory.GetRepository();;
}