Esempio n. 1
0
        public async void Log_Update_null()
        {
            Mock <ILinkLogRepository> linkLogRepository = new Mock <ILinkLogRepository>();

            linkLogRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new LinkLog()));

            var validator = new ApiLinkLogRequestModelValidator(linkLogRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiLinkLogRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Log, null as string);
        }
        public async void LinkId_Update_Valid_Reference()
        {
            Mock <ILinkLogRepository> linkLogRepository = new Mock <ILinkLogRepository>();

            linkLogRepository.Setup(x => x.GetLink(It.IsAny <int>())).Returns(Task.FromResult <Link>(new Link()));

            var validator = new ApiLinkLogRequestModelValidator(linkLogRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiLinkLogRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.LinkId, 1);
        }
Esempio n. 3
0
        public async void LinkId_Create_Invalid_Reference()
        {
            Mock <ILinkLogRepository> linkLogRepository = new Mock <ILinkLogRepository>();

            linkLogRepository.Setup(x => x.LinkByLinkId(It.IsAny <int>())).Returns(Task.FromResult <Link>(null));

            var validator = new ApiLinkLogRequestModelValidator(linkLogRepository.Object);

            await validator.ValidateCreateAsync(new ApiLinkLogRequestModel());

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