Example #1
0
        public async Task <ActionResult> Block(Domain.Models.DomainType blockType, string name)
        {
            //Used by voat.js
            var cmd    = new BlockCommand(blockType, name, true);
            var result = await cmd.Execute();

            if (Request.IsAjaxRequest())
            {
                return(Json(result));
            }
            else
            {
                return(await Blocked(blockType, null));
            }
        }
        public async Task <JsonResult> BlockSubverse(string subverseName)
        {
            var loggedInUser = User.Identity.Name;
            var cmd          = new BlockCommand(Domain.Models.DomainType.Subverse, subverseName).SetUserContext(User);
            var response     = await cmd.Execute();

            if (response.Success)
            {
                return(Json("Subverse block request was successful." /* CORE_PORT: Removed , JsonRequestBehavior.AllowGet */));
            }
            else
            {
                Response.StatusCode = 400;
                return(Json(response.Message /* CORE_PORT: Removed , JsonRequestBehavior.AllowGet */));
            }
        }
Example #3
0
        public async Task QuerySubmissions_Verify_BlockedSubverses()
        {
            //Ensure v/unit does not show up in v/all for user BlocksUnit
            TestHelper.SetPrincipal("BlocksUnit");

            var cmd = new BlockCommand(Domain.Models.DomainType.Subverse, "unit");
            var r   = await cmd.Execute();

            var q = new QuerySubmissions("_all", SearchOptions.Default);
            //q.CachePolicy.Duration = cacheTime; //Cache this request
            var result = q.ExecuteAsync().Result;

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any(), "Found no results");

            foreach (var s in result)
            {
                Assert.AreNotEqual("unit", s.Subverse.ToLower(), "Found blocked sub in BlocksUnit's v/all query");
            }
        }
Example #4
0
        public async Task <ActionResult> BlockUser(string name)
        {
            var cmd    = new BlockCommand(Domain.Models.DomainType.User, name, false);
            var result = await cmd.Execute();

            if (Request.IsAjaxRequest())
            {
                return(Json(result));
            }
            else
            {
                if (!result.Success)
                {
                    ModelState.AddModelError("", result.Message);
                    return(await Blocked(Domain.Models.DomainType.User, null));
                }
                else
                {
                    return(Redirect("/user/blocked/user"));
                }
            }
        }
        public async Task QuerySubmissions_Verify_BlockedSubverses()
        {
            VerifyValidHandler();

            //Ensure v/unit does not show up in v/all for user BlocksUnit
            var user = TestHelper.SetPrincipal("BlocksUnit");

            var cmd = new BlockCommand(Domain.Models.DomainType.Subverse, SUBVERSES.Unit).SetUserContext(user);
            var r   = await cmd.Execute();

            var q = new QuerySubmissions(new Domain.Models.DomainReference(Domain.Models.DomainType.Subverse, "_all"), SearchOptions.Default).SetUserContext(user);

            q.CacheHandler = handler;
            //q.CachePolicy.Duration = cacheTime; //Cache this request
            var result = await q.ExecuteAsync();

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any(), "Found no results");

            foreach (var s in result)
            {
                Assert.AreNotEqual(SUBVERSES.Unit.ToLower(), s.Subverse.ToLower(), "Found blocked sub in BlocksUnit's v/all query");
            }
        }
Example #6
0
    private void Update()
    {
        accumMx += Input.GetAxisRaw("Mouse X") * Time.deltaTime;
        if (Mathf.Abs(accumMx) > lockOnChangeMx && LockOnTarget != null)
        {
            accumMx = 0f;
            if (lockOnChange.IsValid())
            {
                lockOnChange.Execute(accumMx);
            }
        }
        accumMx = Mathf.Lerp(accumMx, 0f, Time.deltaTime);

        if (!player.IsInAnyState(States.Dodging))
        {
            RotationUpdate();
        }

        if (LockOnTarget != null)
        {
            if (LockOnTarget.IsInAnyState(States.Dead))
            {
                LockOnTarget = null;
            }
        }

        if (Input.GetButtonDown("Dodge"))
        {
            if (dodge.IsValid())
            {
                dodge.Execute();
            }
        }
        if (Input.GetButtonDown("LightAttack"))
        {
            if (attack.IsValid())
            {
                attack.Execute(0);
            }
        }
        if (Input.GetButtonDown("HeavyAttack"))
        {
            if (attack.IsValid())
            {
                attack.Execute(1);
            }
        }
        if (Input.GetButtonDown("LockOn"))
        {
            if (lockOn.IsValid())
            {
                lockOn.Execute();
            }
        }



        if (block.IsValid())
        {
            block.Execute(Input.GetButton("Block"));
        }
    }
Example #7
0
        public async Task Block_Lifecycle_Tests()
        {
            var userName = "******";
            var subName  = SUBVERSES.Unit;

            TestDataInitializer.CreateUser(userName);
            var user = TestHelper.SetPrincipal(userName);

            //Verify No Front / Blocked Sets
            var userBlockQuery   = new QueryUserBlocks(userName).SetUserContext(user);
            var userBlockResults = await userBlockQuery.ExecuteAsync();

            Assert.IsNotNull(userBlockResults, "Old McDonald had a farm ee i ee i o. And on that farm he shot some guys. Badda boom badda bing bang boom.");
            Assert.AreEqual(0, userBlockResults.Count(), "He is supposed to be Turkish. Some say his father was German. Nobody believed he was real.");

            var userSetQuery   = new QueryUserSets(userName).SetUserContext(user);
            var userSetResults = await userSetQuery.ExecuteAsync();

            Assert.IsNotNull(userSetResults, "One cannot be betrayed if one has no people.");
            Assert.AreEqual(0, userSetResults.Count(), "A man can convince anyone he's somebody else, but never himself.");

            var currentSubscriberCount = 0;

            using (var db = new VoatDataContext())
            {
                var count = db.Subverse.First(x => x.Name == subName).SubscriberCount;
                currentSubscriberCount = count.HasValue ? count.Value : 0;
            }

            //Sub a user to front
            var domainReference = new DomainReference(DomainType.Subverse, subName);
            var blockCmd        = new BlockCommand(domainReference.Type, domainReference.Name, true).SetUserContext(user);
            var blockResult     = await blockCmd.Execute();

            //Verify Front is created
            userBlockQuery   = new QueryUserBlocks(userName).SetUserContext(user);
            userBlockResults = await userBlockQuery.ExecuteAsync();

            Assert.IsNotNull(userBlockResults, "What about it, pretzel man? What's your story?");
            Assert.AreEqual(1, userBlockResults.Count(), "First day on the job, you know what I learned? How to spot a murderer.");
            Assert.IsTrue(userBlockResults.Any(x => x.Type == DomainType.Subverse && x.Name == subName), "It was Keyser Soze, Agent Kujan. I mean the Devil himself. How do you shoot the Devil in the back? What if you miss?");

            userSetQuery   = new QueryUserSets(userName).SetUserContext(user);
            userSetResults = await userSetQuery.ExecuteAsync();

            Assert.IsNotNull(userSetResults, "What the cops never figured out, and what I know now, was that these men would never break, never lie down, never bend over for anybody");
            Assert.AreEqual(1, userSetResults.Count(x => x.Type == SetType.Blocked), "Is it Friday already? ");
            var set = userSetResults.First(x => x.Type == SetType.Blocked);

            Assert.AreEqual(SetType.Blocked, set.Type, "I got a whole new problem when I post bail.");
            Assert.AreEqual(1, set.SubscriberCount, "I got a whole new problem when I post bail.");

            //Ensure Subverse Subscriber Count Updated
            using (var db = new VoatDataContext())
            {
                var tc    = db.Subverse.First(x => x.Name == subName).SubscriberCount;
                var count = tc.HasValue ? tc.Value : 0;
                Assert.AreEqual(currentSubscriberCount, count, "");
                currentSubscriberCount = count;
            }

            //verify FRONT set has sub
            using (var repo = new Voat.Data.Repository())
            {
                var setList = await repo.GetSetListDescription(SetType.Blocked.ToString(), userName);

                Assert.IsTrue(setList.Any(x => x.Name == subName));
            }

            //Unsubscribe
            blockCmd    = new BlockCommand(domainReference.Type, domainReference.Name, true).SetUserContext(user);
            blockResult = await blockCmd.Execute();

            VoatAssert.IsValid(blockResult);

            //Ensure Subverse Subscriber Count Updated
            using (var db = new VoatDataContext())
            {
                var count = db.Subverse.First(x => x.Name == subName).SubscriberCount;
                Assert.AreEqual(currentSubscriberCount, count.HasValue ? count.Value : 0, "");
            }

            //verify FRONT set has not sub
            using (var repo = new Voat.Data.Repository())
            {
                var setList = await repo.GetSetListDescription(SetType.Blocked.ToString(), userName);

                Assert.IsFalse(setList.Any(x => x.Name == subName));
            }
        }