public void SourceReader_CanGetBuyersWithAReservations()
        {
            /*
             *  _       Henrik      Alice   Simpson
             *  111     1           0       1
             *  222     1           -       0
             *  333                         0
             */

            var parameters = new InputParameters();

            parameters.ElementIdSpan = "A2A4";
            parameters.BuyersSpan    = "B1D1";

            // Reusing columns to simplify test
            parameters.BrickLinkDescriptionSpan = "A2A4";
            parameters.BrickLinkIdSpan          = "A2A4";
            parameters.BrickLinkColorSpan       = "A2A4";
            parameters.TlgColorSpan             = "A2A4";

            var sheet = new Mock <IXLWorksheet>();

            ExcelMocker.AddMockRange(sheet, "A2A4");
            ExcelMocker.AddMockRange(sheet, "B1D1");

            ExcelMocker.CreateMockCell("Henrik", 1, 2, sheet);
            ExcelMocker.CreateMockCell("Alice", 1, 3, sheet);
            ExcelMocker.CreateMockCell("Simpson", 1, 4, sheet);

            ExcelMocker.CreateMockCell("111", 2, 1, sheet);
            ExcelMocker.CreateMockCell("222", 3, 1, sheet);
            ExcelMocker.CreateMockCell("333", 4, 1, sheet);

            ExcelMocker.CreateMockCell("1", 2, 2, sheet);
            ExcelMocker.CreateMockCell("1", 3, 2, sheet);
            ExcelMocker.CreateMockCell("", 4, 2, sheet);

            ExcelMocker.CreateMockCell("0", 2, 3, sheet);
            ExcelMocker.CreateMockCell("-", 3, 3, sheet);
            ExcelMocker.CreateMockCell("", 4, 3, sheet);

            ExcelMocker.CreateMockCell("1", 2, 4, sheet);
            ExcelMocker.CreateMockCell("0", 3, 4, sheet);
            ExcelMocker.CreateMockCell("0", 4, 4, sheet);

            var reader = new SourceReader(sheet.Object, parameters);

            var result = reader.GetBuyers();

            Assert.That(result.Count, Is.EqualTo(2));
            Assert.That(result.Count(x => x.Name == "Henrik"), Is.EqualTo(1));
            Assert.That(result.Count(x => x.Name == "Simpson"), Is.EqualTo(1));
            Assert.That(result.Count(x => x.Id == 100), Is.EqualTo(1));
            Assert.That(result.Count(x => x.Id == 101), Is.EqualTo(1));
        }
        public void SourceReader_BuyerIdsWillFollowAlphabetically()
        {
            /*
             *  _       Henrik      Alice   Simpson
             *  111     1           0       1
             *  222     1           1       0
             *  222     0           1       0
             */

            var parameters = new InputParameters();

            parameters.ElementIdSpan = "A2A4";
            parameters.BuyersSpan    = "B1D1";

            var sheet = new Mock <IXLWorksheet>();

            ExcelMocker.AddMockRange(sheet, "A2A4");
            ExcelMocker.AddMockRange(sheet, "B1D1");

            ExcelMocker.CreateMockCell("Henrik", 1, 2, sheet);
            ExcelMocker.CreateMockCell("Alice", 1, 3, sheet);
            ExcelMocker.CreateMockCell("Simpson", 1, 4, sheet);

            ExcelMocker.CreateMockCell("1", 2, 2, sheet);
            ExcelMocker.CreateMockCell("0", 2, 3, sheet);
            ExcelMocker.CreateMockCell("1", 2, 4, sheet);

            ExcelMocker.CreateMockCell("1", 3, 2, sheet);
            ExcelMocker.CreateMockCell("1", 3, 3, sheet);
            ExcelMocker.CreateMockCell("0", 3, 4, sheet);

            ExcelMocker.CreateMockCell("0", 4, 2, sheet);
            ExcelMocker.CreateMockCell("1", 4, 3, sheet);
            ExcelMocker.CreateMockCell("0", 4, 4, sheet);

            var reader = new SourceReader(sheet.Object, parameters);

            var result = reader.GetBuyers();

            Assert.That(result.Count, Is.EqualTo(3));
            Assert.That(result[0].Name, Is.EqualTo("Alice"));
            Assert.That(result[1].Name, Is.EqualTo("Henrik"));
            Assert.That(result[2].Name, Is.EqualTo("Simpson"));
            Assert.That(result[0].Id, Is.EqualTo(100));
            Assert.That(result[1].Id, Is.EqualTo(101));
            Assert.That(result[2].Id, Is.EqualTo(102));
        }
Ejemplo n.º 3
0
        public void SourceReader_CanGetRightNumberOfBuyersAmount()
        {
            InputParameters parameters = GetParameters();

            var sheet = SheetRetriever.Get(parameters.SourceFileName,
                                           parameters.WorksheetName);

            var reader = new SourceReader(sheet, parameters);

            var buyers = reader.GetBuyers();

            Assert.That(buyers.Count, Is.GreaterThanOrEqualTo(151));

            Assert.That(buyers.Any(x => x.Name == "Should Not Be Included In Buyers List"), Is.False);

            Assert.That(buyers[0].Name, Is.EqualTo("A"));
            Assert.That(buyers[150].Name, Is.EqualTo("Z"));

            Assert.That(buyers.Count, Is.EqualTo(151));
        }