public async void MachinePolicyId_Create_length() { Mock <IMachineRepository> machineRepository = new Mock <IMachineRepository>(); machineRepository.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult(new Machine())); var validator = new ApiMachineRequestModelValidator(machineRepository.Object); await validator.ValidateCreateAsync(new ApiMachineRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.MachinePolicyId, new string('A', 51)); }
public async void LastIpAddress_Update_null() { Mock <IMachineRepository> machineRepository = new Mock <IMachineRepository>(); machineRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Machine())); var validator = new ApiMachineRequestModelValidator(machineRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiMachineRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.LastIpAddress, null as string); }
private async void BeUniqueByName_Update_Not_Exists() { Mock <IMachineRepository> machineRepository = new Mock <IMachineRepository>(); machineRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <Machine>(null)); var validator = new ApiMachineRequestModelValidator(machineRepository.Object); await validator.ValidateUpdateAsync(default(string), new ApiMachineRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.Name, "A"); }