public async void Name_Update_null() { Mock <IChainRepository> chainRepository = new Mock <IChainRepository>(); chainRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Chain())); var validator = new ApiChainServerRequestModelValidator(chainRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiChainServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, null as string); }
private async void BeUniqueByExternalId_Update_Exists() { Mock <IChainRepository> chainRepository = new Mock <IChainRepository>(); chainRepository.Setup(x => x.ByExternalId(It.IsAny <Guid>())).Returns(Task.FromResult <Chain>(new Chain())); var validator = new ApiChainServerRequestModelValidator(chainRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiChainServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.ExternalId, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); }
public async void Name_Create_length() { Mock <IChainRepository> chainRepository = new Mock <IChainRepository>(); chainRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Chain())); var validator = new ApiChainServerRequestModelValidator(chainRepository.Object); await validator.ValidateCreateAsync(new ApiChainServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129)); }
public async void ChainStatusId_Update_Invalid_Reference() { Mock <IChainRepository> chainRepository = new Mock <IChainRepository>(); chainRepository.Setup(x => x.ChainStatusByChainStatusId(It.IsAny <int>())).Returns(Task.FromResult <ChainStatus>(null)); var validator = new ApiChainServerRequestModelValidator(chainRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiChainServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.ChainStatusId, 1); }
public async void TeamId_Create_Invalid_Reference() { Mock <IChainRepository> chainRepository = new Mock <IChainRepository>(); chainRepository.Setup(x => x.TeamByTeamId(It.IsAny <int>())).Returns(Task.FromResult <Team>(null)); var validator = new ApiChainServerRequestModelValidator(chainRepository.Object); await validator.ValidateCreateAsync(new ApiChainServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.TeamId, 1); }