当前位置: 首页>>代码示例>>C#>>正文


C# Project.AddItem方法代码示例

本文整理汇总了C#中Project.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# Project.AddItem方法的具体用法?C# Project.AddItem怎么用?C# Project.AddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Project的用法示例。


在下文中一共展示了Project.AddItem方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestAddExistingItem_Fails

        public void TestAddExistingItem_Fails()
        {
            var underTest = new Project();
            var projectItem = new ProjectItem("p1");
            underTest.AddItem(projectItem);

            Assert.Throws<ArgumentException>(() => underTest.AddItem(projectItem));
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:8,代码来源:ProjectTest.cs

示例2: TestAddTarget_InvokesOnExistingItemsWhenOnChange

        public void TestAddTarget_InvokesOnExistingItemsWhenOnChange()
        {
            var kind = "test";
            var projectItem = new ProjectItem("p2", kind);

            var project = new Project();
            project.AddItem(new ProjectItem("p1"));
            project.AddItem(projectItem);

            var target = new Mock<IBuildTask>();
            target.SetupGet(t => t.DependsOn).Returns(BuildQuery.AllFromKind(kind));
            SetupProceed(target, projectItem).Returns(new [] { new BuildTaskResult(new ProjectItemIdentifier("t1", "test2"), NullProjectItemContent.Instance)});

            var underTest = new Builder(project);
            underTest.AddTask(target.Object);

            target.VerifyAll();
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:18,代码来源:BuilderTest.cs

示例3: TestBuilderSingleItemOnAddWithBuildInBackgroundOption

        public async Task TestBuilderSingleItemOnAddWithBuildInBackgroundOption()
        {
            var kind = "test";
            var projectItem = new ProjectItem("p1", kind);

            var project = new Project();

            var target = new Mock<IBuildTask>();
            const string targetName = "test";
            target.SetupGet(t => t.Name).Returns(targetName);
            target.SetupGet(t => t.DependsOn).Returns(BuildQuery.SingleFromKind(kind));
            target.SetupGet(t => t.Options).Returns(BuildOptions.BuildInBackground);

            var id = new ProjectItemIdentifier("gugus", "created");
            const string contentString = "test";
            var source = new BuildTaskResult(id, new ProjectItemContentFromAction(() => GenerateStreamFromString(contentString)));
            SetupProceed(target, projectItem).Returns(new [] { source });

            var underTest = new Builder(project);
            underTest.AddTask(target.Object);

            project.AddItem(new ProjectItem("p2"));
            project.AddItem(projectItem);

            var generatedItem = project.GetItemById(id);
            Assert.NotNull(generatedItem);
            Assert.Equal(id, generatedItem.Identifier);

            var stream = await generatedItem.OpenRead();
            //Second Stream
            var stream2 = await generatedItem.OpenRead();

            AssertStream(stream, contentString);
            AssertStream(stream2, contentString);

            var links = projectItem.GetLinkedItems();
            Assert.NotNull(links);

            var linkList = links.ToList();
            Assert.Equal(1, linkList.Count);

            Assert.Equal(generatedItem, linkList[0].ProjectItem);
            Assert.Equal(targetName, linkList[0].Description.Name);
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:44,代码来源:BuilderTest.cs

示例4: TestRemove_ItemNotInList

        public void TestRemove_ItemNotInList()
        {
            var underTest = new Project();
            var projectItem = new ProjectItem("p1");
            underTest.AddItem(projectItem);

            underTest.RemoveItem(projectItem);

            var result = underTest.GetItems();
            Assert.NotNull(result);
            Assert.Equal(0, result.Count());
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:12,代码来源:ProjectTest.cs

示例5: TestAddItem_ReturnsItemInList

        public void TestAddItem_ReturnsItemInList()
        {
            var underTest = new Project();
            var projectItem = new ProjectItem("p1");
            underTest.AddItem(projectItem);

            var items = underTest.GetItems();
            Assert.NotNull(items);

            var list = items.ToList();
            Assert.Equal(1, list.Count);
            Assert.Equal(projectItem, list[0]);
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:13,代码来源:ProjectTest.cs

示例6: 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();
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:15,代码来源:ProjectTest.cs

示例7: 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();
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:16,代码来源:ProjectTest.cs

示例8: TestRemoveLink

        public void TestRemoveLink()
        {
            var underTest = new Project();
            var itemKind = "test";

            var item1 = new ProjectItem("p1", itemKind);
            var item2 = new ProjectItem("p2", itemKind);

            underTest.AddItem(item1);
            underTest.AddItem(item2);

            var link = new ProjectItemLinkDescription("desc");
            underTest.AddLink(item1, link, item2);

            underTest.RemoveLink(item1, link, item2);

            AssertEmptyLinkList(item1);
            AssertEmptyLinkList(item2);
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:19,代码来源:ProjectTest.cs

示例9: TestAddLink

        public void TestAddLink()
        {
            var underTest = new Project();
            var itemKind = "test";

            var item1 = new ProjectItem("p1", itemKind);
            var item2 = new ProjectItem("p2", itemKind);

            underTest.AddItem(item1);
            underTest.AddItem(item2);

            var link = new ProjectItemLinkDescription("desc");
            underTest.AddLink(item1, link, item2);

            AssertLinkedItem(item1, item2, link);
            AssertLinkedItem(item2, item1, link);
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:17,代码来源:ProjectTest.cs

示例10: TestAddProjectItemWithSameIdentifier_ThrowsException

        public void TestAddProjectItemWithSameIdentifier_ThrowsException()
        {
            var underTest = new Project();
            var itemKind = "test";

            var item1 = new ProjectItem("p1", itemKind);
            var item2 = new ProjectItem("p1", itemKind);

            underTest.AddItem(item1);

            Assert.Throws<ArgumentException>(() => underTest.AddItem(item2));
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:12,代码来源:ProjectTest.cs

示例11: AddAndCreateItem

        private static ProjectItem AddAndCreateItem(string kind, Project project, string name)
        {
            var projectItem = new ProjectItem(name, kind);
            project.AddItem(projectItem);

            return projectItem;
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:7,代码来源:BuilderTest.cs

示例12: 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());
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:28,代码来源:BuilderTest.cs

示例13: TestBuilderSingleItemOnAddWithBuildOnRequestOption

        public void TestBuilderSingleItemOnAddWithBuildOnRequestOption()
        {
            var kind = "test";
            var projectItem = new ProjectItem("p1", kind);

            var project = new Project();

            var id = new ProjectItemIdentifier("gugus", "created");

            var content = new Mock<IProjectItemContent>();
            content.Setup(s => s.ReadAsync()).Returns(GenerateStreamFromString("test"));

            var target = new Mock<IBuildTask>();
            const string targetName = "test";
            target.SetupGet(t => t.Name).Returns(targetName);
            target.SetupGet(t => t.DependsOn).Returns(BuildQuery.SingleFromKind(kind));
            target.SetupGet(t => t.Options).Returns(BuildOptions.BuildOnRequest);
            SetupProceed(target, projectItem).Returns(new [] { new BuildTaskResult(id, content.Object)});

            var underTest = new Builder(project);
            underTest.AddTask(target.Object);

            project.AddItem(new ProjectItem("p2"));
            project.AddItem(projectItem);

            content.Verify(t => t.ReadAsync(), Times.Never());

            var generatedItem = project.GetItemById(id);
            Assert.NotNull(generatedItem);
            Assert.Equal(id, generatedItem.Identifier);

            generatedItem.OpenRead();
            content.Verify(t => t.ReadAsync(), Times.Once());

            generatedItem.OpenRead();
            content.Verify(t => t.ReadAsync(), Times.Once());
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:37,代码来源:BuilderTest.cs


注:本文中的Project.AddItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。