本文整理汇总了C#中Project.AddObserver方法的典型用法代码示例。如果您正苦于以下问题:C# Project.AddObserver方法的具体用法?C# Project.AddObserver怎么用?C# Project.AddObserver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Project
的用法示例。
在下文中一共展示了Project.AddObserver方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Builder
public Builder(Project project)
{
_project = project;
_project.AddObserver(new BuildObserver(this));
if (project == null)
throw new ArgumentNullException(nameof(project));
}
示例2: TestAddedProcessor_CalledWhenNewProjectItem
public void TestAddedProcessor_CalledWhenNewProjectItem()
{
var underTest = new Project();
var itemKind = "test";
var item = new ProjectItem("p1", itemKind);
var processor = new Mock<IProjectObserver>();
processor.Setup(s => s.NotifyItemAdded(underTest, item));
underTest.AddObserver(processor.Object);
underTest.AddItem(item);
processor.VerifyAll();
}
示例3: TestTouchProjectItem_CallsNotifiyItemChanged
public void TestTouchProjectItem_CallsNotifiyItemChanged()
{
var underTest = new Project();
var itemKind = "test";
var item = new ProjectItem("p1", itemKind);
underTest.AddItem(item);
var processor = new Mock<IProjectObserver>();
processor.Setup(s => s.NotifyItemChanged(underTest, item));
underTest.AddObserver(processor.Object);
underTest.Touch(item);
processor.VerifyAll();
}
示例4: Test_BuilderAddedLinks_CalledOnChange
//[Fact]
public void Test_BuilderAddedLinks_CalledOnChange()
{
var kind = "test";
var project = new Project();
var observerMock = new Mock<IProjectObserver>();
project.AddObserver(observerMock.Object);
var p1 = AddAndCreateItem(kind, project, "p1");
var p2 = AddAndCreateItem("related", project, "p2");
var id1 = new ProjectItemIdentifier("created", "created");
var task = new Mock<IBuildTask>();
task.SetupGet(p => p.DependsOn).Returns(BuildQuery.SingleFromKind(kind).Or(BuildQuery.Exact(p2.Identifier)));
var s1 = new BuildTaskResult(id1, NullProjectItemContent.Instance);
SetupProceed(task, p1).Returns(new[] { s1 });
var builder = new Builder(project);
builder.AddTask(task.Object);
project.Touch(p2);
observerMock.Verify(s => s.NotifyItemChanged(project, It.Is<ProjectItem>(i => i.Identifier.Kind == kind)), Times.Once());
}
示例5: TestChangePropagation
public void TestChangePropagation()
{
var kind = "test";
var projectItem = new ProjectItem("p1", kind);
var project = new Project();
var observerMock = new Mock<IProjectObserver>();
project.AddObserver(observerMock.Object);
var underTest = new Builder(project);
var kind2 = "created";
var kind3 = "created2";
var buildTarget = CreateBuildTarget(kind, kind2);
var buildTarget2 = CreateBuildTarget(kind2, kind3);
underTest.AddTask(buildTarget);
underTest.AddTask(buildTarget2);
project.AddItem(projectItem);
project.Touch(projectItem);
observerMock.Verify(s => s.NotifyItemChanged(project, It.Is<ProjectItem>(i => i.Identifier.Kind == kind)), Times.Once());
observerMock.Verify(s => s.NotifyItemChanged(project, It.Is<ProjectItem>(i => i.Identifier.Kind == kind2)), Times.Once());
observerMock.Verify(s => s.NotifyItemChanged(project, It.Is<ProjectItem>(i => i.Identifier.Kind == kind3)), Times.Once());
}