예제 #1
0
        public void Set_Returns_Chart_For_Users_Company()
        {
            ActionResult result = null;

            Act(() =>
            {
                IExecutionContext executionContext = Substitute.For <IExecutionContext>();
                executionContext.UserId.Returns(userId);
                var controller = new MacController(_session, executionContext);
                result         = controller.Set(ChartIdUtilities.GetInt(_companyAChartIds.First(), typeof(Chart)));
            });

            Assert.IsInstanceOf <ViewResult>(result);
            Assert.AreEqual(_companyAChartIds.First(), ((Chart)((ViewResult)result).Model).Id);
        }
예제 #2
0
        public void Set_Cannot_Access_Chart_For_Company_Not_Belonged_To_By_User()
        {
            ActionResult result = null;

            Act(() =>
            {
                IExecutionContext executionContext = Substitute.For <IExecutionContext>();
                executionContext.UserId.Returns(userId);
                var controller = new MacController(_session, executionContext);
                result         = controller.Set(ChartIdUtilities.GetInt(_companyBChartId, typeof(Chart)));
            });

            Assert.IsInstanceOf <RedirectResult>(result);
            Assert.AreEqual("~/", ((RedirectResult)result).Url);
        }