本文整理汇总了C#中IUserService.Expect方法的典型用法代码示例。如果您正苦于以下问题:C# IUserService.Expect方法的具体用法?C# IUserService.Expect怎么用?C# IUserService.Expect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUserService
的用法示例。
在下文中一共展示了IUserService.Expect方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
userService = MockRepository.GenerateStub<IUserService>();
controller = new OrderStatusController(userService);
userService.Expect(x => x.CurrentUser).Return(new User { Id = 4 });
}
示例2: Setup
public void Setup()
{
basketRepository = MockRepository.GenerateStub<IRepository<Basket>>();
unitOfWorkManager = MockRepository.GenerateStub<IUnitOfWorkManager>();
userService = MockRepository.GenerateStub<IUserService>();
postageService = MockRepository.GenerateStub<IPostageService>();
countryRepository = MockRepository.GenerateStub<IRepository<Country>>();
cardTypeRepository = MockRepository.GenerateStub<IRepository<CardType>>();
orderRepository = MockRepository.GenerateStub<IRepository<Order>>();
subscriptionRepository = MockRepository.GenerateStub<IRepository<MailingListSubscription>>();
emailService = MockRepository.GenerateStub<IEmailService>();
var mocks = new MockRepository(); //TODO: No need to partial mock once email sending is fixed
controller = new CheckoutController(
basketRepository,
userService,
postageService,
countryRepository,
cardTypeRepository,
orderRepository,
unitOfWorkManager,
emailService,
subscriptionRepository
);
mocks.ReplayAll();
userService.Expect(us => us.CurrentUser).Return(new User { UserId = 4, RoleId = Role.AdministratorId });
}
示例3: Setup
public void Setup()
{
user = new User();
userService = MockRepository.GenerateStub<IUserService>();
userService.Expect(x => x.CurrentUser).Return(user);
binder = new CurrentBasketBinder(userService);
}
示例4: Setup
public void Setup()
{
userService = MockRepository.GenerateStub<IUserService>();
repository = MockRepository.GenerateStub<IRepository<Order>>();
emailService = MockRepository.GenerateStub<IEmailService>();
controller = new OrderStatusController(repository, userService, emailService);
userService.Expect(x => x.CurrentUser).Return(new User() { UserId = 4 });
}
示例5: SetUp
public void SetUp()
{
productRepository = MockRepository.GenerateStub<IRepository<Product>>();
contentRepository = MockRepository.GenerateStub<IRepository<Content>>();
userService = MockRepository.GenerateStub<IUserService>();
siteMapController = new SiteMapController(productRepository, contentRepository, userService);
userService.Expect(c => c.CurrentUser).Return(new User{ Role = Role.Guest });
}
示例6: Setup
public void Setup()
{
user = new User { Role = Role.Administrator };
userService = MockRepository.GenerateStub<IUserService>();
userService.Expect(x => x.CurrentUser).Return(user);
basketService = MockRepository.GenerateStub<IBasketService>();
basketService.Stub(b => b.GetCurrentBasketForCurrentUser()).Return(new Basket());
binder = new CurrentBasketBinder(userService, basketService);
}
示例7: SetUp
public void SetUp()
{
// you have to be an administrator to access the order controller
Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("admin"), new[] { "Administrator" });
orderRepository = MockRepository.GenerateStub<IRepository<Order>>();
countryRepository = MockRepository.GenerateStub<IRepository<Country>>();
cardTypeRepository = MockRepository.GenerateStub<IRepository<CardType>>();
encryptionService = MockRepository.GenerateStub<IEncryptionService>();
postageService = MockRepository.GenerateStub<IPostageService>();
userService = MockRepository.GenerateStub<IUserService>();
searchService = MockRepository.GenerateStub<IOrderSearchService>();
var mocks = new MockRepository();
statusRepository = MockRepository.GenerateStub<IRepository<OrderStatus>>();
orderController = new OrderController(
orderRepository,
countryRepository,
cardTypeRepository,
encryptionService,
postageService,
userService,
searchService,
statusRepository
);
testContext = new ControllerTestContext(orderController);
postageService.Expect(ps => ps.CalculatePostageFor(Arg<Order>.Is.Anything));
userService.Expect(us => us.CurrentUser).Return(new User { UserId = 4, RoleId = Role.AdministratorId });
testContext.TestContext.Context.User = new User { UserId = 4 };
testContext.TestContext.Request.RequestType = "GET";
testContext.TestContext.Request.Stub(r => r.QueryString).Return(new NameValueCollection());
testContext.TestContext.Request.Stub(r => r.Form).Return(new NameValueCollection());
statusRepository.Expect(x => x.GetAll()).Return(new List<OrderStatus>().AsQueryable());
mocks.ReplayAll();
}
示例8: SetUp
public void SetUp()
{
// you have to be an administrator to access the product controller
Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("admin"), new[] { "Administrator" });
categoryRepository = MockRepositoryBuilder.CreateCategoryRepository();
productRepository = MockRepositoryBuilder.CreateProductRepository();
MockRepository.GenerateStub<IRepository<ProductImage>>();
MockRepository.GenerateStub<IHttpFileService>();
sizeService = MockRepository.GenerateStub<ISizeService>();
productOrderableService = MockRepository.GenerateStub<IOrderableService<Product>>();
MockRepository.GenerateStub<IOrderableService<ProductImage>>();
userService = MockRepository.GenerateStub<IUserService>();
productController = new ProductController(productRepository, categoryRepository, sizeService, productOrderableService, userService, MockRepository.GenerateStub<IUnitOfWorkManager>());
userService.Expect(c => c.CurrentUser).Return(new User { RoleId = Role.AdministratorId });
}
示例9: InitializeTest
public void InitializeTest()
{
UserPasswordService.PasswordResetTokenMinutesTimeout = 10;
m_unitOfWork = new MemoryUnitOfWork();
m_userService = MockRepository.GenerateMock<IUserService>();
var tokenId = 0;
m_tokenRepository = new MemoryRepository<UserPasswordResetToken>(m_unitOfWork, (o) => ++tokenId);
var token = new UserPasswordResetToken() { Code = Guid.NewGuid(), UserId = 3 };
m_tokenRepository.Add(token);
var historyId = 0;
m_historyRepository = new MemoryRepository<UserPasswordHistory>(m_unitOfWork, (o) => ++historyId);
m_target = new UserPasswordService(m_tokenRepository, m_historyRepository, m_userService);
m_userService.Expect(e => e.GetById(1)).Return(new User() { Id = 1, Password = m_target.Encrypt("11"), Email = "[email protected]" });
m_userService.Expect(e => e.GetById(2)).Return(new User() { Id = 2, Password = m_target.Encrypt("22"), Email = "[email protected]" });
m_userService.Expect(e => e.GetById(3)).Return(new User() { Id = 3, Password = m_target.Encrypt("33"), Email = "[email protected]" });
m_userService.Expect(e => e.GetByEmail("test[email protected]")).Return(new User() { Id = 1, Password = m_target.Encrypt("11"), Email = "[email protected]" });
m_userService.Expect(e => e.GetByEmail("[email protected]")).Return(new User() { Id = 2, Password = m_target.Encrypt("22"), Email = "[email protected]" });
m_userService.Expect(e => e.GetByEmail("[email protected]")).Return(new User() { Id = 3, Password = m_target.Encrypt("33"), Email = "[email protected]" });
m_unitOfWork.Commit();
}