Пример #1
0
        public void GET_List_ListOutputModel_RetrievesInfoString_From_TempData_InfoKey()
        {
            const string INFORMATION = "Information";
            const string INFO_KEY = "info";
            // Arrange

            var roleManager = new RoleManagerController();

            var builder = new TestControllerBuilder();

            builder.TempDataDictionary.Add(INFO_KEY, INFORMATION);

            builder.InitializeController(roleManager);

            var queryRoles = MockRepository.GenerateMock<IQueryService<Role>>();

            queryRoles.Expect(q => q.Query()).Return(new Role[] { }.AsQueryable());

            roleManager.ListOutputModel = new RoleManagerListOutputModel(
                queryRoles				);

            // act
            var result = roleManager.List();

            // Assert
            Assert.IsInstanceOf<ViewResult>(result);

            var viewResult = result as ViewResult;

            var model = viewResult.ViewData.Model;

            Assert.IsInstanceOf<RoleManagerListOutputModel>(model);

            var viewModel = model as RoleManagerListOutputModel;

            Assert.AreEqual(viewModel.InfoMessage, INFORMATION);

            queryRoles.VerifyAllExpectations();
        }
Пример #2
0
        public void GET_List_Has_ListOutputModel_RequestsRoles()
        {
            // Arrange

            var roleManager = new RoleManagerController();

            var builder = new TestControllerBuilder();

            builder.InitializeController(roleManager);

            var queryRoles = MockRepository.GenerateMock<IQueryService<Role>>();

            queryRoles.Expect(q => q.Query()).Return(new Role[] { }.AsQueryable());

            roleManager.ListOutputModel = new RoleManagerListOutputModel(
                queryRoles				);

            // act
            var result = roleManager.List();

            // Assert
            Assert.IsInstanceOf< ViewResult>(result);

            var viewResult = result as ViewResult;

            var model = viewResult.ViewData.Model;

            Assert.IsInstanceOf<RoleManagerListOutputModel>(model);

            queryRoles.VerifyAllExpectations();
        }