public void SetUp() { _wholesalerService = Substitute.For <IWholesalerService>(); _wholesalersController = new WholesalersController(_wholesalerService); Mapper.Initialize(c => c.AddProfile <MappingProfile>()); _contextBase = Substitute.For <HttpContextBase>(); _contextBase.User.Identity.Name.Returns("JohnDoe"); _contextBase.Request.IsAuthenticated.Returns(true); _contextBase.User.IsInRole("Admin").Returns(true); _wholesalersController.ControllerContext = new ControllerContext(_contextBase, new RouteData(), _wholesalersController); }
public void SetUp() { // DAL _dbSet = Substitute.For <DbSet <Wholesaler> >(); _context = Substitute.For <ApplicationDbContext>(); _context.Set <Wholesaler>().Returns(_dbSet); UnityConfig.GetConfiguredContainer().RegisterInstance <IApplicationDbContext>(_context); // BLL Mapper.Initialize(c => c.AddProfile <MappingProfile>()); // UI _wholesalersController = UnityConfig.GetConfiguredContainer().Resolve <WholesalersController>(); // Identity _contextBase = Substitute.For <HttpContextBase>(); _contextBase.User.Identity.Name.Returns("JohnDoe"); _contextBase.Request.IsAuthenticated.Returns(true); _contextBase.User.IsInRole("Admin").Returns(true); _wholesalersController.ControllerContext = new ControllerContext(_contextBase, new RouteData(), _wholesalersController); }