예제 #1
0
        public void Deposit_WhenSet_ValidatesInput(decimal amount, int numberOfErrors)
        {
            var request = new DepositRequest
            {
                Deposit = amount
            };

            Assert.That(ValidateModelHelper.ValidateModel(request).Count, Is.EqualTo(numberOfErrors));
        }
        public void Password_WhenSet_ValidatesInput(string password, int numberOfErrors)
        {
            var request = new LoginRequest
            {
                Email    = ValidEmail,
                Password = password,
            };

            Assert.That(ValidateModelHelper.ValidateModel(request).Count, Is.EqualTo(numberOfErrors));
        }
        public void Email_WhenSet_ValidatesInput(string email, int numberOfErrors)
        {
            var request = new EditCustomerRequest
            {
                Email          = email,
                Name           = ValidName,
                PhoneNumber    = ValidPhoneNumber,
                ChangePassword = false
            };

            Assert.That(ValidateModelHelper.ValidateModel(request).Count, Is.EqualTo(numberOfErrors));
        }
        public void Name_WhenSetToWhiteSpaceOrNull_ValidationFails(string name, int numberOfErrors)
        {
            var request = new EditCustomerRequest
            {
                Email          = ValidEmail,
                Name           = name,
                PhoneNumber    = ValidPhoneNumber,
                ChangePassword = false
            };

            Assert.That(ValidateModelHelper.ValidateModel(request).Count, Is.EqualTo(numberOfErrors));
        }
        public void Password_WhenSet_ValidatesThatBothPasswordsIsPresentAndThatTheyAreEqual(string first, string second, int numberOfErrors)
        {
            var request = new RegisterRequest
            {
                Email            = ValidEmail,
                Password         = first,
                PasswordRepeated = second,
                Name             = ValidName,
                PhoneNumber      = ValidPhoneNumber
            };

            Assert.That(ValidateModelHelper.ValidateModel(request).Count, Is.EqualTo(numberOfErrors));
        }
        public void Email_WhenSet_ValidatesInput(string email, int numberOfErrors)
        {
            var request = new RegisterRequest
            {
                Email            = email,
                Password         = ValidPassword,
                PasswordRepeated = ValidPassword,
                Name             = ValidName,
                PhoneNumber      = ValidPhoneNumber
            };

            Assert.That(ValidateModelHelper.ValidateModel(request).Count, Is.EqualTo(numberOfErrors));
        }
        public void Name_WhenSetToWhiteSpaceOrNull_ValidationFails(string name, int numberOfErrors)
        {
            var request = new RegisterRequest
            {
                Email            = ValidEmail,
                Password         = ValidPassword,
                PasswordRepeated = ValidPassword,
                Name             = name,
                PhoneNumber      = ValidPhoneNumber
            };

            Assert.That(ValidateModelHelper.ValidateModel(request).Count, Is.EqualTo(numberOfErrors));
        }
        public void Name_WhenSet_ValidatesLengthIsMin3Max255(int numberOfCharsInName, int numberOfErrors)
        {
            var name = GenerateString(numberOfCharsInName);

            var request = new EditCustomerRequest
            {
                Email          = ValidEmail,
                Name           = name.ToString(),
                ChangePassword = false,
                PhoneNumber    = ValidPhoneNumber
            };

            Assert.That(ValidateModelHelper.ValidateModel(request).Count, Is.EqualTo(numberOfErrors));
        }
        [TestCase(null, 0)] //will default to false
        public void IsShared_WhenSet_ValidatesInput(RideType type, int numberOfErrors)
        {
            var request = new CreateRideRequest
            {
                RideType             = type,
                DepartureTime        = _validDepartureTime,
                ConfirmationDeadline = _validConfirmationTime,
                PassengerCount       = _validPassengerCount,
                StartDestination     = _validAddress,
                EndDestination       = _validAddress
            };

            Assert.That(ValidateModelHelper.ValidateModel(request).Count, Is.EqualTo(numberOfErrors));
        }
        public void EndDestination_WhenSetToNull_ValidationFails()
        {
            var request = new CreateRideRequest
            {
                RideType             = _validIsShared,
                DepartureTime        = _validDepartureTime,
                ConfirmationDeadline = _validConfirmationTime,
                PassengerCount       = _validPassengerCount,
                StartDestination     = _validAddress,
                EndDestination       = new Address("City", 8210, "Street2", 1)
            };

            Assert.That(ValidateModelHelper.ValidateModel(request).Count, Is.EqualTo(1));
        }
        public void ConfirmationTime_WhenSetToExcatlyNow_ValidationFails()
        {
            var expectedNumberOfErrors = 1;
            var request = new CreateRideRequest
            {
                RideType             = _validIsShared,
                DepartureTime        = _validDepartureTime,
                ConfirmationDeadline = DateTime.Now,
                PassengerCount       = _validPassengerCount,
                StartDestination     = _validAddress,
                EndDestination       = _validAddress
            };

            Assert.That(ValidateModelHelper.ValidateModel(request).Count, Is.EqualTo(expectedNumberOfErrors));
        }