コード例 #1
0
        public async void AssignedMachineId_Update_Valid_Reference()
        {
            Mock <ILinkRepository> linkRepository = new Mock <ILinkRepository>();

            linkRepository.Setup(x => x.MachineByAssignedMachineId(It.IsAny <int>())).Returns(Task.FromResult <Machine>(new Machine()));

            var validator = new ApiLinkServerRequestModelValidator(linkRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiLinkServerRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.AssignedMachineId, 1);
        }
コード例 #2
0
        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 ApiLinkServerRequestModelValidator(linkRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiLinkServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129));
        }
コード例 #3
0
        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 ApiLinkServerRequestModelValidator(linkRepository.Object);

            await validator.ValidateUpdateAsync(default(int), new ApiLinkServerRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.ExternalId, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
        }
コード例 #4
0
        public async void LinkStatusId_Update_Invalid_Reference()
        {
            Mock <ILinkRepository> linkRepository = new Mock <ILinkRepository>();

            linkRepository.Setup(x => x.LinkStatusByLinkStatusId(It.IsAny <int>())).Returns(Task.FromResult <LinkStatus>(null));

            var validator = new ApiLinkServerRequestModelValidator(linkRepository.Object);

            await validator.ValidateUpdateAsync(default(int), new ApiLinkServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.LinkStatusId, 1);
        }