コード例 #1
0
ファイル: Global.asax.cs プロジェクト: arthis/furry-journey
        protected void Application_Start()
        {
            

            Action<User> saveUserToSession = (account) =>
            {
                HttpContext.Current.Session.Remove("User");
                HttpContext.Current.Session.Add("User", account);
            };
            Func<User> getFromSession = () => (User)HttpContext.Current.Session["User"];

            var memoryDataSourceUser = new Dictionary<string, User>();

            //sample initialization
            memoryDataSourceUser.Add("wow", new User() { Id = Guid.Parse("537c8609-ddbe-434f-9e74-b2f55b9a35da"),  Name = "wow", Password = "******" });
            memoryDataSourceUser.Add("wah", new User() { Id = Guid.Parse("2939c3e6-0ee6-4167-a8aa-f5e95e58edee"),  Name = "wah", Password = "******" }); 
            

            //var repoAccount = new MemoryRepoAccount(new Dictionary<Guid, Account>());
            var repoAccount = new FileSystemRepoAccount();
            var serviceAccount = new ServiceAccount(repoAccount);

            var repoUser = new MemoryRepoUser(memoryDataSourceUser);
            var serviceUser = new ServiceUser(repoUser, saveUserToSession, getFromSession);

            var filterConfig = new FilterConfig(serviceUser);

            var controllerFactory = new PoorManControllerFactory(serviceUser,serviceAccount);
            ControllerBuilder.Current.SetControllerFactory(controllerFactory);

            AreaRegistration.RegisterAllAreas();
            filterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
コード例 #2
0
ファイル: RepoUserTests.cs プロジェクト: arthis/furry-journey
        public void Authenticate()
        {
            var expecteUser = new User() { Name = "wow", Password = "******" };
            var ds = new Dictionary<string, User>() { { "wow", expecteUser } };
            IRepoUser repo = new MemoryRepoUser(ds);

            var result = repo.Get("wow");

            Assert.AreEqual(expecteUser, result);

        }