Ejemplo n.º 1
0
        public void Load_OneRowHeader_ReturnsTheCorectNumberOfItems()
        {
            var matrix = MatrixBuilder <MatrixMockItem>
                         .Matrix()
                         .AddRowHeader("Header1", item => item.RowHeader1)
                         .NoMoreRowHeaders()
                         .NoColumnHeaders()
                         .Build();

            matrix.Load(_sampleItems);

            Assert.AreEqual(2, matrix.Count);
        }
Ejemplo n.º 2
0
        public void Load_OneRowHeader_EachMatrixRowMustContainsTheCorrectNumberOfAggregatedItems()
        {
            var matrix = MatrixBuilder <MatrixMockItem>
                         .Matrix()
                         .AddRowHeader("Header1", item => item.RowHeader1)
                         .NoMoreRowHeaders()
                         .NoColumnHeaders()
                         .Build();

            matrix.Load(_sampleItems);

            Assert.IsTrue(matrix.Any(row => row.GetAggregatedItems().Count() == 3));
            Assert.IsTrue(matrix.Any(row => row.GetAggregatedItems().Count() == 4));
        }
Ejemplo n.º 3
0
        public void Load_BeforeLoadingNewItems_ClearTheOldOnes()
        {
            var matrix = MatrixBuilder <MatrixMockItem>
                         .Matrix()
                         .AddRowHeader("Header1", item => item.RowHeader1)
                         .NoMoreRowHeaders()
                         .NoColumnHeaders()
                         .Build();

            matrix.Load(_sampleItems);
            matrix.Load(_sampleItems);

            Assert.AreEqual(2, matrix.Count);
        }
Ejemplo n.º 4
0
        public void Load_IfNoColumnHeaderProvided_MatrixItemPropertiesMustBeEqualWithTheNumberOfAddedRowHeaders()
        {
            var matrix = MatrixBuilder <MatrixMockItem>
                         .Matrix()
                         .AddRowHeader("Header1", item => item.RowHeader1)
                         .AddRowHeader("Header2", item => item.RowHeader2)
                         .NoMoreRowHeaders()
                         .NoColumnHeaders()
                         .Build();


            matrix.Load(_sampleItems);

            var matrixRow = matrix.First();

            Assert.AreEqual(2, TypeDescriptor.GetProperties(matrixRow).Count);
        }
Ejemplo n.º 5
0
        public void Load_ColumnHeaderIsProvided_EachDistinctValueShouldBeAddedAsAProperty()
        {
            var matrix = MatrixBuilder <MatrixMockItem>
                         .Matrix()
                         .AddRowHeader("Header1", item => item.RowHeader1)
                         .AddRowHeader("Header2", item => item.RowHeader2)
                         .NoMoreRowHeaders()
                         .AddColumnHeader(item => item.ColumnHeader)
                         .AggregateBy(items => items.Sum(i => i.Value))
                         .Build();

            matrix.Load(_sampleItems);

            var matrixRow = matrix.First();

            Assert.AreEqual(4, TypeDescriptor.GetProperties(matrixRow).Count);
        }
Ejemplo n.º 6
0
        public void Load_RowHeadersAddedAfterColumnHeaders_CheckCorrectHeadersPositions(int propertyIndex, string expectedPropertyName)
        {
            var matrix = MatrixBuilder <MatrixMockItem>
                         .Matrix()
                         .AddRowHeader("Header1", item => item.RowHeader1)
                         .AddRowHeader("Header2", item => item.RowHeader2, true)
                         .NoMoreRowHeaders()
                         .AddColumnHeader(item => item.ColumnHeader)
                         .AggregateBy(items => items.Sum(i => i.Value))
                         .Build();

            matrix.Load(_sampleItems);

            var matrixRow = matrix.First();

            var property = TypeDescriptor.GetProperties(matrixRow)[propertyIndex];

            Assert.AreEqual(expectedPropertyName, property.Name);
        }