Search Results

Search found 47805 results on 1913 pages for 'return address'.

Page 75/1913 | < Previous Page | 71 72 73 74 75 76 77 78 79 80 81 82  | Next Page >

  • JUnit for Functions with Void Return Values

    - by RobotNerd
    I've been working on a Java application where I have to use JUnit for testing. I am learning it as I go. So far I find it to be useful, especially when used in conjunction with the Eclipse JUnit plugin. After playing around a bit, I developed a consistent method for building my unit tests for functions with no return values. I wanted to share it here and ask others to comment. Do you have any suggested improvements or alternative ways to accomplish the same goal? Common Return Values First, there's an enumeration which is used to store values representing test outcomes. public enum UnitTestReturnValues { noException, unexpectedException // etc... } Generalized Test Let's say a unit test is being written for: public class SomeClass { public void targetFunction (int x, int y) { // ... } } The JUnit test class would be created: import junit.framework.TestCase; public class TestSomeClass extends TestCase { // ... } Within this class, I create a function which is used for every call to the target function being tested. It catches all exceptions and returns a message based on the outcome. For example: public class TestSomeClass extends TestCase { private UnitTestReturnValues callTargetFunction (int x, int y) { UnitTestReturnValues outcome = UnitTestReturnValues.noException; SomeClass testObj = new SomeClass (); try { testObj.targetFunction (x, y); } catch (Exception e) { UnitTestReturnValues.unexpectedException; } return outcome; } } JUnit Tests Functions called by JUnit begin with a lowercase "test" in the function name, and they fail at the first failed assertion. To run multiple tests on the targetFunction above, it would be written as: public class TestSomeClass extends TestCase { public void testTargetFunctionNegatives () { assertEquals ( callTargetFunction (-1, -1), UnitTestReturnValues.noException); } public void testTargetFunctionZeros () { assertEquals ( callTargetFunction (0, 0), UnitTestReturnValues.noException); } // and so on... } Please let me know if you have any suggestions or improvements. Keep in mind that I am in the process of learning how to use JUnit, so I'm sure there are existing tools available that might make this process easier. Thanks!

    Read the article

  • Return XML data from a web service

    - by Nick LaMarca
    What is the best way to create a web service that returns a set of x,y coordinates? I am not sure on the object that is the best return type. When consuming the service I want to have it come back as xml preferibly something like this for example: <TheData> <Point> <x>0</x> <y>2</y> </Point> <Point> <x>5</x> <y>3</y> </Point> </TheData> If someone has a better structure to return please help I am new at all this.

    Read the article

  • Return rows from stored procedure

    - by molgan
    Hello I have this code: public IEnumerable<SomeClass> GetAvalibleThingies(DateTime startDate, DateTime endDate, int categoryID) { if (_entities.Connection.State == System.Data.ConnectionState.Closed) _entities.Connection.Open(); using (EntityCommand c = new EntityCommand("SomeEntities.GetAvalibleThingies", (EntityConnection)this._entities.Connection)) { c.CommandType = System.Data.CommandType.StoredProcedure; EntityParameter paramstartDate = new EntityParameter("startDate", System.Data.DbType.DateTime); paramstartDate.Direction = System.Data.ParameterDirection.Input; paramstartDate.Value = startDate; c.Parameters.Add(paramstartDate); ........ var x = c.ExecuteReader(); return x as IEnumerable<SomeClass>; }; But I can't get it to return a list of SomeClass. What's needed to do here? I use the entity framework 3.5sp1 one /M

    Read the article

  • return statement from within using

    - by Bob
    using (IDbCommand command = new SqlCommand()) { IDbDataAdapter adapter = new SqlDataAdapter(); DataSet ds = new DataSet(); adapter.SelectCommand = command; command.Connection = _dataAccess.Connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "GetProcData"; command.Parameters.Add(new SqlParameter("@ProcID ", procId)); adapter.Fill(ds); return ds.Tables[0].AsEnumerable(); } This returns an IEnumerable DataRow The question is that since the return is within the using statement, will it property dispose of the IDBCommand? I know I can easily refactor this so I change the scope of the DataSet outside of the using, but it is more of a wonder than anything else.

    Read the article

  • Overloading on return type ???

    - by Green Hyena
    scala> val shares = Map("Apple" -> 23, "MicroSoft" -> 50, "IBM" -> 17) shares: scala.collection.immutable.Map[java.lang.String,Int] = Map(Apple -> 23, MicroSoft -> 50, IBM -> 17) scala> val shareholders = shares map {_._1} shareholders: scala.collection.immutable.Iterable[java.lang.String] = List(Apple, MicroSoft, IBM) scala> val newShares = shares map {case(k, v) => (k, 1.5 * v)} newShares: scala.collection.immutable.Map[java.lang.String,Double] = Map(Apple -> 34.5, MicroSoft -> 75.0, IBM -> 25.5) From this example it seems like the map method is overloaded on return type. Overloading on return type is not possible right? Would somebody please explain what's going on here?

    Read the article

  • Using a linq or lambda expression in C# return a collection plus a single value

    - by ahsteele
    I'd like to return a collection plus a single value. Presently I am using a field to create a new list adding a value to the list and then returning the result. Is there a way to do this with a linq or lambda expression? private List<ChargeDetail> _chargeBreakdown = new List<ChargeDetail>(); public ChargeDetail PrimaryChargeDetail { get; set; } public List<ChargeDetail> ChargeBreakdown { get { List<ChargeDetail> result = new List<ChargeDetail>(_chargeBreakdown); result.Add(PrimaryChargeDetail); return result; } }

    Read the article

  • T-SQL stored procedure to return google style "suggested" search results

    - by stephen776
    Ok, using SQL Server 2008. On my web page I have a textbox with jQuery-UI AutoComplete hooked up. Now I need a stored procedure to search across all columns of a single table(or multiple joined tables I suppose) for a search string coming from the textbox/autocomplete AJAX call, and return "suggested" search strings. I am using the AdventureWorks db for testing(Products table) So for example, the product table has columns for product name and product number(among others) and I want to return suggested search strings based on user input where they may enter a product name and/or a product number. I have it working across a single column which was simple. Any ideas?

    Read the article

  • Return no records if FIndKey results in False?

    - by jwilfong
    Using TDataSet.FindKey you can locate records. When it results in True the datasets cursor will be positioned on the found record. When it results in False the cursor is not moved. This results in the record data prior to FindKey being issued being displayed in data aware components. How can I code the result of FindKey to return an empty record? if Not tblSomeTable.FindKey([SomeSearchData]) then begin < code to return empty or move data cursor to neutral position > end; Thanks, John

    Read the article

  • how to return value through php function when called through the anchor tag in html

    - by sumit
    Look at my code below <a href="https://secure.gate2shop.com/ppp/purchase.do?merchant_id=234555454545433&merchant_site_id=54443¤cy=USD&total_amount=39.99&item_name_1=IncidentSupportTier1&item_amount_1=39.99&item_quantity_1=1&checksum=**call php function to get the checksum value**&time_stamp=2010-06-14.14:34:33&version=3.0.0" onmouseover="document.myform.sub_but.src='checkout02.jpg'" onmouseout="document.myform.sub_but.src='butup.gif'" onclick="return val_form_this_page()"> <img src="http://www.techvedic.com/gifs/checkout02.jpg" width="143" height="39" border="0" alt="Submit this form" name="sub_but" /> On button click the href link will open. But before opening the link I need to calculate the cheksum. I know how to calculate it in PHP script. But please tell me how can I call the PHP function which will return the checksum value. Don’t worry about the code in PHP script.

    Read the article

  • What's the best way to return different cells depending on position in a UITableView

    - by Robert Conn
    I have a grouped UITableView that has 3 sections and a number of cells in each section that each need to be a different custom cell, with different display requirements. I currently have a large if statement in cellForRowAtIndexPath, with each branch instantiating and returning the appropriate custom cell based on interrogating the indexPath's section and row properties. e.g. if (indexPath.section == 0 && indexPath.row == 0) { // instantiate and return cell A } else if (indexPath.section == 1 && indexPath.row == 2) { // instantiate and return cell B } //etc etc What is best practice for this scenario? A large if statement does the job, but is it the best implementation?

    Read the article

  • How to return a copy of the data in C++

    - by Josh Curren
    I am trying to return a new copy of the data in a C++ Template class. The following code is getting this error: invalid conversion from ‘int*’ to ‘int’. If I remove the new T then I am not returning a copy of the data but a pointer to it. template<class T> T OrderedList<T>::get( int k ) { Node<T>* n = list; for( int i = 0; i < k; i++ ) { n=n->get_link(); } return new T( n->get_data() ); // This line is getting the error ********** }

    Read the article

  • How to return a 'read-only' copy of a vector

    - by michael
    Hi, I have a class which has a private attribute vector rectVec; class A { private: vector<Rect> rectVec; }; My question is how can I return a 'read-only' copy of my Vector? I am thinking of doing this: class A { public: const vect<Rect>& getRectVec() { return rectVect; } } Is that the right way? I am thinking this can guard against the callee modify the vector(add/delete Rect in vector), what about the Rect inside the vector?

    Read the article

  • Group by clause return latest row information

    - by I Like PHP
    below is my table structure table_movie_info i_movie_id |movie_actor_id |movie_actress_id |movie_director_id | movie_producer_id 48 | 5 | 9 | 66 | 21 48 | 6 | 15 | 88 | 22 48 | 7 | 12 | 77 | 23 one more table is table_movie movie_id | movie_year | movie_genre_id |movie_rating 1 | 2009 | 6 | 8 2 | 2001 | 5 | 7.5 48 | 2007 | 3 | 6.8 now i need total movie information using both table,i write below query SELECT * FROM table_movie_info LEFT JOIN table_movie ON movie_id = i_movie_id WHERE i_movie_id=48 GROUP BY i_movie_id above query return only one row , but i need such type of information movie_id=48, actors_id list=5,6,7 acttress_id list=9,15,12 etc.. please tell me the optimized query which h return complete information i need. thanks for helping me always.

    Read the article

  • Return an opaque object to the caller without violating type-safety

    - by JS Bangs
    I have a method which should return a snapshot of the current state, and another method which restores that state. public class MachineModel { public Snapshot CurrentSnapshot { get; } public void RestoreSnapshot (Snapshot saved) { /* etc */ }; } The state Snapshot class should be completely opaque to the caller--no visible methods or properties--but its properties have to be visible within the MachineModel class. I could obviously do this by downcasting, i.e. have CurrentSnapshot return an object, and have RestoreSnapshot accept an object argument which it casts back to a Snapshot. But forced casting like that makes me feel dirty. What's the best alternate design that allows me to be both type-safe and opaque?

    Read the article

  • in_array() - help on what specifically would return true

    - by Kerri
    I am using in_array, and I'm trying to use it in a way where it will only return true if it's an exact match of one of the objects in the array, not just if it's "in" the array. e.g. 1. $sample_array = array('123', '234', '345'); 2. $sample_array = array('23', '34', '45'); in_array('23', $sample_array); In the above example, I would only want version 2 to return true, because it has the exact string, '23'. Version 1 returns true as well though, because the array contains instances of the string '23'. How would I get this to work so that only version 2 returns true? Am I even using the right function?

    Read the article

  • When will [MFMailComposeViewController canSendMail] return NO

    - by pythonquick
    M iPhone app is using the MFMailComposeViewController class to send an in-app email with an attachment. The app will only attempt to display the mail composer dialog if the "canSendMail" method of class MFMailComposeViewController returns true (YES). Specifically, if the following method returns YES, it shows the mail composer, otherwise the user is presented with an error alert dialog stating that there are no email accounts set up on the device: - (BOOL)canDeviceSendEmail { Class mailClass = (NSClassFromString(@"MFMailComposeViewController")); return mailClass != nil && [mailClass canSendMail]; } A team of testers have reported that they get this error alert dialog, even when email accounts are set up on the device. The tester used an iPhone 3G with OS 3.1.3. Therefore the MFMailComposeViewController class must have existed, and the "canSendMail" method must have returned NO. My question is therefore: apart from the case when there are no email accounts set up on the device, in what other circumstances can the "canSendMail" method return NO? ~ Thanks

    Read the article

  • C# mysql one return last_insert_id

    - by Bernhard
    I am trying to create a method in which I can exequte mysql UPDATE, DELETE or INSERT query. The method must work when with an INSERT I ask or do not ask the last_insert_id(). Below is the code that I have at the moment: public int executeUID(MySqlCommand msCommand) { try { this.Open(); msCommand.Connection = this.msCon; return int.Parse(msCommand.ExecuteScalar().ToString()); } catch (MySqlException ex) { throw ex; } finally { this.Close(); } } The problem with this is is that when I use an insert query that returns a last_insert_id() the method works greatly. But when the query doesn't return an last_insert_id() the method malfunctions. How can I get this method to work?

    Read the article

  • Return multiple results using dynamic sql (postgresql 8.2)

    - by precose
    I want to loop through schemas and get a result set that looks like this: Count 5 834 345 34 984 However, I can't get it to return anything using dynamic sql...I've tried everything but 8.2 is being a real pain. Here is my function: CREATE OR REPLACE FUNCTION dwh.adam_test4() RETURNS void LANGUAGE plpgsql AS $function$ DECLARE myschema text; rec RECORD; BEGIN FOR myschema IN select distinct c.table_schema, d.p_id from information_schema.tables t inner join information_schema.columns c on (t.table_schema = t.table_schema and t.table_name = c.table_name) join dwh.sgmt_clients d on c.table_schema = lower(d.userid) where c.table_name = 'fact_members' and c.column_name = 'debit_card' and t.table_schema NOT LIKE 'pg_%' and t.table_schema NOT IN ('information_schema', 'ad_delivery', 'dwh', 'users', 'wand', 'ttd') order by table_schema LOOP EXECUTE 'select count(ucic) from '|| myschema || '.' ||'fact_members where debit_card = ''yes''' into rec; RETURN rec; END LOOP; END $function$

    Read the article

  • Jquery Match() IP Address?

    - by user1635970
    I'm using a jquery script to validate form fields. This works well, but I'd like to change the validation of one field to check for IP Addresses. The regex I want to use is : \b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b How do I amend the below to work with this ? (This is how the validation works for email address) jQuery("#Email").validate({ expression: "if (VAL.match(/^[^\\W][a-zA-Z0-9\\_\\-\\.]+([a-zA-Z0-9\\_\\-\\.]+)*\\@[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)*\\.[a-zA-Z]{2,4}$/)) return true; else return false;", message: "Should be a valid Email id" });

    Read the article

  • PHP: Return string between two characters

    - by Nic Hubbard
    I am wanting to use "keywords" within a large string. These keywords start and end using *my_keyword* and are user defined. How, within a large string, can I search and find what is between the two * characters and return each instance? The reason it might change it, that parts of the keywords can be user defined, such as *page_date_Y* which might show the year in which the page was created. So, again, I just need to do a search and return what is between those * characters. Is this possible, or is there a better way of doing this if I don't know the "keyword" length or what i might be?

    Read the article

  • Java / Spring MVC 3 validation of an email address

    - by Tim
    I have a Java backend with Spring MVC and I am using validation in this way on my domain object for an email address: import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; ... @NotNull @Size(min = 1, max = 100) @Pattern(regexp="^([a-zA-Z0-9\\-\\.\\_]+)'+'(\\@)([a-zA-Z0-9\\-\\.]+)'+'(\\.)([a-zA-Z]{2,4})$") private String email; But all I get with these lines of code Set<ConstraintViolation<Person>> failures = validator.validate(personObject); ... Map<String, String> failureMessages = new HashMap<String, String>(); for (ConstraintViolation<Person> failure : failures) { failureMessages.put(failure.getPropertyPath().toString(), failure.getMessage()); System.out.println(failure.getPropertyPath().toString()+" - "+failure.getMessage()) } I get this on the console: email - must match "^([a-zA-Z0-9\\-\\.\\_]+)'+'(\\@)([a-zA-Z0-9\\-\\.]+)'+'(\\.)([a-zA-Z]{2,4})$" but I have as email address [email protected], so the regexp does not match. So I have two prolems: What's wrong here? And how can I define a error message on my own, because display this to the user, that is not a good thing :-) Thank you in advance for your help and Best Regards.

    Read the article

  • SQL Query, return value from table with no join

    - by jdenomme19
    I'm hoping for an idea on the best way to approach what I'm trying to do. I have a table with a list of transactions. Each transactions has a PostDate in DateTime format. I have another table holding the fiscal period values. This table has the following columns; FiscalYear, FiscalMonth, StartDate, EndDate. I'm trying to write a query that will return all values from my transactions table, along with the FiscalYear and FiscalMonth of the PostDate. So I guess I'm just trying to return the FiscalYear and FiscalMonth values when the PostDate falls between the StartDate and EndDate. I've tried using a Subbuery, but I have little experience with them and kept returning an error message that the subquery was returning more than 1 value. Help would be appreciated SELECT Transactions.PostDate, Transactions.TranKey, Transactions.CustKey, (SELECT FiscalPeriod.FiscPer FROM FiscalPeriod WHERE (Transactions.PostDate > CONVERT(Datetime, FiscalPeriod.StartDate, 102)) AND (Transactions.PostDate < CONVERT(DATETIME, FiscalPeriod.EndDate, 102))) AS FisPer FROM Transactions

    Read the article

  • What do C# Table Adapters actually return?

    - by Raven Dreamer
    I'm working on an application that manipulates SQL tables in a windows form application. Up until now, I've only been using the pre-generated Fill queries, and self-made update and delete queries (which return nothing). I am interested in storing the value of a single value from a single column (an 'nchar(15)' name), and though I have easily written the SQL code to return that value to the application, I have no idea what it will be returned as. SELECT [Contact First Name] FROM ContactSkillSet WHERE [Contact ID] = @CurrentID Can the result be stored directly as a string? Do I need to cast it? Invoke a toString method?

    Read the article

  • Return the difference between the lowest and highest key

    - by stan
    This is a past exam paper i am attempting and have no way to check if the out put is correct as i am not capable of building one of these things the question is in the title class Tree{ Tree left; Tree right; int key; public static int span(Tree tree) { if ( tree == null ){ return null; } if( tree.left != null) int min = span(tree.left); } if( tree.right != null){ int max = span(tree.right); } return max - min; } } Could anyone suggest what i need to change to get 5/5 marks :D - the only thing we have to do is write the span method, the header was given for us Thanks

    Read the article

< Previous Page | 71 72 73 74 75 76 77 78 79 80 81 82  | Next Page >