I would like to know what are the open source and commerical tools for window Service Testing. Like memeory usage and code leakes etc ..
C# 2.0 - Window Service.
Hi,
this is something I know I should embrass in my coding projects but, due to lack of knowledge and my legendary lazyness, I do not do.
In fact, when I do them, I feel like overloaded and I finally give up.
What I am looking for is a good book/tutorial on how to really write good tests -i.e useful and covering a large spectrum of the code -.
Regards
Hi,
What's the recommended way to cover off unit testing of generic classes/methods?
For example (referring to my example code below). Would it be a case of have 2 or 3 times the tests to cover testing the methods with a few different types of TKey, TNode classes? Or is just one class enough?
public class TopologyBase<TKey, TNode, TRelationship>
where TNode : NodeBase<TKey>, new()
where TRelationship : RelationshipBase<TKey>, new()
{
// Properties
public Dictionary<TKey, NodeBase<TKey>> Nodes { get; private set; }
public List<RelationshipBase<TKey>> Relationships { get; private set; }
// Constructors
protected TopologyBase()
{
Nodes = new Dictionary<TKey, NodeBase<TKey>>();
Relationships = new List<RelationshipBase<TKey>>();
}
// Methods
public TNode CreateNode(TKey key)
{
var node = new TNode {Key = key};
Nodes.Add(node.Key, node);
return node;
}
public void CreateRelationship(NodeBase<TKey> parent, NodeBase<TKey> child) {
.
.
.
HI there
I was wondering if there is a better way of testing that a view has rendered in MVC.
I was thinking perhaps I should render the view to a string but perhaps there are simpler methods?
Basically what I want to know if that the view for a given action has rendered without errors
I m already testing the view model but I want to see that rendering the view giving a correct ViewData.Model works
How do you access a file to use in unit tests? (Every time I have asked with more specific information I cannot get ANYONE to answer. This is as freaking basic as it gets. HELLO? IS ANYONE OUT THERE?)
Is there any good framework for comparing whole objects?
now i do
assertEquals("[email protected]", obj.email);
assertEquals("5", obj.shop);
if bad email is returned i never get to know if it had the right shop, i would like to get a list of incorrect fields.
Guice Singletons are weird for me
First I thought that
IService ser = Guice.createInjector().getInstance(IService.class);
System.out.println("ser=" + ser);
ser = Guice.createInjector().getInstance(IService.class);
System.out.println("ser=" + ser);
will work as singleton, but it returns
ser=Service2@1975b59
ser=Service2@1f934ad
its ok, it doesnt have to be easy.
Injector injector = Guice.createInjector();
IService ser = injector.getInstance(IService.class);
System.out.println("ser=" + ser);
ser = injector.getInstance(IService.class);
System.out.println("ser=" + ser);
works as singleton
ser=Service2@1975b59
ser=Service2@1975b59
So i need to have static field with Injector(Singleton for Singletons)
how do i pass to it Module for testing?
Below is a GLSL fragment shader that outputs a texel
if the given texture coord is inside a box, otherwise a
color is output. This just feels silly and the there
must be a way to do this without branching?
uniform sampler2D texUnit;
varying vec4 color;
varying vec2 texCoord;
void main() {
vec4 texel = texture2D(texUnit, texCoord);
if (any(lessThan(texCoord, vec2(0.0, 0.0))) ||
any(greaterThan(texCoord, vec2(1.0, 1.0))))
gl_FragColor = color;
else
gl_FragColor = texel;
}
Below is a version without branching, but it still feels clumsy.
What is the best practice for "texture coord clamping"?
uniform sampler2D texUnit;
varying vec4 color;
varying vec4 labelColor;
varying vec2 texCoord;
void main() {
vec4 texel = texture2D(texUnit, texCoord);
bool outside = any(lessThan(texCoord, vec2(0.0, 0.0))) ||
any(greaterThan(texCoord, vec2(1.0, 1.0)));
gl_FragColor = mix(texel*labelColor, color,
vec4(outside,outside,outside,outside));
}
I am clamping texels to the region with the label is -- the texture s & t coordinates will be between 0 and 1 in this case. Otherwise, I use a brown color where the label ain't.
Note that I could also construct a branching version of the code that does not perform a texture lookup when it doesn't need to. Would this be faster than a non-branching version that always performed a texture lookup? Maybe time for some tests...
I have a file containing the following content 1000 line in the following format:
abc def ghi gkl
how to write perl script to convert it into :
abc ghi
??
HOSTNAME=$1
#missing files will be created by chk_dir
for i in `cat filesordirectorieslist_of_remoteserver`
do
isdir=remsh $HOSTNAME "if [ -d $i ]; then echo dir; else echo file; fi"
if [ $isdir -eq "dir" ]
then
remsh $HOSTNAME "ls -d $i | cpio -o" | cpio -id
else
remsh $HOSTNAME "ls | cpio -o" | cpio -id
fi
done
i need simple solution for checking remote file is directory or file ?
thanks
Using Hibernate, what is the most efficient way to determine if a table is empty or non-empty? In other words, does the table have 0, or more than 0 rows?
I could execute the HQL query select count(*) from tablename and then check if result is 0 or non-0, but this isn't optimal as I would be asking the database for more detail than I really need.
I'm writing an RPC middleware in C++. I have a class named RPCClientProxy that contains a socket client inside:
class RPCClientProxy {
...
private:
Socket* pSocket;
...
}
The constructor:
RPCClientProxy::RPCClientProxy(host, port) {
pSocket = new Socket(host, port);
}
As you can see, I don't need to tell the user that I have a socket inside.
Although, to make unit tests for my proxies it would be necessary to create mocks for sockets and pass them to the proxies, and to do so I must use a setter or pass a factory to the sockets in the proxies's constructors.
My question: According to TDD, is it acceptable to do it ONLY because the tests? As you can see, these changes would change the way the library is used by a programmer.
I'm not experiencing any performance issues, however I'd like to take a look at what takes how long and how much memory cpu it uses etc.
I'd like to get a firsthand understanding of which things can be bottle necks etc and improve any code i might reuse or build upon... (perfectionist)
I'm looking to create a litte function that i can call at the begining and end of each function that records:
execution time
memory used
cpu demand
any ideas?
I came across this algorithm for testing primality through trial division I fully understand this algorithm
static boolean isPrime(int N) {
if (N < 2)
return false;
for (int i = 2; i <= Math.sqrt(N); i++)
if (N % i == 0)
return false;
return true;
}
It works just fine. But then I came across this other one which works just as good but I do not fully understand the logic behind it.
static boolean isPrime(int N) {
if (N < 2)
return false;
for (int i = 2; i * i<N; i++)
if (N % i == 0)
return false;
return true;
}
It seems like i *i < N behaves like i <= Math.sqrt(N). If so, why?
I currently have a testing environment for web apps on a virtual machine.
The problem - i would like to keep IE 6 for testing and also have access to newer versions of IE as well.
How can i do this?
Thanks.
I have read a lot of programming books, many mention testing of various kinds. I have never really gotten into the topic of testing, but I realize how extremely important it is. Anyone know of some good books that provide a thorough exploration of this topic?
I've got a simple class that gets most of its arguments via init, which also runs a variety of private methods that do most of the work. Output is available either through access to object variables or public methods.
Here's the problem - I'd like my unittest framework to directly call the private methods called by init with different data - without going through init.
What's the best way to do this?
So far, I've been refactoring these classes so that init does less and data is passed in separately. This makes testing easy, but I think the usability of the class suffers a little.
Given the number X, is it a fibonnaci number?
Any source code or mathematical formula would be ok.
Yes, it looks like this is a duplicate of (this question). How does stack overflow deal with duplicates?
Is there a way to tell if a method is an override? For e.g.
public class Foo
{
public virtual void DoSomething() {}
public virtual int GimmeIntPleez() { return 0; }
}
public class BabyFoo: Foo
{
public override int GimmeIntPleez() { return -1; }
}
Is it possible to reflect on BabyFoo and tell if GimmeIntPleez is an override?
I have a Scala combinator parser that handles comma-delimited lists of decimal numbers.
object NumberListParser extends RegexParsers {
def number: Parser[Double] = """\d+(\.\d*)?""".r ^^ (_.toDouble)
def numbers: Parser[List[Double]] = rep1sep(number, ",")
def itMatches(s: String): Boolean = parseAll(numbers, s) match {
case _: Success[_] => true
case _ => false
}
}
The itMatches function returns true when given a string that matches the pattern. For example:
NumberListParser.itMatches("12.4,3.141") // returns true
NumberListParser.itMatches("bogus") // returns false
Is there a more terse way to do this? I couldn't find one in the documentation, but my function sees a bit verbose, so I wonder if I'm overlooking something.
I never use unitests in my apps . I know that exists many technologies for testing .NET based application. (For example NUnit). Which of this tools more comfortable and more understandable to use. Please can you show the good articles where can I find information about unitests and understand key situation where I must use them?