Exemple #1
0
        SearchSchema_when_result_count_is_0_returns_stream_with_the_no_matching_records_found()
        {
            //arrange
            var dsObj2 = new DataSetSchema()
            {
                Title = "schemaurl", IsDisabled = false, IsApproved = true, Category = new Category()
                {
                    IsDisabled = false
                }
            };

            _repositoryDataSetSchema.Add(dsObj2);
            var mut = new DataShareService();

            //act
            var stream = mut.SearchSchemaTextContains("", "schemaurl", "xml", "searchField", "searchtext");
            var sr     = new StreamReader(stream);
            var myStr  = sr.ReadToEnd();
            var result = myStr.Contains("No matching records found");

            //assert
            Assert.IsTrue(result);
            //cleanup
            _repositoryDataSetSchema.Delete(dsObj2);
        }
Exemple #2
0
        SearchSchema_when_schema_is_not_online_returns_stream_with_the_data_is_not_available()
        {
            //arrange
            var dsObj2 = new DataSetSchema()
            {
                Title = "schemaurl-disabled-true", IsDisabled = true, IsApproved = true, Category = new Category()
                {
                    IsDisabled = false
                }
            };

            _repositoryDataSetSchema.Add(dsObj2);
            var mut = new DataShareService();

            //act
            var stream = mut.SearchSchemaTextContains("", "schemaurl-disabled-true", "xml", "searchField", "searchtext");
            var sr     = new StreamReader(stream);
            var myStr  = sr.ReadToEnd();
            var result = myStr.Contains("This data is not available");

            //assert
            Assert.IsTrue(result);
            //cleanup
            _repositoryDataSetSchema.Delete(dsObj2);
        }
Exemple #3
0
        SearchSchema_when_schema_is_null_returns_stream_with_the_data_is_not_available()
        {
            //arrange
            var mut = new DataShareService();
            //act
            var stream = mut.SearchSchemaTextContains("", "schemaurl", "xml", "searchField", "searchtext");
            var sr     = new StreamReader(stream);
            var myStr  = sr.ReadToEnd();
            var result = myStr.Contains("This data is not available");

            //assert
            Assert.IsTrue(result);
        }
Exemple #4
0
        public void Api_SearchSchemaTextContains_Returns_Data_Containing_SearchText()
        {
            var firstCategory = _categoryService.GetAll(false)[0];

            var service = new DataShareService();
            var result  = service.SearchSchemaTextContains(firstCategory.FriendlyUrl, firstCategory.Schemas[0].FriendlyUrl, "xml", "Service", "Commissioning");

            using (var reader = new StreamReader(result))
            {
                var xml = XElement.Parse(reader.ReadToEnd());

                var shouldHaveData = xml.Descendants("Service").Where(p => p.Value.ToLower().Contains("commissioning")).ToList();
                var shouldBeEmpty  = xml.Descendants("Service").Where(p => !p.Value.ToLower().Contains("commissioning")).ToList();

                Assert.IsTrue(shouldHaveData.Count() > 0, "Should have returned records containg misc ");
                Assert.IsTrue(shouldBeEmpty.Count() == 0, "Should return nothing");
            }
        }