• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

samsmithnz / RepoGovernance / 5701615620

pending completion
5701615620

push

github

web-flow
Adding count to .NET frameworks (#501)

* Added count to code

* Added counter to dotnet languages

123 of 236 branches covered (52.12%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 2 files covered. (100.0%)

456 of 647 relevant lines covered (70.48%)

7.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.41
/src/RepoGovernance.Core/TableStorage/TableStorageCommonDA.cs
1
using Azure;
2
using Azure.Data.Tables;
3
using RepoGovernance.Core.Models;
4

5
namespace RepoGovernance.Core.TableStorage
6
{
7
    public class TableStorageCommonDA
8
    {
9
        private readonly string? ConfigurationString;
10
        private readonly string? TableName;
11

12
        public TableStorageCommonDA(string connectionString, string tableName)
2✔
13
        {
2✔
14
            ConfigurationString = connectionString;
2✔
15
            TableName = tableName;
2✔
16
        }
2✔
17

18
        //This is needed for Dependency Injection
19
        public TableStorageCommonDA() { }
×
20

21
        private async Task<TableClient> CreateConnection()
22
        {
2✔
23
            //Create a connection to the Azure Table
24
            TableServiceClient serviceClient = new(ConfigurationString);
2✔
25

26
            // Get a reference to the TableClient from the service client instance.
27
            TableClient tableClient = serviceClient.GetTableClient(TableName);
2✔
28

29
            // Create the table if it doesn't exist.
30
            await tableClient.CreateIfNotExistsAsync();
2✔
31

32
            return tableClient;
2✔
33
        }
2✔
34

35
        public async Task<AzureStorageTableModel> GetItem(string partitionKey, string rowKey)
36
        {
×
37
            //prepare the partition key
38
            partitionKey = EncodePartitionKey(partitionKey);
×
39

40
            //Create a connection to the Azure Table
41
            TableClient tableClient = await CreateConnection();
×
42

43
            // Create a retrieve operation that takes a customer entity.
44
            AzureStorageTableModel result = tableClient.GetEntity<AzureStorageTableModel>(partitionKey, rowKey);
×
45

46
            return result;
×
47
        }
×
48

49
        //This can't be async, because of how it queries the underlying data
50
        public async Task<List<AzureStorageTableModel>> GetItems(string partitionKey)
51
        {
1✔
52
            partitionKey = EncodePartitionKey(partitionKey);
1✔
53

54
            //Create a connection to the Azure Table
55
            TableClient tableClient = await CreateConnection();
1✔
56

57
            // Create the query
58
            Pageable<AzureStorageTableModel>? query = tableClient.Query<AzureStorageTableModel>(e => e.PartitionKey == partitionKey);
1✔
59

60
            // Execute the query.
61
            List<AzureStorageTableModel> list = query.ToList();
1✔
62

63
            return list;
1✔
64
        }
1✔
65

66
        public async Task<bool> SaveItem(AzureStorageTableModel data)
67
        {
1✔
68
            //Create a connection to the Azure Table
69
            TableClient tableClient = await CreateConnection();
1✔
70

71
            // Create the TableOperation that inserts/merges the entity.
72
            Response response = await tableClient.UpsertEntityAsync(data);
1✔
73

74
            return !response.IsError;
1✔
75
        }
1✔
76

77
        public static string EncodePartitionKey(string text)
78
        {
3✔
79
            //The forward slash(/) character
80
            text = text.Replace("/", "_");
3✔
81

82
            return text;
3✔
83
        }
3✔
84

85
    }
86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc