Hi there,
Been trying out the JustMock pro trial and I'm almost ready to buy. However, I have run into an issue which could be a deal breaker. Hoping someone with more knowledge of the product can steer me in the right direction.
I am attempting to test a private static method that resides in the codebehind file of a default.aspx page of a single-page web application (aka default.aspx.cs). The method under test is a very simple one that is a component of a much larger processes involving URL's, see below:
default.aspx.cs
namespace Company.Project
{
public partial class _default : System.Web.UI.Page
{
private static string CleanupURL(String theUrl)
{
theUrl = theUrl.ToLower();
theUrl = theUrl.Replace(@"\", "/");
while (!theUrl.IndexOf(".aspx").Equals(-1))
{
theUrl = theUrl.Substring(0, theUrl.IndexOf(".aspx"));
while (!theUrl.EndsWith("/") && theUrl.Length > 0)
{
theUrl = theUrl.Substring(0, theUrl.Length - 1);
}
}
return theUrl;
}
}
}
here is the test I have written (using nunit/justmock/dotcover test runner)
[Test]
public void WillCleanupUrl()
{
var instance = PrivateAccessor.ForType(typeof(_default));
string given = "server/subsite/default.aspx";
var expected = "server/subsite";
var returned = instance.CallMethod("CleanpUrl", given);
Assert.AreEqual(expected, returned);
}
My implementation is a copy/pasta of the example shown in the documentation regarding static methods with private accessors however the returned var is always null.
Other information:
This test is being executed inside of a virtual machine that has IIS/SQL/Sharepoint installed on it and it also communicates with a neighboring domain controller vm. Essentially, everything the project needs to run the entire application is running locally or nearby on the virtual lan, there is no true connection to the internet. I notice, using fiddler2, that requests are being sent to various URL's (monitor.ashx?) by the jetbrains dotcover test runner. Obviously, these requests fail. Not sure if this has something to do with it? Possible bug?
Any help or guidance on the issue would be greatly appreciated!
Been trying out the JustMock pro trial and I'm almost ready to buy. However, I have run into an issue which could be a deal breaker. Hoping someone with more knowledge of the product can steer me in the right direction.
I am attempting to test a private static method that resides in the codebehind file of a default.aspx page of a single-page web application (aka default.aspx.cs). The method under test is a very simple one that is a component of a much larger processes involving URL's, see below:
default.aspx.cs
namespace Company.Project
{
public partial class _default : System.Web.UI.Page
{
private static string CleanupURL(String theUrl)
{
theUrl = theUrl.ToLower();
theUrl = theUrl.Replace(@"\", "/");
while (!theUrl.IndexOf(".aspx").Equals(-1))
{
theUrl = theUrl.Substring(0, theUrl.IndexOf(".aspx"));
while (!theUrl.EndsWith("/") && theUrl.Length > 0)
{
theUrl = theUrl.Substring(0, theUrl.Length - 1);
}
}
return theUrl;
}
}
}
here is the test I have written (using nunit/justmock/dotcover test runner)
[Test]
public void WillCleanupUrl()
{
var instance = PrivateAccessor.ForType(typeof(_default));
string given = "server/subsite/default.aspx";
var expected = "server/subsite";
var returned = instance.CallMethod("CleanpUrl", given);
Assert.AreEqual(expected, returned);
}
My implementation is a copy/pasta of the example shown in the documentation regarding static methods with private accessors however the returned var is always null.
Other information:
This test is being executed inside of a virtual machine that has IIS/SQL/Sharepoint installed on it and it also communicates with a neighboring domain controller vm. Essentially, everything the project needs to run the entire application is running locally or nearby on the virtual lan, there is no true connection to the internet. I notice, using fiddler2, that requests are being sent to various URL's (monitor.ashx?) by the jetbrains dotcover test runner. Obviously, these requests fail. Not sure if this has something to do with it? Possible bug?
Any help or guidance on the issue would be greatly appreciated!