public void AddRangeMapShard(AddRangeMapShardArgs args) { args.Validate(); var connectionString = new SqlConnectionStringBuilder(args.ConnectionString); Log.Information( LoggingMessageTemplates.AddRangeMapShard, args.ShardDatabaseName, args.ShardServerName, args.ShardKeyRange.KeyType.Name, args.ShardKeyRange.LowValue, args.ShardKeyRange.HighValue, args.MapName, connectionString.InitialCatalog, connectionString.DataSource); var shardManagementServiceType = typeof(ShardMapManagementService); var addRangeMapShardGeneric = shardManagementServiceType.GetMethod("AddRangeMapShard"); var addRangeMapShard = addRangeMapShardGeneric.MakeGenericMethod(args.ShardKeyRange.KeyType); var shardManagementService = new ShardMapManagementService(args.ConnectionString); var parameters = new[] { args.MapName, args.ShardKeyRange.LowValue, args.ShardKeyRange.HighValue, args.ShardServerName, args.ShardDatabaseName }; addRangeMapShard.Invoke(shardManagementService, parameters); }
public void FailsValidationWhenIntLowValueIsSameAsHighValue() { var sut = new AddRangeMapShardArgs { ConnectionString = "required", MapName = "required", ShardDatabaseName = "required", ShardServerName = "required", ShardKeyRange = new ShardKeyRange(typeof(int), lowValue: 1000, highValue: 1000) }; sut.Validate(); }
public void CorrectlyAcceptsValidArguments() { var sut = new AddRangeMapShardArgs { ConnectionString = @"Server = (localdb)\mssqllocaldb; Initial Catalog = SomeTestDb; Integrated Security = true; Application Name = Galen.CI.Azure.Sql.Sharding.App.Tests; ", MapName = "MyTestListMapName", ShardServerName = "TestShard001", ShardDatabaseName = "MyShardedDatabase", ShardKeyRange = new ShardKeyRange(typeof(int), lowValue: 2000, highValue: 3000) }; sut.Validate(); // should not throw exception }