コード例 #1
0
        public void onCallingGetApi_ReturnAddressBook()
        {
            //arrange
            //makes restrequest for getting all the data from json server by giving table name and method.get
            RestRequest request = new RestRequest("/AddressBook", Method.GET);
            //act
            //executing the request using client and saving the result in IrestResponse.
            IRestResponse response = client.Execute(request);

            //assert
            //assert for checking status code of get
            Assert.AreEqual(response.StatusCode, System.Net.HttpStatusCode.OK);
            //adding the data into list from irestresponse by using deserializing.
            List <AddressBookContactDetails> dataResponse = JsonConvert.DeserializeObject <List <AddressBookContactDetails> >(response.Content);

            //printing out the content for list of address book contact details
            foreach (AddressBookContactDetails contactDetails in dataResponse)
            {
                Console.WriteLine("AddressBookName:- " + contactDetails.addressBookName + " First Name:- " + contactDetails.firstName + " Last Name:- " + contactDetails.lastName + " Address:- " + contactDetails.address + " City:- " + contactDetails.city + " State:- " + contactDetails.state + " Zip:- " + contactDetails.zip + " phone number:- " + contactDetails.phoneNo + " Email:- " + contactDetails.eMail + " Date:-" + contactDetails.dateAdded);
            }
            //adding data in database using threading
            //adding multiple entries
            AddressBookOperations addressBookOperations = new AddressBookOperations();

            addressBookOperations.AddingMultipleContactDetailsUsingThreading(dataResponse);
        }
コード例 #2
0
        public void AddingMultipleContactsIntoDataBaseUsingThreading()
        {
            //instatiating address book operations object
            AddressBookOperations addressBookOperations = new AddressBookOperations();
            //getting data from multiple contacts to be added in list method
            List <AddressBookContactDetails> contactDetails = MultipleContactsToBeAddedInList();
            //starting stopwatch
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            //executing method of adding multiple contacts using threading
            addressBookOperations.AddingMultipleContactDetailsUsingThreading(contactDetails);
            stopwatch.Stop();
            Console.WriteLine("Elapsed Time: " + stopwatch.Elapsed);
        }