Пример #1
0
        public void Can_get_entity_count_based_on_its_dto()
        {
            var apiService = new GenericApiService <StoreDto, Store>(_worker.Object);

            var count = apiService.Count().GetAwaiter().GetResult();

            count.ShouldEqual(3);
        }
Пример #2
0
        public void Can_get_entity_by_id_based_on_its_dto()
        {
            var apiService = new GenericApiService <StoreDto, Store>(_worker.Object);

            //storeId = branch_no
            var result = apiService.GetById(135).GetAwaiter().GetResult();

            result.Name.ShouldEqual("Store Power Root");
        }
Пример #3
0
        public void Can_get_entities_based_on_their_dto()
        {
            var apiService = new GenericApiService <StoreDto, Store>(_worker.Object);

            var result = apiService.GetAll(sortColumn: "branch_no", descending: true).GetAwaiter().GetResult();

            result.ShouldNotBeNull();
            result.Last().Name.ShouldEqual("Store Power Root");
            result.Count.ShouldEqual(3);
        }
Пример #4
0
 public DeleteModel(GenericApiService client)
 {
     _client = client;
     _client.ConfigureOptions(ops => { ops.TargetController = "treasures"; });
 }
Пример #5
0
        public void Can_search_entity_by_attributes_based_on_its_dto()
        {
            var apiService = new GenericApiService <StoreDto, Store>(_worker.Object);

            var query      = "p_branchno:246";
            var sortColumn = "name";
            var search     = apiService.Search(query, sortColumn: sortColumn).GetAwaiter().GetResult();

            search.List.Count.ShouldEqual(2);
            search.List.First().Id.ShouldEqual(2);

            var no_query = "";
            var search1  = apiService.Search(no_query).GetAwaiter().GetResult();

            search1.List.Count.ShouldEqual(3);

            var query_with_wrong_attribute = "branch_no:246,namee:Store Kosong";
            var search2 = apiService.Search(query_with_wrong_attribute).GetAwaiter().GetResult();

            search2.List.Count.ShouldEqual(2);

            var query_single_valid = "name:Store Kosong";
            var search3            = apiService.Search(query_single_valid).GetAwaiter().GetResult();

            search3.List.Count.ShouldEqual(1);

            var query_multiple_all_valid = "branch_no:246,name:Store Kosong";
            var search4 = apiService.Search(query_multiple_all_valid).GetAwaiter().GetResult();

            search4.List.Count.ShouldEqual(1);
            search4.List.First().Address1.ShouldEqual("Lorong Kosong");

            //for datetime test, see above notes marked with **synchronize
            var query_with_datetime = "created_on_utc:-5";
            var search5             = apiService.Search(query_with_datetime).GetAwaiter().GetResult();

            search5.List.Count.ShouldEqual(1);
            search5.List.Count(x => x.BranchNo == 135).ShouldEqual(1);

            var search6 = apiService.Search(query_with_datetime, count: true).GetAwaiter().GetResult();

            search6.Count.ShouldEqual(1);

            var datetime_long      = "created_on_utc:-40";
            var datetimeLongSearch = apiService.Search(datetime_long, count: true).GetAwaiter().GetResult();

            datetimeLongSearch.Count.ShouldEqual(2);

            var datetime_positive      = "created_on_utc:+5";
            var datetimePositiveSearch = apiService.Search(datetime_positive).GetAwaiter().GetResult();

            datetimePositiveSearch.List.First().Id.ShouldEqual(3);

            var query_count_others = "branch_no:246";

            var search7 = apiService.Search(query_count_others, sortColumn: "name", limit: 1).GetAwaiter().GetResult();

            search7.List.Count.ShouldEqual(1);
            search7.Count.ShouldEqual(0);

            var search8 = apiService.Search(query_count_others, limit: 1, count: true).GetAwaiter().GetResult();

            search8.Count.ShouldEqual(2);
            search8.List.ShouldBeNull();
        }
Пример #6
0
 public UpdateModel(GenericApiService client)
 {
     _client = client;
     _client.ConfigureOptions(ops => { ops.TargetController = "players"; });
 }