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); }
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(); }
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(); }
public void UploadViewReturn() { testController = new RuleController(mockRuleService.Object); ViewResult result = testController.Upload() as ViewResult; Assert.IsNotNull(result); Assert.AreEqual("Upload", result.ViewName); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }