Exemple #1
0
        private async void BeUniqueByName_Update_Not_Exists()
        {
            Mock <IMachinePolicyRepository> machinePolicyRepository = new Mock <IMachinePolicyRepository>();

            machinePolicyRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <MachinePolicy>(null));
            var validator = new ApiMachinePolicyRequestModelValidator(machinePolicyRepository.Object);

            await validator.ValidateUpdateAsync(default(string), new ApiMachinePolicyRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.Name, "A");
        }
Exemple #2
0
        public async void Name_Update_length()
        {
            Mock <IMachinePolicyRepository> machinePolicyRepository = new Mock <IMachinePolicyRepository>();

            machinePolicyRepository.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult(new MachinePolicy()));

            var validator = new ApiMachinePolicyRequestModelValidator(machinePolicyRepository.Object);
            await validator.ValidateUpdateAsync(default(string), new ApiMachinePolicyRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 201));
        }