mardi 30 septembre 2014

Unit Test In N Tier Architecture


Vote count:

0




I want to write tests for a program that is coded by someone else. But I have some problems while writing tests. I can't understand exactly how to fake some objects. I searched and found Unit Test for n tier architecture but It doesn't help me. For example, I want to write a test for code below (I know It is a dummy code for just clarification)





public List<CustomerObject> FetchCustomersByName(CustomerObject obj)
{
DAL customerDal = new DAL();
//Maybe other operations
List<CustomerObject> list = customerDal.FetchByName(obj.Name);
//Maybe other operations over list
return list;
}



I just want to test FetchCustomersByName but there is connection with DAL. I think creating stub class but In this case I have to change my original code. And it was coded by someone else. How can I write a test for this method?


Thanks in advance.



asked 22 secs ago

Mehmet

131






Unit Test In N Tier Architecture

haw to convert index array to associative array?


Vote count:

0




I have an array like that



$products = array(array(354),array(1),array(375),array(1),array(344),array(2));


and i want to achieve array like that



$arrProducts= array(array('product_id'=>354,'qty'=>1),array('product_id'=>375,'qty'=>1),array('product_id'=>344,'qty'=>2));


I achieved this array using this code



foreach($products as $val)
{
$abc[] =$val[0];

}

for($i=0;$i<count($abc);$i++)
{
if($i%2==0)
{
$newarr[]['product_id'] = $abc[$i];
}
else{
$newarr[]['qty'] = $abc[$i];
}
}


for($j=0;$j<count($newarr);$j++)
{
if($j%2==0)
{
$arrProducts[] = array_merge($newarr[$j],$newarr[$j+1]);
}
else{
continue;
}
}

echo '<pre>';
print_r($arrProducts);


but i think my way to get this array is too long so how can i get this array in short way using some array functions or should i use this code?



asked 38 secs ago







haw to convert index array to associative array?

lundi 29 septembre 2014

fsockopen() unable to connect to localhost : 25


Vote count:

0




I have one project developed using codeigniter framework. In that I need to send mail to the user but I'm getting the error while sending mail


A PHP Error was encountered

Severity: Warning


Message: fsockopen(): unable to connect to localhost:25 (Connection refused)


Filename: libraries/Email.php


Line Number: 1689


why I'm getting this?



asked 52 secs ago







fsockopen() unable to connect to localhost : 25

WebView embedded video playback options disappeared in iOS 8.0


Vote count:

0




I had embedded video in webview which is loaded from app bundle but now i am having one issue in iOS 8.0.


I am not able to see video playback and zoom option panel when i tap on it. I can make it fullscreen by pinch gesture and able to see option panel in full screen but not able to see it while playing normally.


It seems that uiwebview content is not in center or may be its content size is increased. I tried to found its solution online but couldn't found any solution for that. I tried everything which i found about embedding video in uiwebview but the issues is not resolved yet.


Code which i have done to integrate it:



webviewFrame = CGRectMake(335, 67, 675, 670);
webview = [[UIWebView alloc] initWithFrame:webviewFrame];
[webview setBackgroundColor:[UIColor clearColor]];
[webview setOpaque:NO];
webview.delegate=self;
webview.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[webview setScalesPageToFit:YES];
[webview.layer setMasksToBounds:YES];
[webview.layer setCornerRadius:15.0f];
[webview.layer setBorderColor:[UIColor grayColor].CGColor];
[webview.layer setBorderWidth:2.0];

[self.view addSubview:webview];
webview.hidden=NO;
webview.delegate=self;
btn_Zoom.hidden=YES;
btnMail.hidden=YES;

UIScrollView* sv = (UIScrollView*)[webview.subviews objectAtIndex:0];
sv.scrollEnabled=NO;
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:strPath isDirectory:YES]]];


- (void)webViewDidFinishLoad:(UIWebView *)webView{
NSLog(@"finish loading");
[appDelegate hideIndicator];
self.view.userInteractionEnabled=YES;

CGSize contentSize = CGSizeMake(webView.frame.size.width,
webView.frame.size.height);
webview.scrollView.contentSize = contentSize;
[webview setScalesPageToFit:YES];
self.automaticallyAdjustsScrollViewInsets = YES;
self.edgesForExtendedLayout = YES;

}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
NSLog(@"error=%@",error);
[appDelegate hideIndicator];
self.view.userInteractionEnabled=YES;

CGSize contentSize = CGSizeMake(webView.frame.size.width,
webView.frame.size.height);
webview.scrollView.contentSize = contentSize;
[webview setScalesPageToFit:YES];
self.automaticallyAdjustsScrollViewInsets = YES;
self.edgesForExtendedLayout = YES;
}


asked 21 secs ago







WebView embedded video playback options disappeared in iOS 8.0

bootstrap Modal popup does not appear in backbone.js


Vote count:

0




The modal popup just blinks, does not appear on screen. I have added bootstrap.min.js file inside the body tag in backbone.js view through javascript code by creating script tag. when i inspect through firebug does not appear inside the body tag.


The below code in backbone view folio page



html += "<img class='folio-thumb btn btn-primary btn-lg' data-toggle='modal' data-target='#myModal'/>";


The below code in backbone view preview page



var html = "<button class='btn btn-primary btn-lg' data-toggle='modal' data-target='#myModal'>Launch demo modal</button>";
html += "<div class='modal fade' id='myModal' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>";
html += "<div class='modal-dialog'>";
html += "<div class='modal-content'>";
html += "<div class='modal-header'>";
html += "<button type='button' class='close' data-dismiss='modal'><span aria-hidden='true'>&times;</span><span class='sr-only'>Close</span></button>";
html += "<h4 class='modal-title' id='myModalLabel'>Modal title</h4>";
html += "</div>";
html += "<div class='modal-body'>";
html += "<p>Launch Excellence is highly challenging in Pharmerging markets, and yet launching new innovative drugs is becoming a Pharmerging priority where multinationals must succeed. </p>";
html += "</div>";
html += "<div class='modal-footer'>";
html += "<button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>";
html += "<button type='button' class='btn btn-primary'>Save changes</button>";
html += "</div>";
html += "</div>";
html += "</div>";
html += "</div>";


asked 32 secs ago







bootstrap Modal popup does not appear in backbone.js

OpenCL on CPU Device - what happens under the hood?


Vote count:

0




So if I run an openCL Kernel function on a CPU device and not a GPU device, does the kernel automatically make use of all the cores on the CPU? For instance my system says I have 4 cores on the CPU will the kernel make use of all 4 cores automatically?


If the above is true, then does it mean that running an openCL kernel on a single CPU device would be equivalent to using standard std::threads (assuming we're using C++) to carry out the same tasks?


I ask because on my current computer openCL seems to only be able to access one CPU and no GPUs. So if I were to use openCL to parallelize my code it seems like it might be overkill if it will essentially be doing the same thing as an std::thread based implementation.



asked 1 min ago







OpenCL on CPU Device - what happens under the hood?

How to launch multiple kernel in OpenCL, inside the program?


Vote count:

0




I m trying to see the performance of the Opencl Programming model on GPUs, now while testing the Programming model, i have to launch the kernel by using clEnqueueNDkernel(), i m trying to call this function multiple of times, so that i can see how it performs when two or four concurrent kernels are launched.


i observe that the program is taking the same amount of time as launching one kernel, now i m assuming that it is just running the kernel once, cause there is no way it takes the same amount of time to run two or four concurrent kernels.


now i want to know how to i launch multiple kernels on one GPU,


eg : i want to launch something like : clEnqueueNDkernel() clEnqueueNDkernel()


if anyone can help it would be great, or if there is a link that anyone can share, would be really helpful


thanks in advance.



asked 1 min ago







How to launch multiple kernel in OpenCL, inside the program?