Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CosmosRepositoryBase"/> class.
        /// </summary>
        /// <param name="cosmosConfiguration">Configuration to create connection with an Azure Cosmos DB Database</param>
        /// <param name="loggerFactory">Logger factory to create a logger</param>
        public CosmosRepositoryBase(CosmosConfiguration cosmosConfiguration, ILoggerFactory loggerFactory)
            : base(loggerFactory)
        {
            this.Logger.LogTrace("Construction of Cosmos Repository Base starting");

            // Validate input arguments
            cosmosConfiguration = Ensure.IsNotNull(() => cosmosConfiguration);
            cosmosConfiguration.Validate();

            // Set database id
            this.DatabaseId = Ensure.IsNotNullOrWhitespace(() => cosmosConfiguration.DatabaseId);

            this.CosmosClient = CosmosRepositoryBase
                                .CosmosClientFactory
                                .GetCosmosClient(Ensure.IsNotNullOrWhitespace(() => cosmosConfiguration.ConnectionString));

            this.Logger.LogTrace("Construction of Cosmos Repository Base complete");
        }
Example #2
0
        public void PassesValidation()
        {
            var config = BuildCosmosConfiguration();

            CosmosConfiguration.Validate(config);
        }