public void GetSearchSpaces_NullConnectionServer_Failure()
        {
            List <SearchSpace> oSpaces;
            var res = SearchSpace.GetSearchSpaces(null, out oSpaces, 1, 10, "params");

            Assert.IsFalse(res.Success, "Calling GetSearchSpaces member did not fail with null Connection server ");
        }
Пример #2
0
        public void SearchSpace_Test()
        {
            _errorString = "";
            List <SearchSpace> oSearchSpaces;
            var res = SearchSpace.GetSearchSpaces(_connectionServer, out oSearchSpaces, 1, 2);

            Assert.IsTrue(res.Success & oSearchSpaces.Count > 0, "Failed to fetch SearchSpace:" + res);
            Assert.IsTrue(string.IsNullOrEmpty(_errorString), _errorString);
        }
        public void GetSearchSpaces_EmptyResult_Failure()
        {
            Reset();
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = true,
                ResponseText = ""
            });

            List <SearchSpace> oSpaces;
            var res = SearchSpace.GetSearchSpaces(_mockServer, out oSpaces, 1, 5, null);

            Assert.IsFalse(res.Success, "Calling GetSearchSpaces with EmptyResultText did not fail");
        }
        public void GetSearchSpaces_ZeroCount_Success()
        {
            Reset();
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success          = true,
                ResponseText     = "junk text",
                TotalObjectCount = 0
            });

            List <SearchSpace> oSpaces;
            var res = SearchSpace.GetSearchSpaces(_mockServer, out oSpaces, 1, 5, null);

            Assert.IsTrue(res.Success, "Calling GetSearchSpaces with ZeroCount failed:" + res);
        }
        public void GetSearchSpaces_ErrorResponse_Failure()
        {
            Reset();
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = false,
                ResponseText = "error text",
                StatusCode   = 404
            });

            List <SearchSpace> oSpaces;
            var res = SearchSpace.GetSearchSpaces(_mockServer, out oSpaces, 1, 5, null);

            Assert.IsFalse(res.Success, "Calling GetSearchSpaces with ErrorResponse did not fail");
        }
        public void GetSearchSpaces_GarbageResponse_Failure()
        {
            Reset();
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success          = true,
                TotalObjectCount = 1,
                ResponseText     = "garbage result that will not be parsed out as call handler JSON data"
            });

            List <SearchSpace> oSpaces;
            var res = SearchSpace.GetSearchSpaces(_mockServer, out oSpaces, 1, 5, "");

            Assert.IsFalse(res.Success, "Calling GetSearchSpaces with garbage results should fail");
            Assert.IsTrue(oSpaces.Count == 0, "Invalid result text should produce an empty list");
        }
Пример #7
0
        public void SearchSpaceFetchTests()
        {
            List <SearchSpace> oSearchSpaces;
            WebCallResult      res = SearchSpace.GetSearchSpaces(null, out oSearchSpaces);

            Assert.IsFalse(res.Success, "Static SearchSpaces fetch did not fail with null Connection server");

            res = SearchSpace.GetSearchSpaces(_connectionServer, out oSearchSpaces);
            Assert.IsTrue(res.Success, "Static SearchSpaces fetch failed:" + res);

            Assert.IsTrue(oSearchSpaces.Count > 0, "No SearchSpaces found on target Connection server");

            string strObjectId = "";
            string strName     = "";

            foreach (var oSearchSpace in oSearchSpaces)
            {
                Console.WriteLine(oSearchSpace.ToString());
                Console.WriteLine(oSearchSpace.DumpAllProps());
                Console.WriteLine(oSearchSpace.GetSearchSpaceMembers().Count);
                Console.WriteLine(oSearchSpace.GetSearchSpaceMembers(true).Count);
                strObjectId = oSearchSpace.ObjectId;
                strName     = oSearchSpace.Name;
            }

            //get SearchSpace by ObjectId
            SearchSpace oNewSearchSpace;

            try
            {
                oNewSearchSpace = new SearchSpace(_connectionServer, strObjectId);
                Console.WriteLine(oNewSearchSpace);
            }
            catch (Exception ex)
            {
                Assert.Fail("Creating new SearchSpace object with valid ObjectID failed:" + ex);
            }

            //get SearchSpace by name
            try
            {
                oNewSearchSpace = new SearchSpace(_connectionServer, "", strName);
                Console.WriteLine(oNewSearchSpace);
            }
            catch (Exception ex)
            {
                Assert.Fail("Creating new SearchSpace object with valid Name failed:" + ex);
            }

            //get SearchSpace by bogus name
            try
            {
                oNewSearchSpace = new SearchSpace(_connectionServer, "", "bogus");
                Assert.Fail("Creating new SearchSpace object with bogus Name did not fail");
                Console.WriteLine(oNewSearchSpace);
            }
            catch (Exception)
            {
                Console.WriteLine("Expected failure on creation failure");
            }

            //get SearchSpace by bogus objectId
            try
            {
                oNewSearchSpace = new SearchSpace(_connectionServer, "bogus");
                Assert.Fail("Creating new SearchSpace object with bogus ObjectId did not fail");
                Console.WriteLine(oNewSearchSpace);
            }
            catch (Exception)
            {
                Console.WriteLine("Expected error on creation failure");
            }

            res = SearchSpace.GetSearchSpaces(_connectionServer, out oSearchSpaces, 1, 2, "query=(ObjectId is Bogus)");
            Assert.IsTrue(res.Success, "fetching search spaces with invalid query should not fail:" + res);
            Assert.IsTrue(oSearchSpaces.Count == 0, "Invalid query string should return an empty search space list:" + oSearchSpaces.Count);
        }