public void TestGetPersonById()
        {
            PersonServiceClient client = new PersonServiceClient();

            var person = client.GetPersonById(5, new PersonIncludes { Phones = true, Addressses = true, Accounts = true });

            client.Close();
        }
예제 #2
0
        public void AssertThatTheServiceCanRun()
        {
            PersonServiceClient client = new PersonServiceClient();

            client.Open();
            Assert.IsNotNull(client);
            Assert.IsTrue(client.State == CommunicationState.Opened);
            client.Close();
            Assert.IsTrue(client.State == CommunicationState.Closed);
        }
        public void TestGetPersonById()
        {
            var client = new PersonServiceClient();

            var person = client.GetPersonById(5, new PersonIncludes {
                Phones = true, Addressses = true, Accounts = true
            });

            client.Close();

            Assert.IsNotNull(person);
        }
예제 #4
0
        public Person GetPerson(string NIN)
        {
            PersonServiceClient client = new PersonServiceClient();

            client.ClientCredentials.UserName.UserName = "******";
            client.ClientCredentials.UserName.Password = "******";

            LookupParameters lookupParameter = new LookupParameters();

            lookupParameter.NIN = NIN;

            var person = client.GetPerson(lookupParameter);

            client.Close();

            return(person);
        }
        public void TestPersonDocumentSearch()
        {
            var client = new PersonServiceClient();

            var searchCriteria = new PersonDocument();
            searchCriteria.State = "NY";

            var pageOfListPersonDocuments = client.SearchPersons(1, 10, "lastname", SortDirection.Ascending, searchCriteria);
            client.Close();

            // Verify that only 10 records or less are returned
            Assert.IsTrue(pageOfListPersonDocuments.Data.Count <= 10);

            // Verify that only NY state record are returned
            foreach (PersonDocument personDoc in pageOfListPersonDocuments.Data)
                Assert.AreEqual(personDoc.State, "NY");
        }
        public void TestPersonDocumentSearch()
        {
            PersonServiceClient client = new PersonServiceClient();

            var searchCriteria = new Dictionary<PersonSearchColumn, string>();
            searchCriteria.Add(PersonSearchColumn.State, "NY");

            var pageOfListPersonDocuments = client.SearchPersons(1, PersonSearchColumn.LastName, SortDirection.Ascending, 10, searchCriteria);

            // Verify that only 10 records or less are returned
            Assert.IsTrue(pageOfListPersonDocuments.Data.Count <= 10);

            // Verify that only NY state record are returned
            foreach (PersonDocument personDoc in pageOfListPersonDocuments.Data)
                Assert.AreEqual(personDoc.State, "NY");

            client.Close();
        }
        public void TestPersonDocumentSearch()
        {
            var client = new PersonServiceClient();

            var searchCriteria = new PersonDocument();

            searchCriteria.State = "NY";

            var pageOfListPersonDocuments = client.SearchPersons(1, 10, "lastname", SortDirection.Ascending, searchCriteria);

            client.Close();

            // Verify that only 10 records or less are returned
            Assert.IsTrue(pageOfListPersonDocuments.Data.Count <= 10);

            // Verify that only NY state record are returned
            foreach (PersonDocument personDoc in pageOfListPersonDocuments.Data)
            {
                Assert.AreEqual(personDoc.State, "NY");
            }
        }
        public HttpResponseMessage Get(String id)
        {
            //Connect to person service
            PersonServiceClient client = new PersonServiceClient();

            client.ClientCredentials.UserName.UserName = "******";
            client.ClientCredentials.UserName.Password = "******";

            //Add id to lookupparameters and fetch data
            LookupParameters lookupParameters = new LookupParameters();

            lookupParameters.NIN = id;
            Person xml = client.GetPerson(lookupParameters);

            client.Close();

            //serialize Person data to string
            var stringwriter = new System.IO.StringWriter();
            var serializer   = new XmlSerializer(xml.GetType());

            serializer.Serialize(stringwriter, xml);

            //convert from xml to json
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(stringwriter.ToString());

            var json = JsonConvert.SerializeXmlNode(doc, Newtonsoft.Json.Formatting.Indented, false);

            //return json
            var res = Request.CreateResponse(HttpStatusCode.OK);

            res.Content = new StringContent(json, Encoding.UTF8, "application/json");

            return(res);
        }