Пример #1
0
        public void TestQueryWithError()
        {
            IptDataModel client = new IptDataModelClient();
            QueryRequest qRequest = new QueryRequest();

            // Header
            SIFHeaderType header = createHeader();
            header.TopicName = "FoodserviceMilkSales";
            header.MaxBufferSize = uint.MaxValue;
            header.MaxBufferSizeSpecified = true;
            header.ResponseVersion = new String[] { "1.1", "2.0r1", "2.1", "2.5", "2.*" };
            qRequest.SIFHeader = header;

            // Query
            QueryTypeQueryObject query = new QueryTypeQueryObject();
            query.ObjectName = "FoodserviceMilkSales";
            QueryType type = new QueryType();
            type.QueryObject = query;
            qRequest.Query = type;

            bool exceptionThrown = false;

            try
            {
                EventStatus evStatus = client.Query(qRequest);
            }
            catch (FaultException<DataModelErrorType> ex)
            {
                exceptionThrown = true;
                Assert.AreEqual(ex.Detail.Category, InfrastructureErrorCategoryType.Item8, "Expected Category of 8");
                Assert.AreEqual(ex.Detail.Code, "4", "Expected Code of 4");
            }
            catch (Exception ex)
            {
                Assert.Fail("Unable to parse SOAP Fault into expected exception type: " + ex.ToString());
            }

            Assert.IsTrue(exceptionThrown, "A SOAP Fault was not returned");
        }
Пример #2
0
        private EventStatus QueryImplementation(QueryRequest request)
        {
            runAssertions(request.SIFHeader);

            // Run Query assertions
            if (String.IsNullOrEmpty(request.SIFHeader.TopicName))
            {
                throw new FaultException("No TopicName specified");
            }

            // Verify that the TopicName matches the XML Payload
            QueryType q = request.Query;
            if (!(q.QueryObject.ObjectName == request.SIFHeader.TopicName))
            {
                throw new FaultException("Topic Name does not match name in query XML");
            }

            String[] responseVersion = request.SIFHeader.ResponseVersion;
            if (responseVersion == null || responseVersion.Length < 1)
            {
                throw new FaultException("No Response version specified");
            }

            if (!request.SIFHeader.MaxBufferSizeSpecified)
            {
                throw new FaultException("Max Buffer Size not specified");
            }

            // Special case, throw an error for FoodServiceMilkSales
            {
                if (request.SIFHeader.TopicName == "FoodserviceMilkSales")
                {
                    DataModelErrorType sifError = new DataModelErrorType();
                    sifError.Category = InfrastructureErrorCategoryType.Item8;
                    sifError.Code = "4";
                    sifError.Desc = "Bogus objects are not allowed";
                    sifError.ExtendedDesc = "Please Notify Dave Guidos";
                    throw new FaultException<DataModelErrorType>(sifError, "Planned Exception to test SIF WS Transport");
                }
            }

            return genericOKResponse();
        }
Пример #3
0
        public void TestQuery()
        {
            IptDataModel client = new IptDataModelClient();
            QueryRequest qRequest = new QueryRequest();

            // Header
            SIFHeaderType header = createHeader();
            header.TopicName = "SchoolCourseInfo";
            header.MaxBufferSize = uint.MaxValue;
            header.MaxBufferSizeSpecified = true;
            header.ResponseVersion = new String[] { "1.1", "2.0r1", "2.1", "2.5", "2.*" };
            qRequest.SIFHeader = header;

            // Query
            QueryTypeQueryObject query = new QueryTypeQueryObject();
            query.ObjectName = "SchoolCourseInfo";
            QueryType type = new QueryType();
            type.QueryObject = query;

            qRequest.Query = type;

            EventStatus evStatus = client.Query(qRequest);
            runAssertions(evStatus.SIFHeader);
            Assert.IsNotNull(evStatus.Status, "Status is null");
            StatusType status = evStatus.Status;
            Console.WriteLine("Invoked with return code " + status.Code);

            Assert.AreEqual(status.Code, InfrastructureStatusCodeType.Item0);
            Assert.AreEqual(status.Desc, "Success");
        }