Example #1
0
 public ManageController(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     IEmailSender emailSender,
     ILogger <ManageController> logger,
     JanuszMailDbContext context,
     UrlEncoder urlEncoder)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _emailSender   = emailSender;
     _logger        = logger;
     _urlEncoder    = urlEncoder;
     _context       = context;
 }
        public void SetUp()
        {
            mockProvider = new Mock <IProvider>();
            connection   = new SqliteConnection("DataSource=:memory:");
            connection.Open();
            var options = new DbContextOptionsBuilder <JanuszMailDbContext>().UseSqlite(connection).Options;

            mockDbContext = new JanuszMailDbContext(options);
            mockDbContext.Database.Migrate();
            mockUserManager = new Mock <FakeUserManager>();
            controller      = new MailBoxController(mockProvider.Object, mockUserManager.Object, mockDbContext);
            fakeUser        = new ApplicationUser()
            {
                Id = "user1"
            };
            mockUserManager.Setup(Manager => Manager.GetUserAsync(It.IsAny <ClaimsPrincipal>())).Returns(Task.FromResult(fakeUser));

            urlHelper = new Mock <IUrlHelper>();
            urlHelper.Setup(x => x.Link(It.IsAny <string>(), It.IsAny <object>())).Returns("http://localhost");
            controller.Url = urlHelper.Object;
            controller.ControllerContext.HttpContext = new DefaultHttpContext();
            controller.HttpContext.Session           = new MockSession();
            controller.TempData = new TempDataDictionary(new Mock <HttpContext>().Object, new Mock <ITempDataProvider>().Object);
        }
Example #3
0
 public MailBoxController(IProvider provider, UserManager <ApplicationUser> userManager, JanuszMailDbContext dbContext)
 {
     this._provider         = provider;
     this._userManager      = userManager;
     this._dbContext        = dbContext;
     this._mailBoxViewModel = new MailBoxViewModel();
 }
Example #4
0
 public ContactsController(JanuszMailDbContext context, UserManager <ApplicationUser> userManager)
 {
     _context     = context;
     _userManager = userManager;
 }