Ejemplo n.º 1
0
        public void CanListRoles()
        {
            // Establish Context
            IList<RoleDto> roleSummariesToExpect = new List<RoleDto>();

            var roleDto = new RoleDto();
            roleSummariesToExpect.Add(roleDto);

            _roleManagementService.Expect(r => r.GetRoleSummaries())
                .Return(roleSummariesToExpect);

            // Act
            ViewResult result = _rolesController.Index().AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as IList<RoleDto>).ShouldNotBeNull();
            (result.ViewData.Model as IList<RoleDto>).Count.ShouldEqual(1);
        }
        public void CanGetRoleSummaries()
        {
            // Establish Context
            IList<RoleDto> roleSummariesToExpect = new List<RoleDto>();

            var roleDto = new RoleDto();
            roleSummariesToExpect.Add(roleDto);

            roleRepository.Expect(r => r.GetRoleSummaries())
                .Return(roleSummariesToExpect);

            // Act
            IList<RoleDto> roleSummariesRetrieved =
                roleManagementService.GetRoleSummaries();

            // Assert
            roleSummariesRetrieved.ShouldNotBeNull();
            roleSummariesRetrieved.Count.ShouldEqual(1);
            roleSummariesRetrieved[0].ShouldNotBeNull();
            roleSummariesRetrieved[0].ShouldEqual(roleDto);
        }