Exemplo n.º 1
0
        private async void BeUniqueByName_Create_Exists()
        {
            Mock <ISubscriptionRepository> subscriptionRepository = new Mock <ISubscriptionRepository>();

            subscriptionRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <Subscription>(new Subscription()));
            var validator = new ApiSubscriptionRequestModelValidator(subscriptionRepository.Object);

            await validator.ValidateCreateAsync(new ApiSubscriptionRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, "A");
        }
Exemplo n.º 2
0
        public async void Type_Update_length()
        {
            Mock <ISubscriptionRepository> subscriptionRepository = new Mock <ISubscriptionRepository>();

            subscriptionRepository.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult(new Subscription()));

            var validator = new ApiSubscriptionRequestModelValidator(subscriptionRepository.Object);
            await validator.ValidateUpdateAsync(default(string), new ApiSubscriptionRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Type, new string('A', 51));
        }