Example #1
0
        public void should_request_items_with_correct_options()
        {
            // Arrange
            var configData = new IntegrationConfigData("server", "list", "templateID")
            {
                ItemLimit = 100500,
                Folder    = "SomeFolder",
                View      = "SomeView"
            };

            var context          = Substitute.For <SpContext>();
            var list             = Substitute.For <BaseList>(new EntityValues(), context, new Uri("http://empty"));
            var myItemCollection = new MyItemCollection(context, list, new ItemsRetrievingOptions());

            list.GetItems(Arg.Any <ItemsRetrievingOptions>()).Returns(myItemCollection);

            this.sharepointListProvider.GetList(string.Empty, string.Empty, null).ReturnsForAnyArgs(list);

            var args = new SynchronizeTreeArgs
            {
                Context = this.CreateSynchContext(configData)
            };

            // Act
            this.processor.Process(args);

            // Assert
            list.Received().GetItems(Arg.Is <ItemsRetrievingOptions>(x => x.ItemLimit == configData.ItemLimit && x.Folder == configData.Folder && x.ViewName == configData.View));
        }
Example #2
0
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            var collection = new MyItemCollection();

            collection.Add(new MyItem {
                Name = "item1", IsChecked = true
            });
            collection.Add(new MyItem {
                Name = "item2", IsChecked = false
            });

            CheckBox1.DataContext = collection;
        }
Example #3
0
        public void should_return_all_list_items()
        {
            // Arrange
            var dataContext    = Substitute.For <SpContext>();
            var list           = Substitute.For <BaseList>(new EntityValues(), dataContext, new Uri("http://empty"));
            var itemCollection = new MyItemCollection(dataContext, list, new ItemsRetrievingOptions());

            var listItems = new List <BaseItem>
            {
                new BaseItem(new EntityProperties(), list, dataContext),
                new BaseItem(new EntityProperties(), list, dataContext),
                new BaseItem(new EntityProperties(), list, dataContext)
            };

            itemCollection.Items = listItems;

            // We have to make these methods as virtual in the BaseList class:
            list.GetItems(Arg.Any <ItemsRetrievingOptions>()).Returns(itemCollection);

            var configData = new IntegrationConfigData("server", "list", "templateID");
            var args       = new SynchronizeTreeArgs
            {
                Context = this.CreateSynchContext(configData)
            };

            var context = Substitute.For <SpContext>();

            this.sharepointContextProvider.CreateDataContext(configData).Returns(context);
            this.sharepointListProvider.GetList(configData.Web, configData.List, context).Returns(list);

            // Act
            this.processor.Process(args);

            // Assert
            args.SharepointItemList.Should().BeEquivalentTo(listItems);
        }