Search Results

Search found 1676 results on 68 pages for 'andrew philpott'.

Page 50/68 | < Previous Page | 46 47 48 49 50 51 52 53 54 55 56 57  | Next Page >

  • Zend Framework/PHPUnit: How to Stub/Mock an object method that connects to a database?

    - by Andrew
    In my Zend Framework project, I have a form that I am testing. In my form, a multi-select element gets its options from a model, which gets the data from the database. public function init() { $this->addElement('select', 'Region_ID', array('multiOptions' => $this->getRegions())); } protected function getRegions() { $mapper = new Model_RegionMapper(); return $mapper->getFormSelectData(); //this method will try to connect to a database (or get another object that will connect to the database) } I tried copying the example in the PHPUnit documentation, but it doesn't seem to be working. public function setUp() { $stub = $this->getMock('Model_RegionMapper'); $stub->expects($this->any()) ->method('getFormSelectData') ->will($this->returnValue(array('testdata'))); } public function testFoo() { //this will fail $form = new My_Form(); } The test fails because it is trying to find a table in the database that doesn't exist. But I don't want it to connect to the database at all. How do I correctly stub/mock this method so that it doesn't call the database?

    Read the article

  • iPhone NSMutableDictionary setObject forKey after initWithContentsOfFile

    - by andrew
    so here's my function + (void) AddAddress:(NSString*)ip:(NSString*)mac { NSMutableDictionary* currentAddresses = [[NSMutableDictionary alloc] initWithContentsOfFile:[self filePath:ADDRESSES_FILE]]; [currentAddresses setObject:mac forKey:ip]; [Configuration Write:currentAddresses]; [currentAddresses release]; } [self filePath:ADDRESSES_FILE] returns a string containing the full path of a file (ADDRESSES_FILE) located in the Documents. The file may not exist, in this case I want to just write an object to the dictionary and then write it down the problem is that when i do setObject forKey it doesn't add anything to the dict (if i just do alloc init to the dict, it works fine, but i want to read the records from the file, if there are any, and replace/add a record by using the AddAddress function)

    Read the article

  • does a ruby on rails rack class get access to the entire rails environment?

    - by Andrew Arrow
    that is when the def call(env) method is invoked by hitting any url, can I inside that method make some ActiveRecord queries, use classes defined in lib, etc. etc. Or is it more like an irb console without the rails env loaded? Another way to put it with a rake task example: task :foo => :environment do # with env end task :foo2 do # without env end I would think rack classes would NOT get the environment so they are super fast and don't take all the overhead of a normal rails request. But that doesn't seem to be the case. I CAN make ActiveRecord queries inside my rack class. So what is the advantage of rack then?

    Read the article

  • Re-execute target when specified as dependency to multiple rules

    - by andrew
    I have the following GNU makefile: .PHONY a b c d a: b c b: d c: d d: echo HI I would like the target 'd' to be run twice -- since it is specified as a dependency by both b & c. Unfortunately, the target 'd' will be executed only once. The output of running make will simply be 'HI', instead of 'HI HI'. How can I fix this? Thanks! To Clarify, the goal is something like this: subdirs = a b c build: x y x: target=build x: $(subdirs) y: target=prepare y: $(subdirs) $(subdirs): $(make) -f $@/makefile $(target)

    Read the article

  • CoreGraphics taking a while to show on a large view - can i get it to repeat pixels?

    - by Andrew
    This is my coregraphics code: void drawTopPaperBackground(CGContextRef context, CGRect rect) { CGRect paper3 = CGRectMake(10, 14, 300, rect.size.height - 14); CGRect paper2 = CGRectMake(13, 12, 294, rect.size.height - 12); CGRect paper1 = CGRectMake(16, 10, 288, rect.size.height - 10); //Shadow CGContextSetShadowWithColor(context, CGSizeMake(0,0), 10, [[UIColor colorWithWhite:0 alpha:0.5]CGColor]); CGPathRef path = createRoundedRectForRect(paper3, 0); CGContextSetFillColorWithColor(context, [[UIColor blackColor] CGColor]); CGContextAddPath(context, path); CGContextFillPath(context); //Layers of paper //CGContextSaveGState(context); drawPaper(context, paper3); drawPaper(context, paper2); drawPaper(context, paper1); //CGContextRestoreGState(context); } void drawPaper(CGContextRef context, CGRect rect) { //Shadow CGContextSaveGState(context); CGContextSetShadowWithColor(context, CGSizeMake(0,0), 1, [[UIColor colorWithWhite:0 alpha:0.5]CGColor]); CGPathRef path = createRoundedRectForRect(rect, 0); CGContextSetFillColorWithColor(context, [[UIColor blackColor] CGColor]); CGContextAddPath(context, path); CGContextFillPath(context); //CGContextRestoreGState(context); //Gradient //CGContextSaveGState(context); CGColorRef startColor = [UIColor colorWithWhite:0.92 alpha:1.0].CGColor; CGColorRef endColor = [UIColor colorWithWhite:0.94 alpha:1.0].CGColor; CGRect firstHalf = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width / 2, rect.size.height); CGRect secondHalf = CGRectMake(rect.origin.x + (rect.size.width / 2), rect.origin.y, rect.size.width / 2, rect.size.height); drawVerticalGradient(context, firstHalf, startColor, endColor); drawVerticalGradient(context, secondHalf, endColor, startColor); //CGContextRestoreGState(context); //CGContextSaveGState(context); CGRect redRect = rectForRectWithInset(rect, -1); CGMutablePathRef redPath = createRoundedRectForRect(redRect, 0); //CGContextSaveGState(context); CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] CGColor]); CGContextAddPath(context, path); CGContextClip(context); CGContextAddPath(context, redPath); CGContextSetShadowWithColor(context, CGSizeMake(0, 0), 15.0, [[UIColor colorWithWhite:0 alpha:0.1] CGColor]); CGContextStrokePath(context); CGContextRestoreGState(context); } The view is a UIScrollView, which contains a textview. Every time the user types something and goes onto a new line, I call [self setNeedsDisplay]; and it redraws the code. But when the view starts to get long - around 1000 height, it has very noticeable lag. How can i make this code more efficient? Can i take a line of pixels and make it just repeat that, or stretch it, all the way down?

    Read the article

  • Get more error information from unhandled error

    - by Andrew Simpson
    I am using C# in a desktop application. I am calling a DLL written in C that I do not have the source code for. Whenever I call this DLL I get an untrapped error which I trap in an UnhandledException event/delegate. The error is : object reference not set to an instance of an object But the stack trace is empty. When I Googled this the info back was that the error was being hanlded eleswhere and then rethrown. But this can only be in the DLL I do not have the source code for. So, is there anyway I can get more info about this error? This is my code... in program.cs... AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { try { Exception _ex = (Exception)e.ExceptionObject; //the stact trace property is empty here.. } finally { Application.Exit(); } } My DLL... [DllImport("AutoSearchDevice.dll", EntryPoint = "Start", ExactSpelling = false, CallingConvention = CallingConvention.StdCall)] public static extern int Start(int ASD_HANDLE); An I call it like so: public static void AutoSearchStart() { try { Start(m_pASD); } catch (Exception ex) { } }

    Read the article

  • Reusability, testability, code complexity reduction and showing-off-ability programming importance

    - by Andrew Florko
    There are lots of programming and architecture patterns. Patterns allow to make code cleaner, reusable, more testable & at last (but not at least) to feel the follower a real cool developer. How do you rank these considerations for you? What does affect you most when you decide to apply pattern? I wonder how many times code reusability (especially for MVP, MVC patterns) was important? For example DAL library often shared between projects (it's reusable) but how often controllers/views (abstracted via interfaces) are reused?

    Read the article

  • Powershell Select-Object from array not working

    - by Andrew
    I am trying to seperate values in an array so i can pass them to another function. Am using the select-Object function within a for loop to go through each line and separate the timestamp and value fields. However, it doesn't matter what i do the below code only displays the first select-object variable for each line. The second select-object command doesn't seem to work as my output is a blank line for each of the 6 rows. Any ideas on how to get both values $ReportData = $SystemStats.get_performance_graph_csv_statistics( (,$Query) ) ### Allocate a new encoder and turn the byte array into a string $ASCII = New-Object -TypeName System.Text.ASCIIEncoding $csvdata = $ASCII.GetString($ReportData[0].statistic_data) $csv2 = convertFrom-CSV $csvdata $newarray = $csv2 | Where-Object {$_.utilization -ne "0.0000000000e+00" -and $_.utilization -ne "nan" } for ( $n = 0; $n -lt $newarray.Length; $n++) { $nTime = $newarray[$n] $nUtil = $newarray[$n] $util = $nUtil | select-object Utilization $util $tstamp = $nTime | select-object timestamp $tstamp }

    Read the article

  • GUI style question: Icons in context menus?

    - by Andrew White
    Hi, It seems like not so long ago that it was standard to have icons/images in context menus and Microsoft seems to keep this up. But nowadays it seems to have disappeared in other apps: Chrome, iTunes etc. Anyone have an opinion / idea why this has happened or is it just completely personal taste (I for one like the images). A.

    Read the article

  • asp.net mvc route clashing with physical path in IIS7

    - by Andrew Bullock
    I'm messing about with controller organisation and I've hit a problem. If I have the following physical structure /Home/HomeController.cs /Home/Index.aspx /Home/About.aspx and I request the URI: /Home/Index I get a 403 Directory Listing Denied :( (im using a custom IControllerFactory and IViewEngine to look in this non-default path) Why is this happening? (I know the 403 is because its hitting the /Home folder, but why is it hitting the folder?) Why doesn't the UrlRoutingModule rewrite the route and let the controller pick up the request? Application_BeginRequest fires, but then it seems to pass control back to IIS to try and serve from the filesystem. Is it the UrlRoutingModule that defaults to a physical path if it exists before rewriting? Is there a way to make this work? N.B. Please don't suggest relocating my controllers etc. I know this is an obvious option, but that isn't the question ;) Using IIS7 In Integrated Mode Thanks

    Read the article

  • sharpsvn search repository commits

    - by Andrew Day
    Using sharpsvn I want to search all of the comments on the commited files in our svn server for specific strings. but i cannot get this to work. I have tried the following but it does not like my target path. Error: Revision type requires a working copy path, not a URL SvnRevisionRange range = new SvnRevisionRange(SvnRevision.Working, SvnRevision.Zero); string targetPath = "http://********:81/svn/"; Collection<SvnLogEventArgs> items; SvnLogArgs args = new SvnLogArgs { Range = range }; client.GetLog(new Uri(targetPath), args, out items); any ideas would be great

    Read the article

  • jQuery doesn't fire some events while I'm not logged in (Joomla)

    - by Andrew Sekaev
    So basically, .resize function fails until I log in. What does that mean? And how that can be fixed? Almost all other functions work fine. The site is still in developement, so no live version sadly. UPDATE: jQuery(window).resize(function() { var windowSize = jQuery(window).width() var windowWidth = (jQuery(window).width()-60)/6; var windowHeight = windowWidth/1.6; /*grid resize*/ jQuery('.xc-block').css({'width':windowWidth, 'height':windowHeight}); }); This is very simple script, cant really tell what can be wrong... Any thoughts guys? P.S:also no errors in FireBug...

    Read the article

  • Managing several custom content types from one module(drupal)

    - by Andrew
    Is it possible to declare and manage several custom content types inside one module? I'm creating a site that needs four custom content types and I'd like to manage them from one module instead of creating module for every content type. After some testing, I found out that it seems impossible. Because, unless hook_form and content type share the same name of module, drupal doesn't call hook_form. Here's how I'd like to do - function mycontent_node_info(){ return array( 'mycontent1' => array( 'name' => t('....'), 'module' => 'mycontent', 'description' => t('...), 'has_title' => TRUE, 'title_label' => t('Title'), 'has_body' => TRUE, 'body_label' => t('content body'), ), 'mycontent2' => array( ....... ), 'mycontent3' => array( ...... ), 'mycontent4' => array( ...... ), ); } function mycontent1_form(&$node){ $form['control1'] = array( '#type' => 'select', '#options' => array( '0' => t('selection 1'), '1' => t('selection 2'), ), '#attributes' => array('id'=>'control1'), ); $form['control2'] = array( '#type' => 'select', '#options' => array( '0' => t('1'), '1' => t('2'), '2' => t('3'), '3' => t('4'), ), '#attributes' => array('id'=>'control2'), ); return $form; } function mycontent2_form(&$node){ .... } function mycontent3_form(&$node){ .... } function mycontent4_form(&$node){ .... } Am I doing something wrong here or is not possible and there's no alternative other than creating module for every content types. I appreciate much your help.

    Read the article

  • NHibernate. Initiate save collection at saving parent

    - by Andrew Kalashnikov
    Hello, colleagues. I've got a problem at saving my entity. MApping: ?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Clients.Core" namespace="Clients.Core.Domains"> <class name="Sales, Clients.Core" table='sales'> <id name="Id" unsaved-value="0"> <column name="id" not-null="true"/> <generator class="native"/> </id> <property name="Guid"> <column name="guid"/> </property> <set name="Accounts" table="sales_users" lazy="false"> <key column="sales_id" /> <element column="user_id" type="Int32" /> </set> Domain: public class Sales : BaseDomain { ICollection<int> accounts = new List<int>(); public virtual ICollection<int> Accounts { get { return accounts; } set { accounts = value; } } public Sales() { } } When I save Sales object Account collection don't save at sales_users table. What should I do for saving it? Please don't advice me use classes inside List Thanks a lot.

    Read the article

  • HTML dynamic tags insert looks different compared to static layout

    - by Andrew Florko
    I program HTML interface with jquery. There is editable list of publications on the page and user can click any publication to edit details. Popup window appears with data and there is list of authors embedded into details form. There are edit/delete buttons against every of them + "add new author" button. User manipulates authors without page reload. When I insert a new author there are new edit/delete buttons created dynamically & embedded into page. I insert tags like this: <td class="author-actions"> <img onclick='edit(id)' .../> <img onclick='delete(id)' .../> </td> Just the same html-layout that is sent from web-server when popup window appears. But somehow it looks different. There is extraspace between images though firebug demonstrates the same css attributes applied. If I select with mouse inserted layout with IE, somehow it can reorder and become the same-looklike as the those, send by web-server. What can it be?

    Read the article

  • Logging a certain event only once in ruby

    - by Andrew Grimm
    Are there any logging frameworks in ruby that allow you to log a specific event type only once? logger = IdealLogger.new logger.log(:happy_path, "We reached the happy path") # => logs this message logger.log(:happy_path, "We reached the happy path yet again") # => Doesn't log this logger.log(:sad_path, "We've encountered a sad path!") # => logs this message Also, is there a term for the concept of logging a certain event type only once?

    Read the article

  • Selenium: How to click an HTML button element?

    - by Andrew
    I have button on the page that being used as a link to another page. So when the user clicks the button they are redirected to the right page. I am using the Selenium extension for PHPUnit and I would like to test that the button is correctly redirecting the user. Here is the HTML that I am trying to test: <button onclick="window.location='/sponsor';" value="Continue" type="button" id="sponsorContinue" name="sponsorContinue">Continue</button> I have tried a lot of different approaches to click the button, but I can't seem to get any of them to work: $this->click("//button[@id='sponsorContinue']"); This command executes and does not throw any errors, but the page isn't redirected. It works fine when I manually click the button. What should I do?

    Read the article

  • MVP pattern. Presenter requires new view instance. Best practice

    - by Andrew Florko
    I try to apply MVP pattern for win.forms application. I have 2 forms: main & child. Main has a button and when you click it - child form should appear. There are 2 views interfaces that forms implement IMainView { event OnClick; ... } IChildView { ... } There are two presenters MainPresenter(IMainView) & ChildPresenter(IChildView) MainPresenter listens to OnClick event and then should create IChildView implementation. MainPresenter { ... MainClicked() { // it's required to create IChildView instance here } } How would you implement such creation typically? Shall IMainView has factory method for IChildView or may be it should be separate Views factory. What would you advise? Or maybe there is some misunderstanding of MVP here? Thank you in advance!

    Read the article

  • What are the primary advantages of Visual Studio Team Foundation Server over the other versions?

    - by Andrew Dunaway
    We are looking into the possibility of upgrading to Team Foundation Server 2008 for our development team. One of our primary reasons is some of the deployment capabilities surrounding BizTalk 2009, but I am curious what other benefits there are for other projects outside of BizTalk. Some of our interests so far are moving to a one click build and deploy process, the addition of unit tests, and continuous integration. Some definite steps forward for the company I work for. What other benefits or information should I look at as I pitch this to upper management? I am looking for technical reasons, money is a not really a concern for this discussion.

    Read the article

  • Why can't you return a List from a Compiled Query?

    - by Andrew
    I was speeding up my app by using compiled queries for queries which were getting hit over and over. I tried to implement it like this: Function Select(ByVal fk_id As Integer) As List(SomeEntity) Using db As New DataContext() db.ObjectTrackingEnabled = False Return CompiledSelect(db, fk_id) End Using End Function Shared CompiledSelect As Func(Of DataContext, Integer, List(Of SomeEntity)) = _ CompiledQuery.Compile(Function(db As DataContext, fk_id As Integer) _ (From u In db.SomeEntities _ Where u.SomeLinkedEntity.ID = fk_id _ Select u).ToList()) This did not work and I got this error message: Type : System.ArgumentNullException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : Value cannot be null. Parameter name: value However, when I changed my compiled query to return IQueryable instead of List like so: Function Select(ByVal fk_id As Integer) As List(SomeEntity) Using db As New DataContext() db.ObjectTrackingEnabled = False Return CompiledSelect(db, fk_id).ToList() End Using End Function Shared CompiledSelect As Func(Of DataContext, Integer, IQueryable(Of SomeEntity)) = _ CompiledQuery.Compile(Function(db As DataContext, fk_id As Integer) _ From u In db.SomeEntities _ Where u.SomeLinkedEntity.ID = fk_id _ Select u) It worked fine. Can anyone shed any light as to why this is? BTW, compiled queries rock! They sped up my app by a factor of 2.

    Read the article

  • Integration tests - "no exceptions are thrown" approach. Does it make sense?

    - by Andrew Florko
    Sometimes integration tests are rather complex to write or developers have no enough time to check output - does it make sense to write tests that make sure "no exceptions are thrown" only? Such tests provide some input parameters set(s) and doesn't check the result, but only make sure code not failed with exception? May be such tests are not very useful but appropriate in situations when you have no time?

    Read the article

< Previous Page | 46 47 48 49 50 51 52 53 54 55 56 57  | Next Page >