嗨,我正在对我的ASP.Net MVC2项目进行一些单元测试.我正在使用Moq框架.在我的LogOnController中,
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl = "")
{
FormsAuthenticationService FormsService = new FormsAuthenticationService();
FormsService.SignIn(model.UserName, model.RememberMe);
}
Run Code Online (Sandbox Code Playgroud)
在FormAuthenticationService类中,
public class FormsAuthenticationService : IFormsAuthenticationService
{
public virtual void SignIn(string userName, bool createPersistentCookie)
{
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName");
FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
}
public void SignOut()
{
FormsAuthentication.SignOut();
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是如何避免执行
FormsService.SignIn(model.UserName, model.RememberMe);
Run Code Online (Sandbox Code Playgroud)
这条线.或者有没有办法去Moq
FormsService.SignIn(model.UserName, model.RememberMe);
Run Code Online (Sandbox Code Playgroud)
使用Moq框架而不更改我的ASP.Net MVC2项目.
我想在数据框中添加一个新列,其值由0或1组成.我使用了'randint'函数,
from random import randint
df1 = df.withColumn('isVal',randint(0,1))
Run Code Online (Sandbox Code Playgroud)
但我得到以下错误,
/spark/python/pyspark/sql/dataframe.py",第1313行,在withColumn断言isinstance(col,Column)中,"col应该是列"AssertionError:col应该是Column
如何使用自定义函数或randint函数为列生成随机值?
我正在Eclipse中开发一个Dynamic Web Project.我为商店数据库详细信息(用户名,密码等)创建了一个.properties文件.我通过右键单击项目和New - > File添加了它.我使用了Java util包Properties类.但它不起作用.我无法从文件中检索任何属性.这是我使用的代码,
Properties prop = new Properties();
try {
prop.load(new FileInputStream("database.properties"));
String db = prop.getProperty("database");
String userName = prop.getProperty("dbuser");
String password = prop.getProperty("dbpassword");
} catch (IOException ex) {
ex.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
有什么不对或有什么特别的地方我应该放置属性文件.
apache-spark ×1
c# ×1
eclipse ×1
java ×1
java-ee ×1
moq ×1
properties ×1
pyspark ×1
python ×1
unit-testing ×1