Exemplo n.º 1
0
        public void CorrectlyRevivesMutlipleShardLocations()
        {
            const string expectedServerName01   = @"(localdb)\mssqllocaldb";
            const string expectedServerName02   = @"(localdb)\.\SharedLocalDb";
            const string expectedDatabaseName01 = "MyTestShard001";
            const string expectedDatabaseName02 = "MyTestShard002";

            var argValue =
                $"{expectedServerName01}|{expectedDatabaseName01},{expectedServerName02}|{expectedDatabaseName02}";

            var actualShardLocations = ShardLocationsArgReviver.Revive(null, argValue);

            Assert.IsNotNull(actualShardLocations);
            Assert.IsNotNull(actualShardLocations.Locations);
            Assert.AreEqual(2, actualShardLocations.Locations.Length);

            var actualLocation01 = actualShardLocations.Locations[0];

            Assert.AreEqual(expectedServerName01, actualLocation01.ServerName);
            Assert.AreEqual(expectedDatabaseName01, actualLocation01.DatabaseName);

            var actualLocation02 = actualShardLocations.Locations[1];

            Assert.AreEqual(expectedServerName02, actualLocation02.ServerName);
            Assert.AreEqual(expectedDatabaseName02, actualLocation02.DatabaseName);
        }
Exemplo n.º 2
0
        public void CorrectlyReturnsEmptyLocationsArrayForEmtpyLocationValueAndDoesNotThrowException()
        {
            var actualEmptyLocations = ShardLocationsArgReviver.Revive(null, ",");

            Assert.IsNotNull(actualEmptyLocations);
            Assert.IsNotNull(actualEmptyLocations.Locations);
            Assert.IsFalse(actualEmptyLocations.Locations.Any());
        }
Exemplo n.º 3
0
        public void CorrectlyReturnsNullForNullOrEmptyOrWhiteSpaceValue()
        {
            var actualNull = ShardLocationsArgReviver.Revive(null, null);

            Assert.IsNull(actualNull);

            var actualEmpty = ShardLocationsArgReviver.Revive(null, "");

            Assert.IsNull(actualNull);

            var actualWhiteSpace = ShardLocationsArgReviver.Revive(null, "\t");

            Assert.IsNull(actualNull);
        }
Exemplo n.º 4
0
        public void CorrectlyRevivesSingleShardLocationWithErrantPairSeperator()
        {
            const string expectedServerName   = @"(localdb)\mssqllocaldb";
            const string expectedDatabaseName = "MyTestShard001";

            var actualShardLocations = ShardLocationsArgReviver.Revive(null, $"{expectedServerName}|{expectedDatabaseName}|");

            Assert.IsNotNull(actualShardLocations);
            Assert.IsNotNull(actualShardLocations.Locations);
            Assert.AreEqual(1, actualShardLocations.Locations.Length);

            var actualLocation = actualShardLocations.Locations.Single();

            Assert.AreEqual(expectedServerName, actualLocation.ServerName);
            Assert.AreEqual(expectedDatabaseName, actualLocation.DatabaseName);
        }
Exemplo n.º 5
0
 public void ThrowsExceptionForMissingDatabaseNameWhenMultipleLocationsSpecified()
 {
     var _ = ShardLocationsArgReviver.Revive(null, @"(localdb)\mssqllocaldb|,(localdb)\mssqllocaldb|MyTestShard002");
 }
Exemplo n.º 6
0
 public void ThrowsExceptionForMissingDatabaseName()
 {
     var _ = ShardLocationsArgReviver.Revive(null, @"(localdb)\mssqllocaldb|");
 }
Exemplo n.º 7
0
 public void ThrowsExceptionForMissingServerName()
 {
     var _ = ShardLocationsArgReviver.Revive(null, "|MyTestShard001");
 }