コード例 #1
0
        public void PersonSearchableRepository_Search_AddsIncludesForChildObjects()
        {
            // arrange
            var data          = CreateSamplePersonRecords();
            var searchString  = "thump";
            var expectedCount = 6;

            var search = new Search();

            search.AddArgument("LastName", SearchMethod.IsNotEqual, searchString);

            // act
            var result  = SystemUnderTest.Search(search);
            var actuals = result.Results;

            // assert
            Assert.AreEqual <int>(expectedCount, actuals.Count, "Reloaded record count was wrong");

            foreach (var actual in actuals)
            {
                Assert.IsNotNull(actual.Notes, "Notes collection was null.");

                Assert.AreNotEqual <int>(0, actual.Notes.Count, "Note count should not be zero.");
            }
        }
コード例 #2
0
        public void PersonSearchableRepository_Search_StartsWith_TwoCriteria()
        {
            // arrange
            var data          = CreateSamplePersonRecords();
            var expectedCount = 1;

            var search = new Search();

            search.AddArgument("LastName", SearchMethod.StartsWith, "thu", SearchOperator.And);
            search.AddArgument("FirstName", SearchMethod.StartsWith, "glad", SearchOperator.And);

            // act
            var result = SystemUnderTest.Search(search);
            var actual = result.Results;

            // assert
            Assert.AreEqual <int>(expectedCount, actual.Count, "Reloaded record count was wrong");
        }
コード例 #3
0
        public void PersonSearchableRepository_Search_Equals_TwoCriteria()
        {
            // arrange
            var data          = CreateSamplePersonRecords();
            var searchString  = "onk";
            var expectedCount = 3;

            var search = new Search();

            search.AddArgument("LastName", SearchMethod.Contains, searchString, SearchOperator.Or);
            search.AddArgument("FirstName", SearchMethod.Contains, searchString, SearchOperator.Or);

            // act
            var result = SystemUnderTest.Search(search);
            var actual = result.Results;

            // assert
            Assert.AreEqual <int>(expectedCount, actual.Count, "Reloaded record count was wrong");
        }
コード例 #4
0
        public void PersonSearchableRepository_Search_DoesNotContain_OneCriteria()
        {
            // arrange
            var data          = CreateSamplePersonRecords();
            var searchString  = "bon";
            var expectedCount = 6;

            var search = new Search();

            search.AddArgument("LastName", SearchMethod.DoesNotContain, searchString);

            // act
            var result = SystemUnderTest.Search(search);
            var actual = result.Results;

            // assert
            Assert.AreEqual <int>(expectedCount, actual.Count, "Reloaded record count was wrong");
        }
コード例 #5
0
        public void PersonSearchableRepository_Search_Contains_ChildEntitySearch()
        {
            // arrange
            var data          = CreateSamplePersonRecords();
            var searchString  = "dal";
            var expectedCount = 1;

            var search = new Search();

            search.AddArgument("NoteText", SearchMethod.Contains, searchString);

            // act
            var result = SystemUnderTest.Search(search);
            var actual = result.Results;

            // assert
            Assert.AreEqual <int>(expectedCount, actual.Count, "Reloaded record count was wrong");
        }
コード例 #6
0
        private void AddSimpleSearchForValue(Search search, string searchValue)
        {
            search.AddArgument(
                "FirstName", SearchMethod.Contains, searchValue, SearchOperator.Or);
            search.AddArgument(
                "LastName", SearchMethod.Contains, searchValue, SearchOperator.Or);
            search.AddArgument(
                "PhoneNumber", SearchMethod.Contains, searchValue, SearchOperator.Or);
            search.AddArgument(
                "EmailAddress", SearchMethod.Contains, searchValue, SearchOperator.Or);
            search.AddArgument(
                "Status", SearchMethod.Contains, searchValue, SearchOperator.Or);
            search.AddArgument(
                "CreatedBy", SearchMethod.Contains, searchValue, SearchOperator.Or);
            search.AddArgument(
                "LastModifiedBy", SearchMethod.Contains, searchValue, SearchOperator.Or);

            search.AddArgument(
                "Thingy", SearchMethod.Contains, searchValue, SearchOperator.Or);
        }
コード例 #7
0
 private void AddSimpleSearchForValue(Search search, string searchValue)
 {
     search.AddArgument(
         "LookupType", SearchMethod.Contains, searchValue, SearchOperator.Or);
     search.AddArgument(
         "LookupKey", SearchMethod.Contains, searchValue, SearchOperator.Or);
     search.AddArgument(
         "LookupValue", SearchMethod.Contains, searchValue, SearchOperator.Or);
     search.AddArgument(
         "Status", SearchMethod.Contains, searchValue, SearchOperator.Or);
     search.AddArgument(
         "CreatedBy", SearchMethod.Contains, searchValue, SearchOperator.Or);
     search.AddArgument(
         "LastModifiedBy", SearchMethod.Contains, searchValue, SearchOperator.Or);
 }
コード例 #8
0
        public void PersonSearchableRepository_Search_OneCriteria_OneSort_Descending()
        {
            // arrange
            var data          = CreateSamplePersonRecords();
            var expectedCount = 2;

            var search = new Search();

            search.AddArgument("LastName", SearchMethod.Equals, "Thump");
            search.AddSort("FirstName", SearchConstants.SortDirectionDescending);

            // act
            var result = SystemUnderTest.Search(search);
            var actual = result.Results;

            // assert
            Assert.AreEqual <int>(expectedCount, actual.Count, "Reloaded record count was wrong");


            Assert.AreEqual <string>("Mary Ann", actual[0].FirstName, "Unexpected first name item 0");
            Assert.AreEqual <string>("Gladys", actual[1].FirstName, "Unexpected first name item 1");
        }
コード例 #9
0
        public IList <Benday.EasyAuthDemo.Api.DomainModels.Person> Search(
            SearchMethod searchTypeFirstName      = SearchMethod.Contains,
            string searchValueFirstName           = null,
            SearchMethod searchTypeLastName       = SearchMethod.Contains,
            string searchValueLastName            = null,
            SearchMethod searchTypePhoneNumber    = SearchMethod.Contains,
            string searchValuePhoneNumber         = null,
            SearchMethod searchTypeEmailAddress   = SearchMethod.Contains,
            string searchValueEmailAddress        = null,
            SearchMethod searchTypeStatus         = SearchMethod.Contains,
            string searchValueStatus              = null,
            SearchMethod searchTypeCreatedBy      = SearchMethod.Contains,
            string searchValueCreatedBy           = null,
            SearchMethod searchTypeLastModifiedBy = SearchMethod.Contains,
            string searchValueLastModifiedBy      = null,

            SearchMethod searchTypeThingy = SearchMethod.Contains,
            string searchValueThingy      = null,

            string sortBy          = null,
            string sortByDirection = null,
            int maxNumberOfResults = 100)
        {
            var search = new Search();

            if (sortBy != null)
            {
                search.AddSort(sortBy, sortByDirection);
            }

            bool foundOneNonNullSearchValue = false;

            if (String.IsNullOrWhiteSpace(searchValueFirstName) == false)
            {
                foundOneNonNullSearchValue = true;
                search.AddArgument(
                    "FirstName", searchTypeFirstName, searchValueFirstName);
            }
            if (String.IsNullOrWhiteSpace(searchValueLastName) == false)
            {
                foundOneNonNullSearchValue = true;
                search.AddArgument(
                    "LastName", searchTypeLastName, searchValueLastName);
            }
            if (String.IsNullOrWhiteSpace(searchValuePhoneNumber) == false)
            {
                foundOneNonNullSearchValue = true;
                search.AddArgument(
                    "PhoneNumber", searchTypePhoneNumber, searchValuePhoneNumber);
            }
            if (String.IsNullOrWhiteSpace(searchValueEmailAddress) == false)
            {
                foundOneNonNullSearchValue = true;
                search.AddArgument(
                    "EmailAddress", searchTypeEmailAddress, searchValueEmailAddress);
            }
            if (String.IsNullOrWhiteSpace(searchValueStatus) == false)
            {
                foundOneNonNullSearchValue = true;
                search.AddArgument(
                    "Status", searchTypeStatus, searchValueStatus);
            }
            if (String.IsNullOrWhiteSpace(searchValueCreatedBy) == false)
            {
                foundOneNonNullSearchValue = true;
                search.AddArgument(
                    "CreatedBy", searchTypeCreatedBy, searchValueCreatedBy);
            }
            if (String.IsNullOrWhiteSpace(searchValueLastModifiedBy) == false)
            {
                foundOneNonNullSearchValue = true;
                search.AddArgument(
                    "LastModifiedBy", searchTypeLastModifiedBy, searchValueLastModifiedBy);
            }

            if (String.IsNullOrWhiteSpace(searchValueThingy) == false)
            {
                foundOneNonNullSearchValue = true;
                search.AddArgument(
                    "Thingy", searchTypeThingy, searchValueThingy);
            }


            var returnValues = new List <Benday.EasyAuthDemo.Api.DomainModels.Person>();

            if (foundOneNonNullSearchValue == true)
            {
                search.MaxNumberOfResults = maxNumberOfResults;

                var results       = _Repository.Search(search);
                var entityResults = results.Results;

                _Adapter.Adapt(entityResults, returnValues);
            }

            return(returnValues);
        }
コード例 #10
0
        public IList <Benday.EasyAuthDemo.Api.DomainModels.Lookup> Search(
            SearchMethod searchTypeLookupType     = SearchMethod.Contains,
            string searchValueLookupType          = null,
            SearchMethod searchTypeLookupKey      = SearchMethod.Contains,
            string searchValueLookupKey           = null,
            SearchMethod searchTypeLookupValue    = SearchMethod.Contains,
            string searchValueLookupValue         = null,
            SearchMethod searchTypeStatus         = SearchMethod.Contains,
            string searchValueStatus              = null,
            SearchMethod searchTypeCreatedBy      = SearchMethod.Contains,
            string searchValueCreatedBy           = null,
            SearchMethod searchTypeLastModifiedBy = SearchMethod.Contains,
            string searchValueLastModifiedBy      = null,


            string sortBy          = null,
            string sortByDirection = null,
            int maxNumberOfResults = 100)
        {
            var search = new Search();

            if (sortBy != null)
            {
                search.AddSort(sortBy, sortByDirection);
            }

            bool foundOneNonNullSearchValue = false;

            if (String.IsNullOrWhiteSpace(searchValueLookupType) == false)
            {
                foundOneNonNullSearchValue = true;
                search.AddArgument(
                    "LookupType", searchTypeLookupType, searchValueLookupType);
            }
            if (String.IsNullOrWhiteSpace(searchValueLookupKey) == false)
            {
                foundOneNonNullSearchValue = true;
                search.AddArgument(
                    "LookupKey", searchTypeLookupKey, searchValueLookupKey);
            }
            if (String.IsNullOrWhiteSpace(searchValueLookupValue) == false)
            {
                foundOneNonNullSearchValue = true;
                search.AddArgument(
                    "LookupValue", searchTypeLookupValue, searchValueLookupValue);
            }
            if (String.IsNullOrWhiteSpace(searchValueStatus) == false)
            {
                foundOneNonNullSearchValue = true;
                search.AddArgument(
                    "Status", searchTypeStatus, searchValueStatus);
            }
            if (String.IsNullOrWhiteSpace(searchValueCreatedBy) == false)
            {
                foundOneNonNullSearchValue = true;
                search.AddArgument(
                    "CreatedBy", searchTypeCreatedBy, searchValueCreatedBy);
            }
            if (String.IsNullOrWhiteSpace(searchValueLastModifiedBy) == false)
            {
                foundOneNonNullSearchValue = true;
                search.AddArgument(
                    "LastModifiedBy", searchTypeLastModifiedBy, searchValueLastModifiedBy);
            }



            var returnValues = new List <Benday.EasyAuthDemo.Api.DomainModels.Lookup>();

            if (foundOneNonNullSearchValue == true)
            {
                search.MaxNumberOfResults = maxNumberOfResults;

                var results       = _Repository.Search(search);
                var entityResults = results.Results;

                _Adapter.Adapt(entityResults, returnValues);
            }

            return(returnValues);
        }