Exemplo n.º 1
0
        public void SpreadSheetHandler_ReadRows_SheetTwo()
        {
            var rows = SpreadSheetHandler.ReadRows(_path, 1);

            var count = rows.Count();

            Assert.AreEqual(count, 20);
        }
Exemplo n.º 2
0
        public void SpreadSheetHandler_ReadRows_ReturnsProperties()
        {
            var rows       = SpreadSheetHandler.ReadRows(_path, 0);
            var enumerator = rows.GetEnumerator();

            enumerator.MoveNext();

            var property = enumerator.Current.Value;

            Assert.AreEqual(property.WaxId, 430);
            Assert.AreEqual(property.Address, "Salvation Army Halls Arkwright Walk , Fictional Town");
            Assert.AreEqual(property.Postcode, "XX2 2HN");
            Assert.AreEqual(property.StreetName, "Arkwright Walk North");
        }
        public void SpreadSheetHandler_WriteRowsToFile_AddProperties()
        {
            const string sheetName = "sheet1";

            var expected = new Property
            {
                WaxId      = 1,
                Postcode   = "BD13 2AD",
                StreetName = "Bradford Road",
                Address    = "23 Bradford Road",
                Town       = "Gomersal"
            };
            var properties = new List <Property>();

            properties.Add(expected);

            var resultPath = _workbookBuilder
                             .AddSheet(sheetName)
                             .AddPropertyHeaders(sheetName)
                             .CreateWorkbook(_dataFilePath);

            var writeToFile = SpreadSheetHandler.WriteRows(resultPath, sheetName, properties);

            Assert.True(writeToFile);

            var data       = SpreadSheetHandler.ReadRows(resultPath);
            var enumerator = data.GetEnumerator();

            enumerator.MoveNext();
            var actual = enumerator.Current.Value;

            Assert.AreEqual(actual.Postcode, expected.Postcode);
            Assert.AreEqual(actual.Address, expected.Address);
            Assert.AreEqual(actual.WaxId, expected.WaxId);
            Assert.AreEqual(actual.StreetName, expected.StreetName);
            Assert.AreEqual(actual.Town, expected.Town);
        }
Exemplo n.º 4
0
 public void SpreadSheetHandler_ReadRows_SheetDoesNotExist()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => SpreadSheetHandler.ReadRows(_path, 2));
 }