Пример #1
0
        public async void Name_Update_length()
        {
            Mock <IShiftRepository> shiftRepository = new Mock <IShiftRepository>();

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

            var validator = new ApiShiftRequestModelValidator(shiftRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiShiftRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 51));
        }
Пример #2
0
        private async void BeUniqueByStartTimeEndTime_Create_Exists()
        {
            Mock <IShiftRepository> shiftRepository = new Mock <IShiftRepository>();

            shiftRepository.Setup(x => x.ByStartTimeEndTime(It.IsAny <TimeSpan>(), It.IsAny <TimeSpan>())).Returns(Task.FromResult <Shift>(new Shift()));
            var validator = new ApiShiftRequestModelValidator(shiftRepository.Object);

            await validator.ValidateCreateAsync(new ApiShiftRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.EndTime, TimeSpan.Parse("0"));
        }
Пример #3
0
        public async void Name_Create_null()
        {
            Mock <IShiftRepository> shiftRepository = new Mock <IShiftRepository>();

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

            var validator = new ApiShiftRequestModelValidator(shiftRepository.Object);
            await validator.ValidateCreateAsync(new ApiShiftRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, null as string);
        }