Esempio n. 1
0
		public XmlDocument VerifyApplicant(XmlDocument applicantDoc)
		{
			BSTSmartScholarshipSerializer<Applicant> applicantSerializer = new BSTSmartScholarshipSerializer<Applicant>();
			Applicant applicant = applicantSerializer.Deserialize(applicantDoc);

			Student student = Student.GetStudent(applicant.StudentNumber);
			BSTSmartScholarshipSerializer<Student> studentSerializer = new BSTSmartScholarshipSerializer<Student>();
			XmlDocument studentDoc = studentSerializer.Serialize(student);

			return studentDoc;
		}
		public ActionResult VerifyWithRegistrar(String sn)
		{
			VerifyModel model = new VerifyModel();
			model.Applicant = Applicant.GetApplicant(sn);

			if (model.Applicant != null)
			{
				BSTSmartScholarshipSerializer<Applicant> applicantSerializer = new BSTSmartScholarshipSerializer<Applicant>();
				XmlDocument applicantDoc = applicantSerializer.Serialize(model.Applicant);
				Registrar registrar = new Registrar();
				XmlDocument studentDoc = registrar.VerifyApplicant(applicantDoc);
				BSTSmartScholarshipSerializer<Student> studentSerializer = new BSTSmartScholarshipSerializer<Student>();
				model.Student = studentSerializer.Deserialize(studentDoc);

				return PartialView(model);
			}

			return Content("<div>Invalid Applicant</div>", "text/html");
		}
		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);
		}