示例#1
0
        public void TestEvent()
        {
            IptDataModel client = new IptDataModelClient();
            PostEvent pEvent = new PostEvent();

            SIFHeaderType header = createHeader();
            header.EventAction = SIFHeaderTypeEventAction.Add;
            header.EventActionSpecified = true;
            header.TopicName = "SchoolCourseInfo";

            pEvent.SIFHeader = header;
            pEvent.Event = createXML(
                @"<SchoolCourseInfo RefId='9D75101A8C3D00AA001A0000A2E35B35' SchoolInfoRefId='101A8C3D00AA001A0000A2E35B359D75' SchoolYear='2006'
                        xmlns='" + Statics.XMLNS_SIF_US_DATAMODEL + @"'>
                      <CourseCode>CS101</CourseCode>
                      <StateCourseCode>08-001</StateCourseCode>
                      <DistrictCourseCode>CS101</DistrictCourseCode>
                      <SubjectAreaList>
                        <SubjectArea>
                          <Code>05</Code>
                          <OtherCodeList>
                            <OtherCode Codeset='Text'>Graphic Arts</OtherCode>
                          </OtherCodeList>
                        </SubjectArea>
                      </SubjectAreaList>
                      <CourseTitle>Gif, JPeg, or Png: What's the Difference?</CourseTitle>
                      <Description>Explore the various types of files related to graphic arts.</Description>
                      <InstructionalLevel>
                        <Code>0571</Code>
                      </InstructionalLevel>
                      <CourseCredits Type='0585'>2</CourseCredits>
                      <CoreAcademicCourse>No</CoreAcademicCourse>
                      <GraduationRequirement>No</GraduationRequirement>
                </SchoolCourseInfo>");

            EventStatus evStatus = client.Event( pEvent );
            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");
        }
示例#2
0
        private EventStatus EventImplementation(PostEvent request)
        {
            runAssertions(request.SIFHeader);

            // Run event assertions
            if (!request.SIFHeader.EventActionSpecified)
            {
                throw new FaultException("No EventAction header specified");
            }
            if (String.IsNullOrEmpty(request.SIFHeader.TopicName))
            {
                throw new FaultException("No TopicName specified");
            }

            // Verify that the TopicName matches the XML Payload
            XmlElement eventObject = request.Event;

            if (!(eventObject.Name == request.SIFHeader.TopicName))
            {
                throw new FaultException("Topic Name does not match name in event XML");
            }

            // Special case, throw an error for FoodServiceMilkSales
            {
                if (request.SIFHeader.TopicName == "FoodserviceMilkSales")
                {
                    DataModelErrorType sifError = new DataModelErrorType();
                    sifError.Category     = InfrastructureErrorCategoryType.Item9;
                    sifError.Code         = "3";
                    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
        private EventStatus EventImplementation(PostEvent request)
        {
            runAssertions(request.SIFHeader);

            // Run event assertions
            if (!request.SIFHeader.EventActionSpecified)
            {
                throw new FaultException("No EventAction header specified");
            }
            if (String.IsNullOrEmpty(request.SIFHeader.TopicName))
            {
                throw new FaultException("No TopicName specified");
            }

            // Verify that the TopicName matches the XML Payload
            XmlElement eventObject = request.Event;
            if (! (eventObject.Name == request.SIFHeader.TopicName ))
            {
                throw new FaultException("Topic Name does not match name in event XML");
            }

            // Special case, throw an error for FoodServiceMilkSales
            {
                if (request.SIFHeader.TopicName == "FoodserviceMilkSales")
                {
                    DataModelErrorType sifError = new DataModelErrorType();
                    sifError.Category = InfrastructureErrorCategoryType.Item9;
                    sifError.Code = "3";
                    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();
        }
示例#4
0
        public void TestEventWithError()
        {
            IptDataModel client = new IptDataModelClient();
            PostEvent pEvent = new PostEvent();

            SIFHeaderType header = createHeader();
            header.EventAction = SIFHeaderTypeEventAction.Add;
            header.EventActionSpecified = true;
            header.TopicName = "FoodserviceMilkSales";

            pEvent.SIFHeader = header;
            pEvent.Event = createXML(
                @"<FoodserviceMilkSales RefId='D21CF29B7FB44965A9CF950E1E60B21E'
                            xmlns='" + Statics.XMLNS_SIF_US_DATAMODEL + @"'>
                      <SchoolInfoRefId>AA66800BE0D84E80AA5838FA97EE3A3E</SchoolInfoRefId>
                      <Date>2001-10-31</Date>
                      <Program Type='Foodservice'>NSLP</Program>
                      <SaleQuantities>
                        <SaleQuantity>
                          <Value>99999</Value>
                          <MealStatus Type='Free' />
                          <SaleUnit>6 oz</SaleUnit>
                          <ChargeToChild Currency='USD'>999.99</ChargeToChild>
                        </SaleQuantity>
                        <SaleQuantity>
                          <Value>99999</Value>
                          <MealStatus Type='Reduced' />
                          <SaleUnit>6 oz</SaleUnit>
                          <ChargeToChild Currency='USD'>999.99</ChargeToChild>
                        </SaleQuantity>
                      </SaleQuantities>
                    </FoodserviceMilkSales>");

            bool exceptionThrown = false;
            try
            {
                EventStatus evStatus = client.Event(pEvent);
            }
            catch (FaultException<DataModelErrorType> ex)
            {
                exceptionThrown = true;
                Assert.AreEqual(ex.Detail.Category, InfrastructureErrorCategoryType.Item9, "Expected Category of 9");
                Assert.AreEqual(ex.Detail.Code, "3", "Expected Code of 3");

            }
            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");
        }