public void Serialize_Applicant_ValidateSchema() { XmlDocument actual = (new BSTSmartScholarshipSerializer<Applicant>()).Serialize(this.TestApplicant); XmlSchemaProvider provider = new XmlSchemaProvider(); actual.Schemas.Add(provider.GetSchemaFromResource("BSTSmartScholarship.Business.Schemas.Applicant.xsd")); actual.Validate(null); }
public void ValidateSchema_Applicant_Invalid_StudentNumber() { Applicant applicant = this.TestApplicant; applicant.StudentNumber = "F"; XmlDocument actual = (new BSTSmartScholarshipSerializer<Applicant>()).Serialize(applicant); XmlSchemaProvider provider = new XmlSchemaProvider(); actual.Schemas.Add(provider.GetSchemaFromResource("BSTSmartScholarship.Business.Schemas.Applicant.xsd")); try { actual.Validate(null); } catch (XmlSchemaValidationException e) { Assert.AreEqual(@"The 'http://bstsmartscholarship.sesmar.net/applicant:StudentNumber' element is invalid - The value 'F' is invalid according to its datatype 'http://bstsmartscholarship.sesmar.net/applicant:StudentNumberType' - The Pattern constraint failed.", e.Message); throw e; } }
public void Serialize_TuitionAmountResponse_ValidateSchema_Invalid_StudentNumber() { TuitionAmountResponse response = new TuitionAmountResponse() { StudentNumber = "88634351", TuitionAmount = 4500.00 }; response.StudentNumber = "F"; XmlDocument actual = (new BSTSmartScholarshipSerializer<TuitionAmountResponse>()).Serialize(response); XmlSchemaProvider provider = new XmlSchemaProvider(); actual.Schemas.Add(provider.GetSchemaFromResource("BSTSmartScholarship.Business.Schemas.TuitionAmountResponse.xsd")); actual.Validate(null); }
public void Serialize_TuitionAmountRequest_ValidateSchema_Invalid_StudentNumber() { TuitionAmountRequest request = new TuitionAmountRequest() { StudentNumber = "88634351" }; request.StudentNumber = "F"; XmlDocument actual = (new BSTSmartScholarshipSerializer<TuitionAmountRequest>()).Serialize(request); XmlSchemaProvider provider = new XmlSchemaProvider(); actual.Schemas.Add(provider.GetSchemaFromResource("BSTSmartScholarship.Business.Schemas.TuitionAmountRequest.xsd")); actual.Validate(null); }
public void Registrar_VerifyApplicant_Valid_StudentNumber() { Registrar registrar = new Registrar(); BSTSmartScholarshipSerializer<Applicant> serializer = new BSTSmartScholarshipSerializer<Applicant>(); XmlDocument applicantDoc = serializer.Serialize(this.TestApplicant); ISchemaProvider provider = new XmlSchemaProvider(); applicantDoc.Schemas.Add(provider.GetSchemaFromResource("BSTSmartScholarship.Business.Schemas.Applicant.xsd")); applicantDoc.Validate(null); XmlDocument studentDoc = registrar.VerifyApplicant(applicantDoc); studentDoc.Schemas.Add(provider.GetSchemaFromResource("BSTSmartScholarship.Business.Schemas.Student.xsd")); studentDoc.Validate(null); BSTSmartScholarshipSerializer<Student> deserializer = new BSTSmartScholarshipSerializer<Student>(); Student student = deserializer.Deserialize(studentDoc); Assert.AreEqual(student.StudentNumber, this.TestApplicant.StudentNumber); }
public void Registrar_RequestTutionAmount_Valid_StudentNumber() { Registrar registrar = new Registrar(); TuitionAmountRequest request = new TuitionAmountRequest() { StudentNumber = "88634352" }; BSTSmartScholarshipSerializer<TuitionAmountRequest> serializer = new BSTSmartScholarshipSerializer<TuitionAmountRequest>(); XmlDocument requestDoc = serializer.Serialize(request); ISchemaProvider provider = new XmlSchemaProvider(); requestDoc.Schemas.Add(provider.GetSchemaFromResource("BSTSmartScholarship.Business.Schemas.TuitionAmountRequest.xsd")); requestDoc.Validate(null); XmlDocument responseDoc = registrar.RequestTuitionAmount(requestDoc); responseDoc.Schemas.Add(provider.GetSchemaFromResource("BSTSmartScholarship.Business.Schemas.TuitionAmountResponse.xsd")); responseDoc.Validate(null); BSTSmartScholarshipSerializer<TuitionAmountResponse> deserilaizer = new BSTSmartScholarshipSerializer<TuitionAmountResponse>(); TuitionAmountResponse response = deserilaizer.Deserialize(responseDoc); Assert.AreEqual(response.StudentNumber, request.StudentNumber); Assert.AreEqual(response.TuitionAmount, 5500.00); }