Example #1
0
        public async void Action_Update_length()
        {
            Mock <IDeviceActionRepository> deviceActionRepository = new Mock <IDeviceActionRepository>();

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

            var validator = new ApiDeviceActionServerRequestModelValidator(deviceActionRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiDeviceActionServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Action, new string('A', 4001));
        }
Example #2
0
        public async void DeviceId_Create_Valid_Reference()
        {
            Mock <IDeviceActionRepository> deviceActionRepository = new Mock <IDeviceActionRepository>();

            deviceActionRepository.Setup(x => x.DeviceByDeviceId(It.IsAny <int>())).Returns(Task.FromResult <Device>(new Device()));

            var validator = new ApiDeviceActionServerRequestModelValidator(deviceActionRepository.Object);
            await validator.ValidateCreateAsync(new ApiDeviceActionServerRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.DeviceId, 1);
        }
Example #3
0
        public async void Action_Create_null()
        {
            Mock <IDeviceActionRepository> deviceActionRepository = new Mock <IDeviceActionRepository>();

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

            var validator = new ApiDeviceActionServerRequestModelValidator(deviceActionRepository.Object);
            await validator.ValidateCreateAsync(new ApiDeviceActionServerRequestModel());

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