Ejemplo n.º 1
0
        public void Name()
        {
            var expected = Guid.NewGuid().ToString();
            var c = new TableData
            {
                TableName = expected,
            };

            Assert.AreEqual(expected, c.TableName);
        }
Ejemplo n.º 2
0
        public void Rows()
        {
            var expected = new List<IDictionary<string, object>>();
            var c = new TableData
            {
                Rows = expected,
            };

            Assert.AreEqual(expected, c.Rows);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Retrieve Data
        /// </summary>
        /// <param name="tables">Tables</param>
        /// <returns>Table Data</returns>
        public async Task<IEnumerable<TableData>> Retrieve(IEnumerable<ITableStorage> tables)
        {
            var datas = new List<TableData>();
            foreach (var table in tables)
            {
                Trace.TraceInformation("Reading from table: {0}.", table.Name);

                var data = new TableData
                {
                    TableName = table.Name,
                    Rows = await table.Query(new TableQuery()),
                };

                datas.Add(data);

                Trace.TraceInformation("Rows Read: {0}", data.Rows.Count());
            }

            return datas;
        }
Ejemplo n.º 4
0
        public async Task StoreTableNotCreated()
        {
            var tableName = Guid.NewGuid().ToString();
            var tableStatement = string.Format(SqlStatements.CreateTable, SqlStatements.Schema, tableName);
            var row = new Dictionary<string, object>();
            row.Add(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            row.Add(TableStorage.PartitionKey, Guid.NewGuid().ToString());
            row.Add(TableStorage.RowKey, Guid.NewGuid().ToString());
            row.Add(TableStorage.ETag, Guid.NewGuid().ToString());
            var rows = new List<IDictionary<string, object>>();
            rows.Add(row);
            var data = new TableData()
            {
                TableName = Guid.NewGuid().ToString(),
                Rows = rows,
            };
            var dataSets = new List<TableData>();
            dataSets.Add(data);
            var reader = Substitute.For<ISchemaReader>();
            reader.Load(SchemaTypes.Table).Returns(Task.FromResult<IEnumerable<IDefinition>>(new List<IDefinition>()));
            var executor = Substitute.For<IExecutor>();
            executor.NonQuery(tableStatement).Returns(Task.FromResult(0));
            executor.NonQuery(Arg.Any<SaveData>());

            var writer = new SqlDataWriter(reader, executor, tableName);
            await writer.Store(dataSets);

            reader.Received().Load(SchemaTypes.Table);
            executor.Received().NonQuery(tableStatement);
            executor.Received(0).NonQuery(Arg.Any<SaveData>());
        }