コード例 #1
0
 public void Init()
 {
     _customerServiceMock = new Mock <ICustomerService>();
     _httpAccessorMock    = new Mock <IHttpContextAccessor>();
     _customerSettings    = new CustomerSettings();
     _cookieAuthService   = new CookieAuthenticationService(_customerSettings, _customerServiceMock.Object, _httpAccessorMock.Object);
     //For mock HttpContext extension methods like SignOutAsync ,SignInAsync etc..
     _authServiceMock    = new Mock <IAuthenticationService>();
     serviceProviderMock = new Mock <IServiceProvider>();
     serviceProviderMock
     .Setup(_ => _.GetService(typeof(IAuthenticationService)))
     .Returns(_authServiceMock.Object);
     _httpContext = new DefaultHttpContext()
     {
         RequestServices = serviceProviderMock.Object
     };
     _httpAccessorMock.Setup(c => c.HttpContext).Returns(_httpContext);
 }
コード例 #2
0
 public void Init()
 {
     _customerServiceMock     = new Mock <ICustomerService>();
     _genericAttributeService = new Mock <IGenericAttributeService>().Object;
     _httpAccessorMock        = new Mock <IHttpContextAccessor>();
     _customerSettings        = new CustomerSettings();
     _config = new GrandConfig();
     _config.CookieClaimsIssuer = "grandnode";
     _config.CookiePrefix       = ".Grand.";
     _cookieAuthService         = new CookieAuthenticationService(_customerSettings, _customerServiceMock.Object, _genericAttributeService, _httpAccessorMock.Object, _config);
     //For mock HttpContext extension methods like SignOutAsync ,SignInAsync etc..
     _authServiceMock    = new Mock <IAuthenticationService>();
     serviceProviderMock = new Mock <IServiceProvider>();
     serviceProviderMock
     .Setup(_ => _.GetService(typeof(IAuthenticationService)))
     .Returns(_authServiceMock.Object);
     _httpContext = new DefaultHttpContext()
     {
         RequestServices = serviceProviderMock.Object
     };
     _httpAccessorMock.Setup(c => c.HttpContext).Returns(_httpContext);
 }
 public HeaderViewComponent(CookieAuthenticationService authenticationService)
 {
     _authenticationService = authenticationService;
 }
コード例 #4
0
 public AuthController(OnlineShopContext context, ISmsService smsService, CookieAuthenticationService userService)
 {
     this.context     = context;
     this.smsService  = smsService;
     this.userService = userService;
 }
コード例 #5
0
 public UserController(CookieAuthenticationService authenticationService, DataContext dataContext)
 {
     _authenticationService = authenticationService;
     _dataContext           = dataContext;
 }