public void UpdateOneGroupAccessShouldCallRepository()
 {
     var acc = new AccessGroupDTO();
     var accView = new AccessGroup();
     _accessGroupRepositoryMock.Setup(x => x.UpdateOne(acc)).Returns(StorageResult.Success);
     var result = _subject.UpdateOneAccessGroup(accView);
     Assert.That(result, Is.EqualTo(StorageResult.Success));
 }
 public AccessGroupDTO ToDTO(AccessGroup model)
 {
     return new AccessGroupDTO
                   {
                       Id = model.Id,
                       Name = model.Name,
                       Type = model.Type,
                       Description = model.Description,
                       RolesThatHaveAccess = MapRolesInViewModel(model.RolesThatHaveAccess)
                   };
 }
        public void EditShouldFetchAllRolesAndReturnRightViewAndModel()
        {
            var guid = new Guid();
            var viewModel = new AccessGroup
                                {

                                    Id = guid,
                                    Name = "AccessTest",
                                    Type = "TestGruppe",
                                    Description = "Dette er en testgruppe",
                                    RolesThatHaveAccess = new List<string> {"Administrator"}
                                };
            _accessGroupServiceMock.Setup(x => x.GetOneAccessGroup(guid)).Returns(viewModel);
            _roleServiceMock.Setup(x => x.GetAllRoles()).Returns(new List<string> { "Administrator", "Leder" });
            var result = _subject.Edit(guid);
            var resultModel = (AccessGroupEditModel) result.Model;
            Assert.That(result.ViewName, Is.EqualTo("Edit"));
            Assert.That(resultModel.AccessGroup, Is.EqualTo(viewModel));
            Assert.That(resultModel.RequestedRoles, Contains.Item("Administrator"));
            Assert.That(resultModel.AvailableRoles, Contains.Item("Leder"));
            _roleServiceMock.Verify(x => x.GetAllRoles(), Times.Once());
        }
        public void DeleteShouldFetchAccessGroup()
        {
            var guid = new Guid();
            var viewModel = new AccessGroup
            {

                Id = guid,
                Name = "AccessTest",
                Type = "TestGruppe",
                Description = "Dette er en testgruppe",
                RolesThatHaveAccess = new List<string> { "Administrator" }
            };
            _accessGroupServiceMock.Setup(x => x.GetOneAccessGroup(guid)).Returns(viewModel);
            var result = _subject.Edit(guid);
            Assert.That(result.ViewName, Is.EqualTo("Edit"));
            _accessGroupServiceMock.Verify(x => x.GetOneAccessGroup(guid), Times.Once());
        }