Example #1
0
        public async void Name_Create_null()
        {
            Mock <ITenantRepository> tenantRepository = new Mock <ITenantRepository>();

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

            var validator = new ApiTenantRequestModelValidator(tenantRepository.Object);
            await validator.ValidateCreateAsync(new ApiTenantRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, null as string);
        }
Example #2
0
        public async void Name_Update_length()
        {
            Mock <ITenantRepository> tenantRepository = new Mock <ITenantRepository>();

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

            var validator = new ApiTenantRequestModelValidator(tenantRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiTenantRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129));
        }
        private async void BeUniqueByName_Update_Not_Exists()
        {
            Mock <ITenantRepository> tenantRepository = new Mock <ITenantRepository>();

            tenantRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <Tenant>(null));
            var validator = new ApiTenantRequestModelValidator(tenantRepository.Object);

            await validator.ValidateUpdateAsync(default(string), new ApiTenantRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.Name, "A");
        }