Ejemplo n.º 1
0
        public async Task StoreNoPK()
        {
            var rows = new List <IDictionary <string, object> >();
            var row  = new Dictionary <string, object>();

            rows.Add(row);
            var data = new TableSqlData()
            {
                PrimaryKeyColumns = null,
                Rows      = rows,
                TableName = Guid.NewGuid().ToString(),
            };

            var tables = new List <TableSqlData>();

            tables.Add(data);

            var table = Substitute.For <ITableStorage>();

            table.InsertOrReplace(row);

            var writer = new TableStorageWriter(table);
            await writer.Store(tables);

            Assert.AreEqual(data.TableName, row[TableStorage.PartitionKey]);
            Assert.IsNotNull(row[TableStorage.RowKey]);
            Assert.AreNotEqual(Guid.Empty, Guid.Parse((string)row[TableStorage.RowKey]));

            table.Received().InsertOrReplace(row);
        }
Ejemplo n.º 2
0
        public async Task StoreNoPK()
        {
            var rows = new List<IDictionary<string, object>>();
            var row = new Dictionary<string, object>();
            rows.Add(row);
            var data = new TableSqlData()
            {
                PrimaryKeyColumns = null,
                Rows = rows,
                TableName = Guid.NewGuid().ToString(),
            };

            var tables = new List<TableSqlData>();
            tables.Add(data);

            var table = Substitute.For<ITableStorage>();
            table.InsertOrReplace(row);

            var writer = new TableStorageWriter(table);
            await writer.Store(tables);

            Assert.AreEqual(data.TableName, row[TableStorage.PartitionKey]);
            Assert.IsNotNull(row[TableStorage.RowKey]);
            Assert.AreNotEqual(Guid.Empty, Guid.Parse((string)row[TableStorage.RowKey]));

            table.Received().InsertOrReplace(row);
        }
Ejemplo n.º 3
0
        public async Task StoreMultiplePks()
        {
            var pks = new List <string>();

            pks.Add(Guid.NewGuid().ToString());
            pks.Add(Guid.NewGuid().ToString());

            var rows = new List <IDictionary <string, object> >();
            var row  = new Dictionary <string, object>();

            row.Add(pks.ElementAt(0), Guid.NewGuid());
            row.Add(pks.ElementAt(1), Guid.NewGuid());
            rows.Add(row);
            var data = new TableSqlData()
            {
                PrimaryKeyColumns = pks,
                Rows      = rows,
                TableName = Guid.NewGuid().ToString(),
            };

            var tables = new List <TableSqlData>();

            tables.Add(data);

            var table = Substitute.For <ITableStorage>();

            table.InsertOrReplace(row);

            var writer = new TableStorageWriter(table);
            await writer.Store(tables);

            Assert.AreEqual(data.TableName, row[TableStorage.PartitionKey]);
            var pk     = string.Format("{0}_{1}", row.Values.ElementAt(0), row.Values.ElementAt(1));
            var rowKey = row[TableStorage.RowKey];

            Assert.AreEqual(pk, rowKey);

            table.Received().InsertOrReplace(row);
        }
Ejemplo n.º 4
0
        public async Task Store()
        {
            var pks = new List<string>();
            var pkName = Guid.NewGuid().ToString();
            pks.Add(pkName);
            var pk = Guid.NewGuid().ToString();

            var rows = new List<IDictionary<string, object>>();
            var row = new Dictionary<string, object>();
            row.Add(pkName, pk);
            rows.Add(row);
            var data = new TableSqlData()
            {
                PrimaryKeyColumns = pks,
                Rows = rows,
                TableName = Guid.NewGuid().ToString(),
            };

            var tables = new List<TableSqlData>();
            tables.Add(data);

            var table = Substitute.For<ITableStorage>();
            table.InsertOrReplace(row);

            var writer = new TableStorageWriter(table);
            await writer.Store(tables);

            Assert.AreEqual(data.TableName, row[TableStorage.PartitionKey]);
            Assert.AreEqual(pk, row[TableStorage.RowKey]);

            table.Received().InsertOrReplace(row);
        }