Esempio n. 1
0
        private async void BeUniqueByName_Update_Exists()
        {
            Mock <IMachinePolicyRepository> machinePolicyRepository = new Mock <IMachinePolicyRepository>();

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

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

            validator.ShouldHaveValidationErrorFor(x => x.Name, "A");
        }
Esempio n. 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));
        }