public async void JwtKey_Create_null() { Mock <IMachineRepository> machineRepository = new Mock <IMachineRepository>(); machineRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Machine())); var validator = new ApiMachineServerRequestModelValidator(machineRepository.Object); await validator.ValidateCreateAsync(new ApiMachineServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.JwtKey, null as string); }
public async void JwtKey_Update_length() { Mock <IMachineRepository> machineRepository = new Mock <IMachineRepository>(); machineRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Machine())); var validator = new ApiMachineServerRequestModelValidator(machineRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiMachineServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.JwtKey, new string('A', 129)); }
private async void BeUniqueByMachineGuid_Update_Not_Exists() { Mock <IMachineRepository> machineRepository = new Mock <IMachineRepository>(); machineRepository.Setup(x => x.ByMachineGuid(It.IsAny <Guid>())).Returns(Task.FromResult <Machine>(null)); var validator = new ApiMachineServerRequestModelValidator(machineRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiMachineServerRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.MachineGuid, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); }