private void TestUpdateName(string name1, string name2)
        {
            // Create.

            var owner = new Employer {
                Id = Guid.NewGuid()
            };
            var savedSearch = new MemberSearch
            {
                Name     = name1,
                Criteria = CreateAdvancedCriteria(1)
            };

            _memberSearchesCommand.CreateMemberSearch(owner, savedSearch);

            var gotSearch = _memberSearchesQuery.GetMemberSearch(savedSearch.Id);

            Assert.AreEqual(name1, gotSearch.Name);

            // Update.

            savedSearch.Name = name2;

            if (string.IsNullOrEmpty(name2))
            {
                AssertException.Thrown <ValidationErrorsException>(() => _memberSearchesCommand.UpdateMemberSearch(owner, savedSearch), "A 'LinkMe.Framework.Utility.Validation.RequiredValidationError' error has occurred for the Name property.");
            }
            else
            {
                _memberSearchesCommand.UpdateMemberSearch(owner, savedSearch);

                gotSearch = _memberSearchesQuery.GetMemberSearch(savedSearch.Id);
                Assert.AreEqual(name2, gotSearch.Name);
            }
        }
        public void TestUpdateSameName()
        {
            var ownerId = Guid.NewGuid();

            // Create 2 searches.

            var savedSearch1 = new JobAdSearch
            {
                Name     = "TestName1",
                Criteria = CreateCriteria(1)
            };

            _jobAdSearchesCommand.CreateJobAdSearch(ownerId, savedSearch1);

            var savedSearch2 = new JobAdSearch
            {
                Name     = "TestName2",
                Criteria = CreateCriteria(2)
            };

            _jobAdSearchesCommand.CreateJobAdSearch(ownerId, savedSearch2);

            // Update the second to match the first.

            savedSearch2.Name = savedSearch1.Name;
            AssertException.Thrown <ValidationErrorsException>(() => _jobAdSearchesCommand.UpdateJobAdSearch(ownerId, savedSearch2), "A 'LinkMe.Framework.Utility.Validation.DuplicateValidationError' error has occurred for the Name property.");
        }
Exemple #3
0
        public void TestCouponRedeemerId()
        {
            var product1 = GetContactProduct();
            var product2 = GetApplicantProduct();

            var redeemerId1 = Guid.NewGuid();
            var redeemerId2 = Guid.NewGuid();
            var redeemerId3 = Guid.NewGuid();

            var coupon1 = CreateCoupon(1, false, CreatePercentageDiscount(), new[] { redeemerId1, redeemerId2 }, null);

            AssertException.Thrown <CouponRedeemerException>(() => _ordersCommand.ValidateCoupon(coupon1, null, null));
            _ordersCommand.ValidateCoupon(coupon1, redeemerId1, null);
            _ordersCommand.ValidateCoupon(coupon1, redeemerId2, null);
            AssertException.Thrown <CouponRedeemerException>(() => _ordersCommand.ValidateCoupon(coupon1, redeemerId3, null));

            // Purchase.

            var ownerId    = Guid.NewGuid();
            var creditCard = CreateCreditCard(CreditCardType.Visa);
            var order      = _ordersCommand.PrepareOrder(new[] { product1.Id, product2.Id }, coupon1, null, creditCard.CardType);
            var receipt    = _ordersCommand.PurchaseOrder(ownerId, order, new Purchaser {
                Id = ownerId
            }, creditCard) as CreditCardReceipt;

            // Assert.

            AssertAllocations(ownerId, order.Id, product1.CreditAdjustments.Concat(product2.CreditAdjustments).ToArray());
            AssertOrders(ownerId, coupon1, null, product1, product2);
            AssertReceipt(order.Id, receipt);
            AssertException.Thrown <CouponRedeemerException>(() => _ordersCommand.ValidateCoupon(coupon1, null, null));
            _ordersCommand.ValidateCoupon(coupon1, redeemerId1, null);
            _ordersCommand.ValidateCoupon(coupon1, redeemerId2, null);
            AssertException.Thrown <CouponRedeemerException>(() => _ordersCommand.ValidateCoupon(coupon1, redeemerId3, null));
        }
Exemple #4
0
        public void TestInvalidName()
        {
            var ownerId = Guid.NewGuid();
            var search  = new JobAdSearch
            {
                Criteria = CreateCriteria(0),
                Name     = "#&*&^*(&_(_*()",
            };

            AssertException.Thrown <ValidationErrorsException>(() => _jobAdSearchesCommand.CreateJobAdSearch(ownerId, search), "A 'LinkMe.Framework.Utility.Validation.RegexLengthRangeValidationError' error has occurred for the Name property.");
        }
Exemple #5
0
        public void TestInvalidName()
        {
            var owner = new Employer {
                Id = Guid.NewGuid()
            };
            var savedSearch = new MemberSearch
            {
                Criteria = CreateAdvancedCriteria(1),
                Name     = "#&*&^*(&_(_*()",
            };

            AssertException.Thrown <ValidationErrorsException>(() => _memberSearchesCommand.CreateMemberSearch(owner, savedSearch), "A 'LinkMe.Framework.Utility.Validation.RegexLengthRangeValidationError' error has occurred for the Name property.");
        }
Exemple #6
0
        public void TestCreateWithoutName()
        {
            var owner = new Employer {
                Id = Guid.NewGuid()
            };
            var savedSearch = new MemberSearch {
                Criteria = CreateAdvancedCriteria(1)
            };

            Assert.IsNull(savedSearch.Name);

            AssertException.Thrown <ValidationErrorsException>(() => _memberSearchesCommand.CreateMemberSearch(owner, savedSearch), "A 'LinkMe.Framework.Utility.Validation.RequiredValidationError' error has occurred for the Name property.");
        }
        public void TestEmailAddressErrors()
        {
            var user           = new AnonymousUser();
            var contactDetails = CreateContactDetails(0);

            contactDetails.EmailAddress = null;
            AssertException.Thrown <ValidationErrorsException>(() => _anonymousUsersCommand.CreateContact(user, contactDetails), "A 'LinkMe.Framework.Utility.Validation.RequiredValidationError' error has occurred for the EmailAddress property.");

            contactDetails.EmailAddress = "a";
            AssertException.Thrown <ValidationErrorsException>(() => _anonymousUsersCommand.CreateContact(user, contactDetails), "A 'LinkMe.Framework.Utility.Validation.EmailAddressValidationError' error has occurred for the EmailAddress property.");

            contactDetails.EmailAddress = "abademailaddress";
            AssertException.Thrown <ValidationErrorsException>(() => _anonymousUsersCommand.CreateContact(user, contactDetails), "A 'LinkMe.Framework.Utility.Validation.EmailAddressValidationError' error has occurred for the EmailAddress property.");
        }
        public void TestLastNameErrors()
        {
            var user           = new AnonymousUser();
            var contactDetails = CreateContactDetails(0);

            contactDetails.LastName = null;
            AssertException.Thrown <ValidationErrorsException>(() => _anonymousUsersCommand.CreateContact(user, contactDetails), "A 'LinkMe.Framework.Utility.Validation.RequiredValidationError' error has occurred for the LastName property.");

            contactDetails.LastName = "a";
            AssertException.Thrown <ValidationErrorsException>(() => _anonymousUsersCommand.CreateContact(user, contactDetails), "A 'LinkMe.Framework.Utility.Validation.RegexLengthRangeValidationError' error has occurred for the LastName property.");

            contactDetails.LastName = new string('a', 500);
            AssertException.Thrown <ValidationErrorsException>(() => _anonymousUsersCommand.CreateContact(user, contactDetails), "A 'LinkMe.Framework.Utility.Validation.RegexLengthRangeValidationError' error has occurred for the LastName property.");
        }
Exemple #9
0
        public void TestCreateSameName()
        {
            var ownerId = Guid.NewGuid();
            var search  = new JobAdSearch
            {
                Criteria = CreateCriteria(0),
                Name     = SearchName,
            };

            _jobAdSearchesCommand.CreateJobAdSearch(ownerId, search);

            // Create another.

            search = new JobAdSearch
            {
                Criteria = CreateCriteria(0),
                Name     = SearchName,
            };
            AssertException.Thrown <ValidationErrorsException>(() => _jobAdSearchesCommand.CreateJobAdSearch(ownerId, search), "A 'LinkMe.Framework.Utility.Validation.DuplicateValidationError' error has occurred for the Name property.");
        }
Exemple #10
0
        public void TestCreateSameName()
        {
            var owner = new Employer {
                Id = Guid.NewGuid()
            };
            var savedSearch = new MemberSearch
            {
                Criteria = CreateAdvancedCriteria(1),
                Name     = SearchName,
            };

            _memberSearchesCommand.CreateMemberSearch(owner, savedSearch);

            // Create another.

            savedSearch = new MemberSearch
            {
                Criteria = CreateAdvancedCriteria(1),
                Name     = SearchName,
            };
            AssertException.Thrown <ValidationErrorsException>(() => _memberSearchesCommand.CreateMemberSearch(owner, savedSearch), "A 'LinkMe.Framework.Utility.Validation.DuplicateValidationError' error has occurred for the Name property.");
        }
        public void TestErrors()
        {
            var applicantId = Guid.NewGuid();
            var positionId  = Guid.NewGuid();

            var application = new InternalApplication
            {
                PositionId      = positionId,
                ApplicantId     = applicantId,
                CoverLetterText = new string('a', 2000),
            };

            AssertException.Thrown <ValidationErrorsException>(() => _applicationsCommand.CreateApplication(application));

            application.CoverLetterText = new string('a', 900);
            _applicationsCommand.CreateApplication(application);

            AssertApplication(application, _applicationsQuery.GetApplication <InternalApplication>(application.Id, true));

            var applications = _applicationsQuery.GetApplications <InternalApplication>(applicantId, true);

            Assert.AreEqual(1, applications.Count);
            AssertApplication(application, applications[0]);

            applications = _applicationsQuery.GetApplications <InternalApplication>(new[] { application.Id }, true);
            Assert.AreEqual(1, applications.Count);
            AssertApplication(application, applications[0]);

            applications = _applicationsQuery.GetApplications <InternalApplication>(applicantId, new[] { positionId }, true);
            Assert.AreEqual(1, applications.Count);
            AssertApplication(application, applications[0]);

            applications = _applicationsQuery.GetApplicationsByPositionId <InternalApplication>(positionId, true);
            Assert.AreEqual(1, applications.Count);
            AssertApplication(application, applications[0]);
        }