public void PrepareSpreadsheet()
        {
            //Create item
            var dataItem = new TestData { Text = "str", FractionalNumber = 1.0 };

            //Create spreadsheet, populate Items collection and build columns
            _spreadsheet = Mock.Create<SpreadsheetView>(Behavior.CallOriginal);
            _spreadsheet.ItemsSource = new List<TestData> { dataItem };
            _spreadsheet.OnApplyTemplate();

            //Need one of the columns built
            var column = _spreadsheet.Columns.FirstOrDefault(x => x.PropertyName == "Text");
            if (column == null)
                Assert.Fail();

            //Create container but suppress cells creation
            var container = new SpreadsheetItemContainer(_spreadsheet);
            Mock.NonPublic.Arrange(container, "InitializeCellsWithValues").DoNothing();
            container.Item = ItemWrap.BuildNew(dataItem);

            //Avoid calling original SetValueBinding and SetEditorParams methods from cell's constructor
            Mock.NonPublic.Arrange(typeof(Cell), "SetValueBinding", container.Item);
            Mock.NonPublic.Arrange(typeof(Cell), "SetEditorParams");
            _cell = column.CreateCell(container) as Cell;

            //Mock behavior
            _cellInteractionBehaviorMock = Mock.Create<CellInteractionBehavior>(Behavior.CallOriginal);

            //Attach behavior to the new control and check that OnAttached method was called
            _contentControl = Mock.Create<CellControl>(Behavior.CallOriginal);
            _contentControl.Content = _cell;
            _contentControl.DataContext = _cell;
            _cellInteractionBehaviorMock.Attach(_contentControl);
            Mock.NonPublic.Assert(_cellInteractionBehaviorMock, "OnAttached", Occurs.Once());
        }
        public void CheckPropertiesInitialValuesTest()
        {
            //Mock spreadsheet
            var spreadsheetMock = Mock.Create<SpreadsheetView>(Constructor.Mocked, Behavior.Loose);
            Mock.Arrange(() => spreadsheetMock.GetTopLevelSpreadsheet()).CallOriginal();

            //Call constructor
            var container = new SpreadsheetItemContainer(spreadsheetMock);
            var privateAccessor = new PrivateAccessor(container);

            //Assert fields
            Assert.IsNotNull(privateAccessor.GetField("_topLevelSpreadsheet"));
            Assert.AreEqual(privateAccessor.GetField("_topLevelSpreadsheet"), spreadsheetMock);
            Assert.IsNotNull(privateAccessor.GetField("_owner"));
            Assert.AreEqual(privateAccessor.GetField("_owner"), spreadsheetMock);
            Assert.IsNull(privateAccessor.GetField("_item"));
            Assert.IsFalse((bool)privateAccessor.GetField("_disposed"));

            //Assert properties
            Assert.IsFalse(container.IsOdd);
            Assert.IsFalse(container.IsDisposed);
            Assert.AreEqual(container.Owner, spreadsheetMock);
            Assert.AreEqual(container.TopLevelSpreadsheet, spreadsheetMock);
            Assert.IsNull(container.Item);
            Assert.IsNotNull(container.Cells);
            Assert.IsFalse(container.Cells.Any());
            Assert.IsFalse(container.IsAlternate);
            Assert.IsFalse(container.IsSelected);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DetailCell"/> class.
        /// </summary>
        /// <param name="column">The column.</param>
        /// <param name="spreadsheetItemContainer">The spreadsheet item container.</param>
        public DetailCell(IColumn column, SpreadsheetItemContainer spreadsheetItemContainer)
            : base(column, spreadsheetItemContainer)
        {
            ValuePresenter = new CellValuePresenter(this);
            ItemSelected = InitializeItemSelected();
            if (ChildSpreadsheet != null)
            {
                ChildSpreadsheet.SwitchVisibility();
                RaiseShowDetailsChanged();
            }

            ((SpreadsheetDetailColumn) column).ColumnExpanded += OnColumnExpanded;
        }
        public void InvokeConstructorTest()
        {
            //Mock spreadsheet
            var spreadsheetMock = Mock.Create<SpreadsheetView>(Constructor.Mocked, Behavior.Loose);
            Mock.Arrange(() => spreadsheetMock.GetTopLevelSpreadsheet()).CallOriginal();

            //Call constructor
            var container = new SpreadsheetItemContainer(spreadsheetMock);
            var privateAccessor = new PrivateAccessor(container);

            //Assert fields and properties
            Assert.AreEqual(privateAccessor.GetField("_owner"), spreadsheetMock);
            Assert.AreEqual(container.TopLevelSpreadsheet, spreadsheetMock);
            Assert.IsNotNull(container.Cells);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CellBase"/> class.
        /// </summary>
        /// <param name="column">The column.</param>
        /// <param name="spreadsheetItemContainer">The spreadsheet item container.</param>
        public CellBase(IColumn column, SpreadsheetItemContainer spreadsheetItemContainer) : base()
        {
            if (spreadsheetItemContainer != null)
            {
                _column = column;
                if (_column != null)
                    _column.WidthChanged += OnColumnWidthChanged;
                _owner = spreadsheetItemContainer.Owner;
                _container = spreadsheetItemContainer;
                _topLevelSpreadsheet = _owner.GetTopLevelSpreadsheet();
                HasNested = false;

                SetValueBinding(spreadsheetItemContainer.Item);
                SetEditorParams();

                BindingOperations.SetBinding(this, ContentWrappingProperty, new Binding("Column.Wrapping"));
                BindingOperations.SetBinding(this, HorizontalAlignmentProperty, new Binding("Column.HorizontalAlignment"));
                BindingOperations.SetBinding(this, VerticalAlignmentProperty, new Binding("Column.VerticalAlignment"));
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Removes the container from dictionary if exists.
 /// </summary>
 /// <param name="container">The container.</param>
 internal void RemoveContainerFromDictionaryIfExists(SpreadsheetItemContainer container)
 {
     if (_containersDict != null)
     {
         var kv = _containersDict.FirstOrDefault(x => x.Value == container);
         if (!default(KeyValuePair<IWrap, SpreadsheetItemContainer>).Equals(kv))
             _containersDict.Remove(kv.Key);
     }
 }
        public void RaiseSelectionChangedMethodTest()
        {
            //Mock spreadsheet
            var spreadsheetMock = Mock.Create<SpreadsheetView>(Constructor.Mocked, Behavior.Loose);
            Mock.Arrange(() => spreadsheetMock.RowIndicatorVisibility).Returns(Visibility.Collapsed);
            Mock.Arrange(() => spreadsheetMock.GetTopLevelSpreadsheet()).CallOriginal();

            //Call constructor
            var container = new SpreadsheetItemContainer(spreadsheetMock);

            //PrepareCells
            var cell1 = Mock.Create<Cell>(Constructor.Mocked);
            Mock.Arrange(() => cell1.IsSelected).Returns(false);
            var cell2 = Mock.Create<Cell>(Constructor.Mocked);
            Mock.Arrange(() => cell2.IsSelected).Returns(true);

            container.Cells.Add(cell1);
            container.Cells.Add(cell2);

            //Assert IsSelected
            container.RaiseSelectionChanged();
            Assert.IsTrue(container.IsSelected);

            //If row indicator column is visible
            Mock.Arrange(() => spreadsheetMock.RowIndicatorVisibility).Returns(Visibility.Visible);
            container.RaiseSelectionChanged();
            Mock.Assert(() => cell1.RaisePropertyChanged("IsRowSelected"), Occurs.Once());
            Mock.Assert(() => cell1.RaisePropertyChanged("Foreground"), Occurs.Once());
            Mock.Assert(() => cell2.RaisePropertyChanged("IsRowSelected"), Occurs.Never());
            Mock.Assert(() => cell2.RaisePropertyChanged("Foreground"), Occurs.Never());

            //Owner.ParentCell is not null
            var parentCell = Mock.Create<StackCell>(Constructor.Mocked);
            var parentCellContainer = Mock.Create<SpreadsheetItemContainer>(Constructor.Mocked);
            Mock.Arrange(() => parentCellContainer.RaiseSelectionChanged()).MustBeCalled();
            Mock.Arrange(() => parentCell.Container).Returns(parentCellContainer);
            Mock.Arrange(() => spreadsheetMock.ParentCell).Returns(parentCell);
            container.RaiseSelectionChanged();
            Mock.Assert(parentCellContainer);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CellBase" /> class.
 /// </summary>
 /// <param name="column">The column.</param>
 /// <param name="spreadsheetItemContainer">The spreadsheet item container.</param>
 public StackCell(IColumn column, SpreadsheetItemContainer spreadsheetItemContainer)
     : base(column, spreadsheetItemContainer)
 {
     HasNested = true;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates the cell.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <returns>CellBase.</returns>
 public override CellBase CreateCell(SpreadsheetItemContainer container)
 {
     return new StackCell(this, container);
 }
        public void SetIsAlternateMethodTest()
        {
            //Mock spreadsheet
            var spreadsheetMock = Mock.Create<SpreadsheetView>(Constructor.Mocked, Behavior.Loose);
            Mock.Arrange(() => spreadsheetMock.GetTopLevelSpreadsheet()).CallOriginal();

            //Call constructor
            var container = new SpreadsheetItemContainer(spreadsheetMock);

            //TopLevelSpreadsheet.AlternateStyle is None
            container.SetIsAlternate();
            Assert.IsFalse(container.IsAlternate);
            Mock.NonPublic.Assert(container, "GetTopLevelCell", Occurs.Never());

            //Owner is a top level spreadsheet
            Mock.Arrange(() => spreadsheetMock.AlternateStyle).Returns(AlternateStyles.Full);
            Mock.Arrange(() => container.IsOdd).Returns(true);
            container.SetIsAlternate();            
            Assert.IsTrue(container.IsAlternate);
            Assert.AreEqual(container.IsAlternate, container.IsOdd);
            Mock.NonPublic.Assert(container, "GetTopLevelCell", Occurs.Never());

            //Top level AlternateStyle is Full
            Mock.Arrange(() => spreadsheetMock.ParentSpreadsheet).Returns(Mock.Create<SpreadsheetView>(Constructor.Mocked));
            Mock.Arrange(() => container.IsOdd).Returns(false);
            container.SetIsAlternate();
            Assert.IsFalse(container.IsAlternate);
            Assert.AreEqual(container.IsAlternate, container.IsOdd);
            Mock.NonPublic.Assert(container, "GetTopLevelCell", Occurs.Never());

            //Otherwise
            Mock.Arrange(() => spreadsheetMock.AlternateStyle).Returns(AlternateStyles.TopLevel);
            var topLevelCell = Mock.Create<Cell>(Constructor.Mocked);
            var topLevelCellContainer = Mock.Create<SpreadsheetItemContainer>(Constructor.Mocked);
            Mock.Arrange(() => topLevelCell.Container).Returns(topLevelCellContainer);
            Mock.Arrange(() => topLevelCellContainer.IsOdd).Returns(true);
            Mock.NonPublic.Arrange<CellBase>(container, "GetTopLevelCell").Returns(topLevelCell);
            container.SetIsAlternate();
            Assert.IsTrue(container.IsAlternate);
            Assert.AreEqual(container.IsAlternate, topLevelCellContainer.IsOdd);
            Mock.NonPublic.Assert(container, "GetTopLevelCell", Occurs.Once());
        }
Ejemplo n.º 11
0
        public void OnItemsChangedItemResetTest()
        {
            var spreadsheet = new SpreadsheetView();
            var privateAccessor = new PrivateAccessor(spreadsheet);

            var container = new SpreadsheetItemContainer(spreadsheet);

            //Arrange ContainerFromItem and initialize spreadsheet ItemsSource collection
            Mock.Arrange(() => spreadsheet.ItemContainerGenerator.ContainerFromItem(Arg.IsAny<IWrap>())).Returns(container);
            spreadsheet.ItemsSource = new List<TestData> {new TestData{Text = "data1"}};
            spreadsheet.OnApplyTemplate();
            var containersDict = privateAccessor.GetField("_containersDict") as Dictionary<IWrap, SpreadsheetItemContainer>;
            Assert.AreEqual(containersDict.Count, 1);
            Assert.AreEqual(((TestData)containersDict.First().Key.Data).Text, "data1");

            //Re-initialize collection to call OnItemsChanged with Reset action and assert results
            Mock.NonPublic.Arrange(spreadsheet, "DisposeContainers").CallOriginal().MustBeCalled();
            spreadsheet.ItemsSource = new List<TestData> { new TestData { Text = "data2" } };
            Assert.AreEqual(containersDict.Count, 1);
            Assert.AreEqual(((TestData)containersDict.First().Key.Data).Text, "data2");            
            Mock.Assert(spreadsheet);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Disposes this instance.
        /// </summary>
        internal override void Dispose()
        {
            base.Dispose();

            if (_column != null)
                _column.WidthChanged -= OnColumnWidthChanged;

            _column = null;
            _owner = null;

            if (_container != null && _container.Cells != null)
                _container.Cells.Remove(this);

            _container = null;
        }
Ejemplo n.º 13
0
        public void OnItemsChangedItemRemoveTest()
        {
            var spreadsheet = new SpreadsheetView();
            var privateAccessor = new PrivateAccessor(spreadsheet);

            //Initialize ItemCollection
            Mock.NonPublic.Arrange(spreadsheet, "OnItemsChanged", ArgExpr.IsAny<NotifyCollectionChangedEventArgs>()).DoNothing();
            var list = new List<TestData>
            {
                new TestData {Text = "fff", FractionalNumber = 0},
                new TestData {Text = "item", FractionalNumber = 55},
                new TestData {Text = "last item", FractionalNumber = -5}
            };
            spreadsheet.ItemsSource = list;
            spreadsheet.OnApplyTemplate();
            Assert.IsNotNull(spreadsheet.ItemsCollection);
            Mock.Reset();

            var item1 = spreadsheet.ItemsCollection[0];
            var item2 = spreadsheet.ItemsCollection[1];
            var item3 = spreadsheet.ItemsCollection[2];

            //Bind item1 to container
            var container = new SpreadsheetItemContainer(spreadsheet);
            Mock.NonPublic.Arrange(container, "InitializeCellsWithValues");
            privateAccessor.CallMethod("BindContainerToItem", container, item1);
            privateAccessor.CallMethod("BindContainerToItem", container, item3);

            //Assert dictionary with containers
            var containerDict = privateAccessor.GetField("_containersDict") as Dictionary<IWrap, SpreadsheetItemContainer>;
            Assert.IsNotNull(containerDict);
            Assert.AreEqual(containerDict.Count, 2);
            containerDict.Add(item2, null);
            Assert.AreEqual(containerDict.Count, 3);

            //Remove second item from collection (when container is null)
            Mock.Arrange(() => containerDict.Remove(item2)).CallOriginal();
            spreadsheet.ItemsCollection.Remove(item2);
            Mock.Assert(() => containerDict.Remove(item2), Occurs.Once());
            Assert.AreEqual(containerDict.Count, 2);

            //Remove first item from collection (when container is disposed)
            Mock.Arrange(() => container.IsDisposed).Returns(true);
            spreadsheet.ItemsCollection.Remove(item1);            
            Mock.Assert(() => containerDict.Remove(item1), Occurs.Once());
            Assert.AreEqual(containerDict.Count, 1);

            //Remove item and dispose container            
            Mock.Arrange(() => container.IsDisposed).Returns(false);            
            spreadsheet.ItemsCollection.Remove(item3);
            Mock.Assert(() => containerDict.Remove(item3), Occurs.Exactly(2));
            Assert.AreEqual(containerDict.Count, 0);
            Mock.Reset();
            Assert.IsTrue(container.IsDisposed);
        }
        public void OnAlternateStausChangedTest()
        {
            var container = new SpreadsheetItemContainer(null);
            var privateAccessor = new PrivateAccessor(container);

            //Prepare cells
            var childSpreadsheet = Mock.Create<SpreadsheetView>(Constructor.Mocked);
            var cell1 = Mock.Create<Cell>(Constructor.Mocked);            
            var cell2 = Mock.Create<StackCell>(Constructor.Mocked);
            Mock.Arrange(() => cell2.ChildSpreadsheet).Returns(childSpreadsheet);
            Mock.Arrange(() => cell2.HasNested).Returns(true);
            container.Cells.Add(cell1);
            container.Cells.Add(cell2);

            //Container is disposed
            Mock.Arrange(() => container.Cells).CallOriginal().OccursNever();
            privateAccessor.SetField("_disposed", true);
            container.IsAlternate = true;
            Mock.NonPublic.Assert(typeof(SpreadsheetItemContainer), "OnAlternateStausChanged", 
                Occurs.Once(), ArgExpr.IsAny<DependencyObject>(), ArgExpr.IsAny<DependencyPropertyChangedEventArgs>());
            Mock.Assert(() => childSpreadsheet.AlternateRows(), Occurs.Never());
            Mock.Assert(container);

            //Container is not disposed
            Mock.Arrange(() => container.Cells).CallOriginal().OccursOnce();
            privateAccessor.SetField("_disposed", false);
            container.IsAlternate = false;
            Mock.NonPublic.Assert(typeof(SpreadsheetItemContainer), "OnAlternateStausChanged",
                Occurs.Exactly(2), ArgExpr.IsAny<DependencyObject>(), ArgExpr.IsAny<DependencyPropertyChangedEventArgs>());
            Mock.Assert(() => childSpreadsheet.AlternateRows(), Occurs.Once());
            Mock.Assert(container);
            Assert.IsTrue(cell2.HasNested);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Selects the next row cell.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <param name="spreadsheetItemContainer">The spreadsheet item container.</param>
        /// <returns>NavigationInfo.</returns>
        public NavigationInfo SelectNextRowCell(NavigationInfo navInfoParam, SpreadsheetItemContainer spreadsheetItemContainer)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            if (spreadsheetItemContainer == null)
            {
                navigationInfo.ActionState = MoveStates.Fail;
                return navigationInfo;
            }

            var index = spreadsheetItemContainer.Item != null ? spreadsheetItemContainer.Item.Index : -1;
            if (index < 0)
            {
                navigationInfo.ActionState = MoveStates.Fail;
                return navigationInfo;
            }

            if (index >= Items.Count - 1) // last row
            {
                if (ParentSpreadsheet == null) // top-level last row
                    navigationInfo.ActionState = MoveStates.Bottommost;
                else
                    navigationInfo.ActionState = MoveStates.Lowermost;

                navigationInfo = spreadsheetItemContainer.JumpToNextCell(navigationInfo);
            }
            else
            {
                var container = GetContainerFromItem(Items[index + 1] as IWrap);
                if (container != null)
                {
                    navigationInfo = container.JumpToNextCell(navigationInfo);
                }
                else
                    navigationInfo.ActionState = MoveStates.Fail;
            }

            return navigationInfo;
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Creates the cell.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <returns>CellBase.</returns>
 public virtual CellBase CreateCell(SpreadsheetItemContainer container)
 {
     return new CellBase(this, container);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Creates the cell.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <returns>CellBase.</returns>
 public override CellBase CreateCell(SpreadsheetItemContainer container)
 {
     return new Cell(this, container){EditTemplate = EditTemplate};
 }
Ejemplo n.º 18
0
        public void OnItemsChangedItemAddTest()
        {
            var spreadsheet = new SpreadsheetView();
            var privateAccessor = new PrivateAccessor(spreadsheet);

            //Initialize ItemCollection
            Mock.NonPublic.Arrange(spreadsheet, "OnItemsChanged", ArgExpr.IsAny<NotifyCollectionChangedEventArgs>()).DoNothing();
            spreadsheet.ItemsSource = new List<TestData>();
            spreadsheet.OnApplyTemplate();
            Assert.IsNotNull(spreadsheet.ItemsCollection);
            Mock.Reset();

            //Create data item and its wrapper
            var dataItem = new TestData {Text = "test", FractionalNumber = 3.5};
            var itemWrap = ItemWrap.BuildNew(dataItem);

            //Arrabge ManageExpandStates and BindContainerToItem
            Mock.Arrange(() => spreadsheet.ManageExpandStates(Arg.IsAny<IDetailColumn>()));
            Mock.NonPublic.Arrange(spreadsheet, "BindContainerToItem", ArgExpr.IsAny<SpreadsheetItemContainer>(), ArgExpr.IsAny<IWrap>());

            //Make spreadsheet disposed
            privateAccessor.SetField("_disposed", true);
            spreadsheet.ItemsCollection.Add(itemWrap);

            //Check ManageExpandStates and BindContainerToItem invocations when spreadsheet is disposed
            Assert.IsTrue((bool)privateAccessor.GetField("_disposed"));
            Mock.NonPublic.Assert(spreadsheet, "BindContainerToItem", Occurs.Never(), ArgExpr.IsAny<SpreadsheetItemContainer>(), ArgExpr.IsAny<IWrap>());
            Mock.Assert(() => spreadsheet.ManageExpandStates(Arg.IsAny<IDetailColumn>()), Occurs.Never());

            //Mock ItemContainerGenerator.ContainerFromItem method and add new item to ItemsCollection
            //this invokes OnItemsChanged
            privateAccessor.SetField("_disposed", false);
            var container = new SpreadsheetItemContainer(spreadsheet);
            Mock.Arrange(() => spreadsheet.ItemContainerGenerator.ContainerFromItem(Arg.IsAny<object>())).Returns(container);
            Mock.Arrange(() => spreadsheet.ParentColumn).Returns(Mock.Create<IDetailColumn>());
            spreadsheet.ItemsCollection.Add(itemWrap);

            //Check ManageExpandStates and BindContainerToItem invocations when spreadsheet is not disposed
            Assert.IsFalse((bool)privateAccessor.GetField("_disposed"));
            Mock.NonPublic.Assert(spreadsheet, "BindContainerToItem", Occurs.Once(), container, itemWrap);
            Mock.Assert(() => spreadsheet.ManageExpandStates(Arg.IsAny<IDetailColumn>()), Occurs.Once());
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Populates the cells.
 /// </summary>
 /// <param name="ic">The ic.</param>
 /// <param name="item">The item.</param>
 private static void PopulateCells(SpreadsheetItemContainer ic, IWrap item)
 {
     ic.Item = item;
     ic.IsOdd = ic.Item.Index % 2 != 0;
     ic.SetIsAlternate();
 }
Ejemplo n.º 20
0
        public void OnItemsChangedItemReplaceTest()
        {
            var spreadsheet = new SpreadsheetView();
            var privateAccessor = new PrivateAccessor(spreadsheet);            

            //Create data
            var oldItem = ItemWrap.BuildNew(new TestData());
            var newItem = ItemWrap.BuildNew(new TestData());
            var oldContainer = new SpreadsheetItemContainer(spreadsheet);
            var newContainer = new SpreadsheetItemContainer(spreadsheet);

            //Prepare event arguments and container dictionary
            var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, newItem, oldItem, 0);
            var containerDict = privateAccessor.GetField("_containersDict") as Dictionary<IWrap, SpreadsheetItemContainer>;
            containerDict.Add(oldItem, oldContainer);

            //Arrange methods
            Mock.Arrange(() => spreadsheet.ItemContainerGenerator.ContainerFromItem(newItem)).Returns(newContainer);
            Mock.NonPublic.Arrange(spreadsheet, "BindContainerToItem", newContainer, newItem).CallOriginal();

            //Call OnItemsChanged and Assert results
            privateAccessor.CallMethod("OnItemsChanged", args);
            Assert.AreEqual(containerDict.Count, 1);
            Assert.AreEqual(containerDict.First().Key, newItem);
            Assert.AreEqual(containerDict[newItem], newContainer);
            Mock.NonPublic.Assert(spreadsheet, "BindContainerToItem", Occurs.Once(), newContainer, newItem);
            Assert.IsTrue(oldContainer.IsDisposed);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Binds the container to item.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="item">The item.</param>
        private void BindContainerToItem(SpreadsheetItemContainer container, IWrap item)
        {
            SpreadsheetItemContainer ctnr;

            if (_containersDict.TryGetValue(item, out ctnr))
                _containersDict[item] = container;
            else
                _containersDict.Add(item, container);
        }
Ejemplo n.º 22
0
        public void GetContainerFromItemMethodTest()
        {
            //Mock spreadsheet
            var spreadsheet = new SpreadsheetView();
            var privateAccessor = new PrivateAccessor(spreadsheet);

            //Prepare data
            var item = ItemWrap.BuildNew(new TestData());
            var container = new SpreadsheetItemContainer(spreadsheet);
            var containerHash = container.GetHashCode();

            var containersDict = privateAccessor.GetField("_containersDict") as Dictionary<IWrap, SpreadsheetItemContainer>;
            containersDict.Add(item, container);

            //Call GetContainerFromItem and assert results
            var result = spreadsheet.GetContainerFromItem(item);
            Assert.AreEqual(result.GetHashCode(), containerHash);
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Cell"/> class.
 /// </summary>
 /// <param name="column">The column.</param>
 /// <param name="spreadsheetItemContainer">The spreadsheet item container.</param>
 public Cell(IColumn column, SpreadsheetItemContainer spreadsheetItemContainer)
     : base(column, spreadsheetItemContainer)
 {
 }