Exemple #1
0
        public void ShouldNotEditIfUserDoesNotExists()
        {
            var testUserNotInSystem = new AdminAppUser
            {
                Email    = $"testuser{Guid.NewGuid():N}@test.com",
                UserName = $"testuser{Guid.NewGuid():N}@test.com"
            };

            var testInstances = SetupOdsInstanceRegistrations(5).OrderBy(x => x.Name).ToList();

            var updateModel = new EditOdsInstanceRegistrationForUserModel
            {
                UserId = testUserNotInSystem.Id,
                OdsInstanceRegistrations = testInstances.Select(x => new OdsInstanceRegistrationSelection
                {
                    Name = x.Name,
                    OdsInstanceRegistrationId = x.Id,
                    Selected = true
                }).ToList()
            };

            var validator         = new EditOdsInstanceRegistrationForUserModelValidator(SetupContext);
            var validationResults = validator.Validate(updateModel);

            validationResults.IsValid.ShouldBe(false);
            validationResults.Errors.Select(x => x.ErrorMessage).ShouldContain("The user you are trying to edit does not exist in the database.");
        }
Exemple #2
0
        public void ShouldNotEditIfRequiredFieldsEmpty()
        {
            var updateModel = new EditOdsInstanceRegistrationForUserModel();

            var validator         = new EditOdsInstanceRegistrationForUserModelValidator(SetupContext);
            var validationResults = validator.Validate(updateModel);

            validationResults.IsValid.ShouldBe(false);
            validationResults.Errors.Select(x => x.ErrorMessage).ShouldBe(new List <string>
            {
                "'User Id' must not be empty."
                , "The user you are trying to edit does not exist in the database."
                , "'Email' must not be empty."
                , "'Selected ODS Instances' must not be empty."
            }, false);
        }
Exemple #3
0
        public void ShouldNotEditIfInstancesDoesNotExist()
        {
            var existingUser = SetupUsers(1).Single();

            var testInstanceInSystem = SetupOdsInstanceRegistrations(1).Single();

            var testInstanceNotInSystem = new OdsInstanceRegistration
            {
                Name        = $"TestInstance{Guid.NewGuid():N}",
                Description = "Test Description"
            };

            var updateModel = new EditOdsInstanceRegistrationForUserModel
            {
                UserId = existingUser.Id,
                OdsInstanceRegistrations = new List <OdsInstanceRegistrationSelection>
                {
                    new OdsInstanceRegistrationSelection
                    {
                        Name = testInstanceInSystem.Name,
                        OdsInstanceRegistrationId = testInstanceInSystem.Id,
                        Selected = true
                    },
                    new OdsInstanceRegistrationSelection
                    {
                        Name = testInstanceNotInSystem.Name,
                        OdsInstanceRegistrationId = testInstanceNotInSystem.Id,
                        Selected = true
                    }
                }
            };

            var validator         = new EditOdsInstanceRegistrationForUserModelValidator(SetupContext);
            var validationResults = validator.Validate(updateModel);

            validationResults.IsValid.ShouldBe(false);
            validationResults.Errors.Select(x => x.ErrorMessage).ShouldContain("A selected instance does not exist in the database.");
        }