本文整理汇总了C#中Server.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# Server.Validate方法的具体用法?C# Server.Validate怎么用?C# Server.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server.Validate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateValidatesChildren
public void ValidateValidatesChildren()
{
var validated = false;
var project = new ProjectStub
{
Name = "Project",
OnValidate = vl => validated = true
};
var server = new Server("Server", project);
var validationStub = new ValidationLogStub();
server.Validate(validationStub);
Assert.IsTrue(validated);
}
示例2: ValidateValidatesName
public void ValidateValidatesName()
{
var validated = false;
var server = new Server();
var validationStub = new ValidationLogStub
{
OnAddErrorMessage = (m, a) =>
{
Assert.AreEqual("The Server has no name specified.", m);
Assert.AreEqual(0, a.Length);
validated = true;
}
};
server.Validate(validationStub);
Assert.IsTrue(validated);
}
示例3: ValidateDetectsDuplicateChildItems
public void ValidateDetectsDuplicateChildItems()
{
var errorAdded = false;
var queue1 = new Queue("Queue");
var queue2 = new Queue("Queue");
var queue3 = new Queue("OtherQueue");
var server = new Server("Server", queue1, queue2, queue3);
var validationStub = new ValidationLogStub
{
OnAddErrorMessage = (m, a) =>
{
Assert.AreEqual(
"Duplicate {1} name detected: '{0}'", m);
CollectionAssert.AreEqual(
new[] { "Queue", "child" },
a);
errorAdded = true;
}
};
server.Validate(validationStub);
Assert.IsTrue(errorAdded);
}
示例4: ValidateDetectsDuplicateProjects
public void ValidateDetectsDuplicateProjects()
{
var errorAdded = false;
var project1 = new Project("Project");
var project2 = new Project("Project");
var childQueue = new Queue("Test", project2);
var project3 = new Project("OtherProject");
var server = new Server("Server", project1, childQueue, project3);
var validationStub = new ValidationLogStub
{
OnAddErrorMessage = (m, a) =>
{
Assert.AreEqual(
"Duplicate {1} name detected: '{0}'", m);
CollectionAssert.AreEqual(
new[] { "Project", "project" },
a);
errorAdded = true;
}
};
server.Validate(validationStub);
Assert.IsTrue(errorAdded);
}