コード例 #1
0
        public void Setup()
        {
            // Builds webhost and gets service providers from web host
            var webHost = WebHost.CreateDefaultBuilder()
                          .UseStartup <Startup>()
                          .Build();

            _serviceProvider = new ServiceDependencyResolver(webHost);

            // Resets database to inital state so all tests are isolated and repeatable
            _context = new FlatManagementContext();
            _context.Database.EnsureDeleted();
            _context.Database.EnsureCreated();

            var testDataGenerator = new DevelopmentDatabaseSetup(_context);

            testDataGenerator.SetupDevelopmentDataSet();

            _flatController = new FlatController(_context);

            //Creates a new httpContext and adds a user identity to it, imitating being already logged in.
            DefaultHttpContext httpContext = new DefaultHttpContext();
            GenericIdentity    MyIdentity  = new GenericIdentity("YinWang");
            ClaimsIdentity     objClaim    = new ClaimsIdentity(new List <Claim> {
                new Claim(ClaimTypes.NameIdentifier, "1")
            });

            _flatController.ControllerContext             = new ControllerContext();
            _flatController.ControllerContext.HttpContext = httpContext;
            httpContext.User = new ClaimsPrincipal(objClaim);
        }
コード例 #2
0
 void Start()
 {
     if (PlayerPrefs.GetInt("Currentlevel") != 0)
     {
         Tutpanel.SetActive(false);
     }
     swp            = transform.GetComponent <SwipeControl>();
     currentpos     = transform.position.y;
     anim           = transform.GetComponent <Animator>();
     flatcontroller = GameObject.Find("FlatControl").GetComponent <FlatController>();
     flatcontroller.NextFloorEvent += MoveNextFloor;
 }
コード例 #3
0
        public void Setup()
        {
            _dbSetUpHelper     = new DatabaseSetUpHelper();
            _context           = _dbSetUpHelper.GetContext();
            _httpContextHelper = new HttpContextHelper();

            var httpContext = _httpContextHelper.GetHttpContext();
            var objClaim    = _httpContextHelper.GetClaimsIdentity();

            _flatController = new FlatController(_context)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = httpContext
                }
            };
            httpContext.User = new ClaimsPrincipal(objClaim);
        }