Пример #1
0
        public virtual void Initialize()
        {
            context = Mock.Of <ITypeDescriptorContext>();

            solution = new Solution();
            project  = new Project {
                Name = "project", PhysicalPath = @"c:\projects\solution\project\project.csproj"
            };
            folder = new Folder();
            item   = new Item {
                Data = { CustomTool = "", IncludeInVSIX = "false", CopyToOutputDirectory = CopyToOutput.DoNotCopy, ItemType = "None" }, PhysicalPath = @"c:\projects\solution\project\assets\icon.ico"
            };
            folder.Items.Add(item);
            project.Items.Add(folder);
            project.Data.AssemblyName = "project";
            solution.Items.Add(project);

            serviceProvider = new Mock <IServiceProvider>();
            componentModel  = new Mock <IComponentModel>();
            picker          = new Mock <ISolutionPicker>();
            var uriProvider = new PackUriProvider();

            var pack = new ResourcePack(item);

            var uriService = new Mock <IUriReferenceService>();

            uriService.Setup(u => u.CreateUri <ResourcePack>(It.IsAny <ResourcePack>(), "pack")).Returns(uriProvider.CreateUri(pack));

            serviceProvider.Setup(s => s.GetService(typeof(SComponentModel))).Returns(componentModel.Object);
            serviceProvider.Setup(s => s.GetService(typeof(ISolution))).Returns(solution);
            serviceProvider.Setup(s => s.GetService(typeof(IUriReferenceService))).Returns(uriService.Object);
            componentModel.Setup(c => c.GetService <Func <ISolutionPicker> >()).Returns(new Func <ISolutionPicker>(() => { return(picker.Object); }));

            picker.Setup(p => p.Filter).Returns(Mock.Of <IPickerFilter>());
        }
Пример #2
0
        public virtual void Initialize()
        {
            context = Mock.Of<ITypeDescriptorContext>();

            solution = new Solution();
            project = new Project { Name = "project", PhysicalPath = @"c:\projects\solution\project\project.csproj" };
            folder = new Folder();
            item = new Item { Data = { CustomTool = "", IncludeInVSIX = "false", CopyToOutputDirectory = CopyToOutput.DoNotCopy, ItemType = "None" }, PhysicalPath = @"c:\projects\solution\project\assets\icon.ico" };
            folder.Items.Add(item);
            project.Items.Add(folder);
            project.Data.AssemblyName = "project";
            solution.Items.Add(project);

            serviceProvider = new Mock<IServiceProvider>();
            componentModel = new Mock<IComponentModel>();
            picker = new Mock<ISolutionPicker>();
            var uriProvider = new PackUriProvider();

            var pack = new ResourcePack(item);

            var uriService = new Mock<IUriReferenceService>();
            uriService.Setup(u => u.CreateUri<ResourcePack>(It.IsAny<ResourcePack>(), "pack")).Returns(uriProvider.CreateUri(pack));

            serviceProvider.Setup(s => s.GetService(typeof(SComponentModel))).Returns(componentModel.Object);
            serviceProvider.Setup(s => s.GetService(typeof(ISolution))).Returns(solution);
            serviceProvider.Setup(s => s.GetService(typeof(IUriReferenceService))).Returns(uriService.Object);
            componentModel.Setup(c => c.GetService<Func<ISolutionPicker>>()).Returns(new Func<ISolutionPicker>(() => { return picker.Object; }));

            picker.Setup(p => p.Filter).Returns(Mock.Of<IPickerFilter>());
        }
        public void WhenPackIsItemWithSpacesInName_ResolveItem()
        {
            var resolver = new PackUriProvider();
            resolver.Solution = this.solution;

            Assert.Equal(this.item2, resolver.ResolveUri(new Uri("pack://application:,,,/project;component/assets/icon%20with%20spaces.ico")).GetItem());
        }
Пример #4
0
        public void WhenPackIsItemWithSpacesInName_ResolveItem()
        {
            var resolver = new PackUriProvider();

            resolver.Solution = this.solution;

            Assert.Equal(this.item2, resolver.ResolveUri(new Uri("pack://application:,,,/project;component/assets/icon%20with%20spaces.ico")).GetItem());
        }
Пример #5
0
        public void WhenPackIsNotItem_ResolveNull()
        {
            var resolver = new PackUriProvider();

            resolver.Solution = this.solution;

            Assert.Null(resolver.ResolveUri(new Uri("pack://application:,,,/referencedproject;component/foo.ico")));
        }
Пример #6
0
        public void WhenProjectItemWithSpacesInName_CreateUriForItem()
        {
            var resolver = new PackUriProvider();

            Assert.Equal("pack://application:,,,/project;component/assets/icon%20with%20spaces.ico", resolver.CreateUri(new ResourcePack(this.item2)).AbsoluteUri);
        }
        public void WhenProjectItem_CreateUriForItem()
        {
            var resolver = new PackUriProvider();

            Assert.Equal("pack://application:,,,/project;component/assets/icon.ico", resolver.CreateUri(new ResourcePack(this.item1)).AbsoluteUri);
        }
        public void WhenPackIsNotItem_ResolveNull()
        {
            var resolver = new PackUriProvider();
            resolver.Solution = this.solution;

            Assert.Null(resolver.ResolveUri(new Uri("pack://application:,,,/referencedproject;component/foo.ico")));
        }