Beispiel #1
0
        public async void FirstName_Update_null()
        {
            Mock <IAdminRepository> adminRepository = new Mock <IAdminRepository>();

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

            var validator = new ApiAdminRequestModelValidator(adminRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiAdminRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.FirstName, null as string);
        }
Beispiel #2
0
        public async void Email_Update_length()
        {
            Mock <IAdminRepository> adminRepository = new Mock <IAdminRepository>();

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

            var validator = new ApiAdminRequestModelValidator(adminRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiAdminRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Email, new string('A', 129));
        }
Beispiel #3
0
        public async void UserId_Update_Invalid_Reference()
        {
            Mock <IAdminRepository> adminRepository = new Mock <IAdminRepository>();

            adminRepository.Setup(x => x.UserByUserId(It.IsAny <int>())).Returns(Task.FromResult <User>(null));

            var validator = new ApiAdminRequestModelValidator(adminRepository.Object);

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

            validator.ShouldHaveValidationErrorFor(x => x.UserId, 1);
        }
Beispiel #4
0
        public async void StudioId_Create_Invalid_Reference()
        {
            Mock <IAdminRepository> adminRepository = new Mock <IAdminRepository>();

            adminRepository.Setup(x => x.GetStudio(It.IsAny <int>())).Returns(Task.FromResult <Studio>(null));

            var validator = new ApiAdminRequestModelValidator(adminRepository.Object);

            await validator.ValidateCreateAsync(new ApiAdminRequestModel());

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