Пример #1
0
        public void Delete_non_urdms_users()
        {
            var project = GetProject();
            var parties = project.Parties;

            var deletedParties = parties.Where(o => o.Party.UserId == null && o.Id == 0).Take(1)
                                 .Union(parties.Where(o => o.Party.UserId == null && o.Id != 0).Take(1))
                                 .ToList();

            var currentParties = parties.Except(deletedParties).ToList();

            AddProjectToFormCollection(project, deletedParties.Select(o => o.Party).ToList());
            _form.Add("DeleteNonUrdmsUser", "Remove users");

            var bindingContext = GetBindingContext();
            var binder         = new DataManagementPlanViewModelBinder();
            var viewModel      = binder.BindModel(_context, bindingContext) as DataManagementPlanViewModel;

            Assert.That(viewModel, Is.Not.Null, "Viewmodel is null");
            Assert.That(viewModel.UrdmsUsers.Count, Is.EqualTo(currentParties.Count(o => o.Party.UserId != null)), "Curtin Users count is incorrect");
            Assert.That(viewModel.NonUrdmsUsers.Count, Is.EqualTo(currentParties.Count(o => o.Party.UserId == null)), "Non Curtin Users count is incorrect");

            Assert.That(viewModel.UrdmsUsers.All(o => currentParties.SingleOrDefault(q => q.Party.FullName == o.FullName && q.Party.UserId != null) != null), Is.True, "Invalid curtin users");
            Assert.That(viewModel.NonUrdmsUsers.All(o => currentParties.SingleOrDefault(q => q.Party.FullName == o.FullName && q.Party.UserId == null) != null), Is.True, "Invalid curtin users");
        }
Пример #2
0
        public void Persist_users()
        {
            var project = GetProject();
            var parties = project.Parties;

            AddProjectToFormCollection(project);
            var bindingContext = GetBindingContext();
            var binder         = new DataManagementPlanViewModelBinder();
            var viewModel      = binder.BindModel(_context, bindingContext) as DataManagementPlanViewModel;

            Assert.That(viewModel, Is.Not.Null, "Viewmodel is null");
            Assert.That(viewModel.UrdmsUsers.Count, Is.EqualTo(parties.Count(o => o.Party.UserId != null)), "URDMS Users count is incorrect");
            Assert.That(viewModel.NonUrdmsUsers.Count, Is.EqualTo(parties.Count(o => o.Party.UserId == null)), "Non URDMS Users count is incorrect");

            Assert.That(viewModel.UrdmsUsers.All(o => parties.SingleOrDefault(q => q.Party.FullName == o.FullName && q.Party.UserId != null) != null), Is.True, "Invalid URDMS users");
            Assert.That(viewModel.NonUrdmsUsers.All(o => parties.SingleOrDefault(q => q.Party.FullName == o.FullName && q.Party.UserId == null) != null), Is.True, "Invalid URDMS users");
        }