Inheritance: Controller
Esempio n. 1
0
        public void TestCreateReturnView()
        {
            testController = new RuleController(mockRuleService.Object);
            ViewResult result = testController.Create() as ViewResult;

            Assert.IsNotNull(result, "No View was returned.");
            Assert.AreEqual("Create", result.ViewName);
        }
        public RuleControllerTests()
        {
            Controller = new RuleController();

            Request = new Mock<HttpRequestBase>(MockBehavior.Strict);
            Request.SetupGet(x => x.ApplicationPath).Returns("/");
            Request.SetupGet(x => x.Url).Returns(new Uri("http://localhost/a", UriKind.Absolute));
            Request.SetupGet(x => x.ServerVariables).Returns(new System.Collections.Specialized.NameValueCollection());

            Response = new Mock<HttpResponseBase>(MockBehavior.Strict);
        }
Esempio n. 3
0
        public void TestDeleteConfirmed()
        {
            mockRuleService.Setup(ruleService => ruleService.Delete(TESTIDTHREE))
                .Verifiable();

            testController = new RuleController(mockRuleService.Object);
            RedirectToRouteResult result = testController
                .DeleteConfirmed(TESTIDTHREE) as RedirectToRouteResult;

            Assert.IsNotNull(result, "No RedirectResult thingy was returned.");
            mockRuleService.Verify();
        }
Esempio n. 4
0
        public void TestCreateRule()
        {
            mockRuleService.Setup(rules => rules.Create(mockRuleSets[0])).
                Returns(mockRuleSets[1]).Verifiable();

            testController = new RuleController(mockRuleService.Object);
            RedirectToRouteResult result = testController
                .Create(testRuleDetailsOne) as RedirectToRouteResult;

            Assert.IsNotNull(result, "No RedirectResult thingy was returned.");
            mockRuleService.Verify();
        }
Esempio n. 5
0
        public void UploadViewReturn()
        {
            testController = new RuleController(mockRuleService.Object);
            ViewResult result = testController.Upload() as ViewResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("Upload", result.ViewName);
        }
Esempio n. 6
0
        public void TestIndexGetAllRuleSets()
        {
            mockRuleService.Setup(rules => rules.GetAllRulesets())
                .Returns(mockRuleSets).Verifiable();

            testController = new RuleController(mockRuleService.Object);
            ViewResult result = testController.Index() as ViewResult;
            List<RuleSet> ruleSets = (List<RuleSet>)result.ViewData.Model;

            Assert.IsNotNull(ruleSets, "The rules weren't returned.");
            Assert.AreEqual(TESTIDONE, ruleSets[0].RuleSetId);
            mockRuleService.Verify();
        }
Esempio n. 7
0
        public void TestEditDetailsHttpReturn()
        {
            RulesetDetails testNullRulesetDetails = null;
            mockRuleService.Setup(rules => rules.Details(TESTIDONE))
                .Returns(testNullRulesetDetails).Verifiable();

            testController = new RuleController(mockRuleService.Object);
            var result = testController.Edit(TESTIDONE) as HttpNotFoundResult;

            Assert.AreEqual(404, result.StatusCode);
            mockRuleService.Verify();
        }
Esempio n. 8
0
        public void TestEditDetailsGET()
        {
            mockRuleService.Setup(rules => rules.Details(TESTIDTWO))
                .Returns(testRuleDetailsTwo).Verifiable();

            testController = new RuleController(mockRuleService.Object);
            ViewResult result = testController.Edit(TESTIDTWO) as ViewResult;
            RulesetDetails ruleset = (RulesetDetails)result.Model;
            short status = 1;

            Assert.IsNotNull(ruleset, "The rule's details weren't returned.");
            Assert.AreEqual(TESTIDTWO, ruleset.rulesetWrapper.RuleSetId);
            Assert.AreEqual("Second Test", ruleset.rulesetWrapper.RuleSet1);
            Assert.AreEqual("Test RuleSet 2", ruleset.rulesetWrapper.Name);
            Assert.AreEqual(status, ruleset.rulesetWrapper.Status);
            mockRuleService.Verify();
        }
Esempio n. 9
0
        public void TestEditDetails()
        {
            mockRuleService.Setup(rules => rules.Edit(mockRuleSets[0]))
                .Returns(mockRuleSets[0]).Verifiable();

            testController = new RuleController(mockRuleService.Object);
            RedirectToRouteResult result = testController
                .Edit(testRuleDetailsOne) as RedirectToRouteResult;

            Assert.IsNotNull(result);
            mockRuleService.Verify();
        }
Esempio n. 10
0
        public void TestDetailsGetId()
        {
            mockRuleService.Setup(rules => rules.Details(TESTIDONE))
                .Returns(testRuleDetailsOne).Verifiable();

            testController = new RuleController(mockRuleService.Object);
            ViewResult result = testController.Details(TESTIDONE) as ViewResult;
            RulesetDetails ruleset = (RulesetDetails)result.Model;

            Assert.IsNotNull(ruleset, "The rule's Details weren't retrieved.");
            Assert.AreEqual(mockRuleSets[0].RuleSet1,
                ruleset.rulesetWrapper.RuleSet1,
                "The details returned weren't correct.");
            mockRuleService.Verify();
        }
Esempio n. 11
0
        public void TestDeleteRuleset()
        {
            mockRuleService.Setup(rules => rules.Details(TESTIDTHREE))
                .Returns(testRuleDetailsThree).Verifiable();

            testController = new RuleController(mockRuleService.Object);
            ViewResult result = testController.Delete(TESTIDTHREE) as ViewResult;
            RulesetDetails ruleset = (RulesetDetails)result.Model;

            Assert.IsNotNull(ruleset, "The rule selected for deletion wasn't returned.");
            Assert.AreEqual(TESTIDTHREE, ruleset.rulesetWrapper.RuleSetId);
            mockRuleService.Verify();
        }