nUnit Integration test weird interaction with other test [closed] - c#

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I have a bunch of tests which execute basically a file being moved around.
At the end I check if the file exists in the target directory.
I have 8 such tests which all look the same except for some minor differences.
One of the tests fails when run together with one specific other test (we call it: fTest). I found the culprit codeline and it is this simple assert running in a suceeding test (sTest). When I comment the Assert line, fTest does no longer fail.
var exists = File.Exists(#"\\?\" + destFullPath);
Assert.AreEqual(true, exists);
Even when I remove the first line and change the second line to Assert.AreEqual(true, true) the fTest still fails. Only commenting it out works.
This is some really weird behavior and I have absolutely no clue what is going on. How can one test affect the other?
EDIT: I just copied the sTest, deleted the original and renamed the copy to "TEST()" and now fTest works. What the f*?

I fixed it. Since these are integration tests there was one test which needed to run first. I added the order:1 attribute and now it works.

Related

Why does unity say that i have ; missing when i checked everything [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 days ago.
Improve this question
I get NetworkButtons.cs(9.87): error cs1002: ; expected. And i cant find the reason of it so here's my c# code
Code
I tried finding if ; was missing somewhere but i cant find it
If( ... ) is not correct. The keyword should be if( ... ) (all lower-case).
Because of the typo, the compiler first treats If() as a function call to a (probably non-existent) If(bool) function. Following the function call there is a missing ;, just like the compiler says, and following that an anonymous code block that will always run, regardless of the result of the If() function.
Now no such function exists (unless you made one), but the compiler doesn't get that far. If you try to fix this by adding the missing ; instead of fixing the keyword you'll get a new error complaining about the missing function definition.

I would like to add a label to a gridview that includes text and and image [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I want to add a link and image to a gridview when certain conditions are met.
I think that it can be done using the below code, but I get confused about where the " go and I know that some of them need to be \" but I'm not sure where. At the moment this won't compile, please could someone help me with this?
I've also investigated using an image button but that way seems more complex in my case, as the button should only appear in rows that fit the conditions. I'm open to using that method instead if you think that it's better.
if(line.SuperSessionIndicator == "1" || line.ErrorType =="S" )
{
lbl3.Text = "<aref=\"https://stackoverflow.com/questions/7167839/aspimage-with-link \">"<img url='Images/Prop.png\'/>\"\"<a/>";
}
You need to use following code to get it right.
lbl3.Text = "<a href=\"https://stackoverflow.com/questions/7167839/aspimage-with-link\"><img src='Images/Prop.png\'/><a/>";
The resulting markup from above C# code would be as below which looks correct.
<a href="https://stackoverflow.com/questions/7167839/aspimage-with-link"><img src='Images/Prop.png'/><a/>

What should i unit test here [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Let's say i have method like that
What should i test over here:
public Subscription ChangeState(TestClass testClass, DateTime currentTime)
{
testClass.IsDisabled = true;
testClass.IsDelete = true;
Update(testClass);
_logger.LogInfo($"Some Error message is going here");
return testClass;
}
First that come to my mind only test IsDisabled and IsDelete state adter test
Are there additional cases for testing?
It all boils down to what the method is supposed to do exactly rather than its current code, but given what you've got, I can find some dead simple tests:
The parameter must be the same as the return value.
Assert that both properties are set to true if sent as false.
If the properties are both true, is it really necesary to call Update? This is a potential improvement that a test can discover.
Check that Update is really called. Since this is another method (we don't know if private or what) you may verify its side effects.
If no error happens, there is no need to log an error message, that's a possible bug in your implementation (although not sure if it merits a unit test).
A clear bug is that the method doesn't check for nulls, a test will easily check that.
Not for wirting an unit test, but the currentTime parameter is not used at all and should be removed.

Record instance in F# is null in C# [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I'm working on an assignment for school in which we make a small game using monogame, with the added challenge of working in F#. The game logic is fully immutable F#, and the entrypoint is in C# by use of the Game class in monogame. I have however come across a weird problem concerning Record types in F#. In the logic (F#) I have something along the lines of:
...
module Vectors =
type Vector = {
x : double
y : double
}
let Zero : Vector = {x=0.0; y=0.0}
...
And in C# I have some code accessing Zero:
...
player.vector = Vectors.Zero;
...
Weirdly enough, when I try to now use player.vector, it comes up as null. When debugging Vector.Zero is also null. I've looked around for a few solutions, and it may be some trivial mistake, but I can't seem to find it.
When you build an F# project as an exe, but use it as a library, occasionally some initialisation code doesn't get called.
This can be fixed by changing the project to build as a library.
Solved - F# project was building as a console application.
Changing it to be a class library fixed the issue.
Thanks #JohnPalmer

If-statement behaving strange [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have the following code:
var test = _myDictionary.ContainsKey(myKey);
if (!test)
{
Logger.Error("My log message");
throw new ApplicationException("My exception message");
}
The dictionary contains the key. When debugging, the value of test is true
What happens, is that the code jumps directly to the throw statement, skipping the call to Logger, while it really shouldn't do neither - it should just skip the whole block and continue execution.
I've replaced the source completely from repository, I've cleaned and rebuilt numerous times, to no avail.
However, when I changed my code to
if (test)
{
// my code
}
else
{
Logger.Error("My log message");
throw new ApplicationException("My exception message");
}
everything works as expected.
Any ideas what might be going on here? It works as it currently is, but I won't rest easy unless I know what might be cause this.
UPDATE: I deleted my .suo file and some binaries in the output folder which were not deleted even if I cleaned the solution. After this, it seems to work fine
This can happen sometimes when the assembly and its PDB gets out of sync. When you're debugging, the debugger actually reads the relevant information from the PDB file, and not directly from your source file.
You should simply try and rebuild the project (or manually Clean then Build), then try again.
EDIT I misread your question, where you said you already tried rebuilding. In this case, during Debugging, go to Debug → Windows → Modules window, and make sure the symbol file that is loaded is in fact the correct one (e.g. loaded from the same bin\Debug location):

Categories