public async void AssignedMachineId_Update_Valid_Reference() { Mock <ILinkRepository> linkRepository = new Mock <ILinkRepository>(); linkRepository.Setup(x => x.GetMachine(It.IsAny <int>())).Returns(Task.FromResult <Machine>(new Machine())); var validator = new ApiLinkRequestModelValidator(linkRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiLinkRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.AssignedMachineId, 1); }
public async void ChainId_Create_Valid_Reference() { Mock <ILinkRepository> linkRepository = new Mock <ILinkRepository>(); linkRepository.Setup(x => x.GetChain(It.IsAny <int>())).Returns(Task.FromResult <Chain>(new Chain())); var validator = new ApiLinkRequestModelValidator(linkRepository.Object); await validator.ValidateCreateAsync(new ApiLinkRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.ChainId, 1); }
public async void Name_Update_length() { Mock <ILinkRepository> linkRepository = new Mock <ILinkRepository>(); linkRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Link())); var validator = new ApiLinkRequestModelValidator(linkRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiLinkRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129)); }
private async void BeUniqueByExternalId_Update_Not_Exists() { Mock <ILinkRepository> linkRepository = new Mock <ILinkRepository>(); linkRepository.Setup(x => x.ByExternalId(It.IsAny <Guid>())).Returns(Task.FromResult <Link>(null)); var validator = new ApiLinkRequestModelValidator(linkRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiLinkRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.ExternalId, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); }
public async void Name_Create_null() { Mock <ILinkRepository> linkRepository = new Mock <ILinkRepository>(); linkRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Link())); var validator = new ApiLinkRequestModelValidator(linkRepository.Object); await validator.ValidateCreateAsync(new ApiLinkRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, null as string); }
public async void LinkStatusId_Update_Invalid_Reference() { Mock <ILinkRepository> linkRepository = new Mock <ILinkRepository>(); linkRepository.Setup(x => x.GetLinkStatus(It.IsAny <int>())).Returns(Task.FromResult <LinkStatus>(null)); var validator = new ApiLinkRequestModelValidator(linkRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiLinkRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.LinkStatusId, 1); }
public async void AssignedMachineId_Create_Invalid_Reference() { Mock <ILinkRepository> linkRepository = new Mock <ILinkRepository>(); linkRepository.Setup(x => x.MachineByAssignedMachineId(It.IsAny <int>())).Returns(Task.FromResult <Machine>(null)); var validator = new ApiLinkRequestModelValidator(linkRepository.Object); await validator.ValidateCreateAsync(new ApiLinkRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.AssignedMachineId, 1); }