예제 #1
0
        public void It_saves()
        {
            QueueResult(TestTableResult.OK(), TestTableResult.OK(), TestTableResult.OK());
            var entries = new List <StateEntry>
            {
                TestStateEntry.Mock().WithState(EntityState.Added).WithType("Test1"),
                TestStateEntry.Mock().WithState(EntityState.Modified).WithType("Test1"),
                TestStateEntry.Mock().WithState(EntityState.Deleted).WithType("Test1"),
            };
            var succeeded = SaveChangesAsync(entries).Result;

            Assert.Equal(3, succeeded);
        }
예제 #2
0
        public void It_separates_by_partition_key()
        {
            QueueResult(new[] { TestTableResult.OK(), TestTableResult.OK(), TestTableResult.OK() }, new[] { TestTableResult.OK(), TestTableResult.OK(), TestTableResult.OK() });
            var entries = new List <StateEntry>
            {
                TestStateEntry.Mock().WithState(EntityState.Added).WithProperty("PartitionKey", "A"),
                TestStateEntry.Mock().WithState(EntityState.Modified).WithProperty("PartitionKey", "A"),
                TestStateEntry.Mock().WithState(EntityState.Deleted).WithProperty("PartitionKey", "A"),
                TestStateEntry.Mock().WithState(EntityState.Added).WithProperty("PartitionKey", "B"),
                TestStateEntry.Mock().WithState(EntityState.Modified).WithProperty("PartitionKey", "B"),
                TestStateEntry.Mock().WithState(EntityState.Deleted).WithProperty("PartitionKey", "B"),
            };

            Assert.Equal(6, SaveChangesAsync(entries).Result);
        }
예제 #3
0
        public void It_saves_changes(int expectedChanges)
        {
            var entries   = new List <StateEntry>(expectedChanges);
            var responses = new List <TableResult>(expectedChanges);

            for (var i = 0; i < expectedChanges; i++)
            {
                entries.Add(TestStateEntry.Mock().WithState(EntityState.Added).WithType("TestType").WithProperty("PartitionKey", "A"));
                responses.Add(TestTableResult.OK());
                if (responses.Count >= 100)
                {
                    QueueResult(responses);
                    responses = new List <TableResult>();
                }
            }
            if (responses.Any())
            {
                QueueResult(responses);
            }

            var actualChanges = SaveChangesAsync(entries).Result;

            Assert.Equal(expectedChanges, actualChanges);
        }