嗨,我想知道我必须在VS中评论一个方法,当我想选择这些方法时,我在工具提示中看到我的描述?
在C#中:
多少个接口,一个类可以实现在同一时间?
public class MyClass: IInteferface_1, IInterface_2, ... , IInterface_N
{
}
Run Code Online (Sandbox Code Playgroud)
N有限制吗?
不要担心我不想实现或维护这样的对象.我只是想知道是否有限制.
我有以下代码.这个想法是检测整个单词.
bool contains = Regex.IsMatch("Hello1 Hello2", @"\bHello\b"); // yields false
bool contains = Regex.IsMatch("Hello Hello2", @"\bHello\b"); // yields true
bool contains = Regex.IsMatch("Hello: Hello2", @"\bHello\b"); **// yields true, but should yield false**
Run Code Online (Sandbox Code Playgroud)
似乎正则表达式忽略了冒号.如何修改代码,使最后一行返回false?
我有以下控制器(请注意,在实例化时我进行显式调用$scope.getNotifications()):
bla.controller("myctrl", [
"$scope", "$http", "configs", function ($scope, $http, configs) {
$scope.getNotifications = function () {
$http.get("bla/blabla").success(function (data) {
});
};
$scope.removeNotification = function (notification) {
var index = $scope.allNotifications.indexOf(notification);
$scope.allNotifications.splice(index, 1);
};
$scope.getNotifications();
}
]);
Run Code Online (Sandbox Code Playgroud)
然后我做了一些单元测试(注意控制器在每个测试之前被实例化):
describe("blaController", function () {
var scope, $httpBackend;
beforeEach(module('bla'));
beforeEach(inject(function ($controller, $rootScope, _$httpBackend_) {
scope = $rootScope.$new();
$httpBackend = _$httpBackend_;
$controller('blaCtrl', { $scope: scope });
}));
afterEach(function(){
//assert
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
});
it("should get all notifications from server when instantiated", function () { …Run Code Online (Sandbox Code Playgroud) 如何测试此代码(ASP.NET MVC 4,.NET 4.5 Web应用程序中的登录方法):
public ActionResult Login(LoginModel model, string returnUrl)
{
if (ModelState.IsValid && _userCredentialsService.ValidateUser(model.UserName, model.Password))
{
SessionAuthentication.SetAuthCookie(model.UserName, _userCredentialsService.GetUserGroups(model.UserName), model.RememberMe);
return RedirectToLocal(returnUrl);
}
}
Run Code Online (Sandbox Code Playgroud)
使用此SetAuthCookie方法:
public static void SetAuthCookie(IEnumerable<Claim> claims, bool isPersistent)
{
if (!HttpContext.Current.Request.IsSecureConnection && FormsAuthentication.RequireSSL)
{
throw new HttpException(500, "Connection is not secured with SSL");
}
var sessionToken = CreateSessionSecurityToken(CreatePrincipal(claims.ToList()), isPersistent);
FederatedAuthentication.SessionAuthenticationModule.WriteSessionTokenToCookie(sessionToken);
}
Run Code Online (Sandbox Code Playgroud)
我在访问时得到一个空引用异常SessionAuthenticationModule(在尝试获取HttpContext时提到的属性在内部抛出异常).这是堆栈跟踪:
at System.IdentityModel.Services.FederatedAuthentication.GetHttpContextModule[T]()
at System.IdentityModel.Services.FederatedAuthentication.GetHttpModule[T]()
at System.IdentityModel.Services.FederatedAuthentication.get_SessionAuthenticationModule()
Run Code Online (Sandbox Code Playgroud)
我在位于测试程序集中的app.config中制作了我的web.config的精确副本,代码在应用程序的正常运行时中运行.
我已经使用了HttpSimulator和MvcContrib测试助手,以便HttpContext得到设置,但仍然抛出异常.有没有人有如何测试它的解决方案或解决方法?
除了StrCpy和StrLen之外,NSIS中是否有任何字符串解析函数?
或者是一个插件,它有strstr,strcmp,find,contains等方法.
MemoryCache如果我希望缓存数据在多个WCF服务中可见(使用PerCall实例模式),那么使用该类是一个有效的选项吗?
有两种情况:
我的应用程序最初将与Windows Installer一起部署.
我正在寻找的解决方案的主要特点包括:
在应用程序运行时支持静默更新(或自动重启客户端)
易于维护和管理包装过程
避免复杂的自定义或安装脚本
你有什么想法我怎么能实现这个目标?即使它意味着修改应用程序代码以支持任何想法.
应用程序是.net 2.0
当系统从休眠状态唤醒时,有没有办法在我的C#2.0应用程序中获取通知(事件)?
我的应用程序在系统进入休眠状态时在系统托盘中运行.
我创建了简单的MS单元测试项目.Assert.Equal(true, true).当我想运行测试时,我收到来自Resharper和Visual Studio的错误.
"单元测试Runner未能运行测试
System.Xml.XmlException:解析EnityName时发生错误.第1行,第17位."
我错过了什么吗
编辑:我无法添加屏幕截图,我无法选择要复制的文本.好的,我会尽我所能写出来的.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.xml.XmlTextReaderImpl.Throw(String res,String arg)
at System.Xml.XmlText.ParseEnityName()
at System.Xml.XmlTextReaderImplparseEnityReference
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextLoader.ParsePartialContent(XmlNode parentNode,String innerxmltext, xmlNodeType nt)
at System.Xml.XmlElement.set_InnerXml(string value)
at Microsoft.VisualStudio.TestPlatform.Utilities.InferSettingHelper.AppendOrModifyChild(XpathNavigator,String nodePatH,String nodeNAME,sTRING INNERxML)
at Microsoft.VisualStudio.TestPlatform.Utilities.InferSettingsHelper.UpdatedRunConfiguration(XPathNavigator, ArchitectureeffectivePlatform,FrameworkVersion effectiveFramework,String resultsDirectory,String solutionDirectory,String binariesRootDirectory)
Microsoft.VisualStudio.TestPlatform.Utilities.InferSettingsHelper.MergeRunSettingsAndFindCompatibleSource()
at JetBrains.ReSharper.UnitTestProvider.MSTest11.MsTest11Runner.Run(IRemoteTaskServer server,String assemblyLocation,String runConfigurationFilename,IUnitTestRun run)
Run Code Online (Sandbox Code Playgroud) 我有一个字符串列表List<string>.实际上是文件路径列表.我需要将它发送到网络服务.该清单可包含大量物品(1 000 - 10 000).
实现这一目标的最有效方法是什么?考虑到消息有效载荷将非常高.
我在寻求想法和原则,而不是代码示例.
非常感谢.
c# ×8
.net ×4
unit-testing ×3
angularjs ×1
caching ×1
hibernation ×1
httpbackend ×1
iis ×1
interface ×1
jasmine ×1
javascript ×1
memorycache ×1
nsis ×1
patch ×1
regex ×1
request ×1
silent ×1
string ×1
wcf ×1