Exemple #1
0
        public void TestProjectController_Tools_ShouldReturnTheToolsView(string httpMethod, string userPermisison)
        {
            SetUpProjectControllerForTesting(httpMethod);

            if (userPermisison == "UserHasPermission")
            {
                projectController.CurrentUser = user;

                ViewResult result = projectController.Tools() as ViewResult;

                Assert.That(result, Is.Not.EqualTo(null));

                List <ToolModel> model = result.Model as List <ToolModel>;

                Assert.That(model, Is.Not.EqualTo(null));
                Assert.That(model.Count, Is.GreaterThan(0));
                Assert.That(model.Count, Is.GreaterThan(8));

                if (model.Count > 8)
                {
                    Assert.That(model[0].Name, Is.EqualTo("VRV Xpress"));
                    Assert.That(model[1].Name, Is.EqualTo("WEBXpress (VRV)"));
                    Assert.That(model[2].Name, Is.EqualTo("Ventilation Xpress"));
                    Assert.That(model[3].Name, Is.EqualTo("8-Zone Multi-Split Selection Tool"));
                    Assert.That(model[4].Name, Is.EqualTo("Psychrometric Tool"));
                    Assert.That(model[5].Name, Is.EqualTo("Unit Converter"));
                    Assert.That(model[6].Name, Is.EqualTo("Ventilation Rate Calculator"));
                    Assert.That(model[7].Name, Is.EqualTo("VRV Refrigerant Charge Calculator"));
                    Assert.That(model[8].Name, Is.EqualTo("VRV Mechanical Schedule Generator"));
                }
            }
            if (userPermisison == "UserDoesNotHavePermission")
            {
                projectController.CurrentUser        = new UserSessionModel();
                projectController.CurrentUser.UserId = 1234;

                ViewResult result = projectController.Tools() as ViewResult;

                Assert.That(result, Is.Not.EqualTo(null));

                List <ToolModel> model = result.Model as List <ToolModel>;

                Assert.That(model, Is.Not.EqualTo(null));
                Assert.That(model.Count, Is.EqualTo(0));
            }
        }