Ejemplo n.º 1
0
        public void Equality()
        {
            DateTime timestamp1 = new DateTime(2000, 6, 1, 23, 1, 5, DateTimeKind.Utc);
            TimeSpan staleness1 = TimeSpan.FromSeconds(10);

            DateTime timestamp2 = new DateTime(2005, 1, 1, 1, 1, 1, DateTimeKind.Utc);
            TimeSpan staleness2 = TimeSpan.FromSeconds(30);

            var strong         = TimestampBound.Strong;
            var minRead        = TimestampBound.OfMinReadTimestamp(timestamp1);
            var read           = TimestampBound.OfReadTimestamp(timestamp1);
            var exactStaleness = TimestampBound.OfExactStaleness(staleness1);
            var maxStaleness   = TimestampBound.OfMaxStaleness(staleness1);

            EqualityTester.AssertEqual(strong,
                                       new[] { strong },
                                       new[] { minRead, read, exactStaleness, maxStaleness });

            EqualityTester.AssertEqual(minRead,
                                       new[] { TimestampBound.OfMinReadTimestamp(timestamp1) },
                                       new[] { strong, read, exactStaleness, maxStaleness, TimestampBound.OfMinReadTimestamp(timestamp2) });

            EqualityTester.AssertEqual(read,
                                       new[] { TimestampBound.OfReadTimestamp(timestamp1) },
                                       new[] { strong, minRead, exactStaleness, maxStaleness, TimestampBound.OfReadTimestamp(timestamp2) });

            EqualityTester.AssertEqual(exactStaleness,
                                       new[] { TimestampBound.OfExactStaleness(staleness1) },
                                       new[] { strong, minRead, read, maxStaleness, TimestampBound.OfExactStaleness(staleness2) });

            EqualityTester.AssertEqual(maxStaleness,
                                       new[] { TimestampBound.OfMaxStaleness(staleness1) },
                                       new[] { strong, minRead, read, exactStaleness, TimestampBound.OfMaxStaleness(staleness2) });
        }
Ejemplo n.º 2
0
        public void Equality_CustomHostAndPort()
        {
            string dataSource = "projects/p1/instances/i1/databases/d1";
            var    builder    = new SpannerConnectionStringBuilder {
                DataSource = dataSource, Host = "h1", Port = 500
            };
            // The data source doesn't matter
            var equalBuilder = new SpannerConnectionStringBuilder($"Data Source=projects/p2/instances/i2/databases/d2;Host = h1; Port = 500");

            var unequalBuilders = new[]
            {
                new SpannerConnectionStringBuilder {
                    DataSource = dataSource, Host = "h1", Port = 600
                },
                new SpannerConnectionStringBuilder {
                    DataSource = dataSource, Host = "h2", Port = 500
                },
                new SpannerConnectionStringBuilder {
                    DataSource = dataSource, Host = "h1", Port = 500, MaximumGrpcChannels = 5
                },
                new SpannerConnectionStringBuilder {
                    DataSource = dataSource, Host = "h1", Port = 500, MaxConcurrentStreamsLowWatermark = 25
                },
                new SpannerConnectionStringBuilder {
                    DataSource = dataSource, Host = "h1", Port = 500, CredentialFile = "creds.json"
                },
                new SpannerConnectionStringBuilder($"Data Source={dataSource}; Host = h1; Port = 500", new ComputeCredential().ToChannelCredentials())
            };

            var options        = new SpannerClientCreationOptions(builder);
            var equalOptions   = new SpannerClientCreationOptions(equalBuilder);
            var unequalOptions = unequalBuilders.Select(b => new SpannerClientCreationOptions(b)).ToArray();

            EqualityTester.AssertEqual(options, new[] { equalOptions }, unequalOptions);
        }
Ejemplo n.º 3
0
        public void Equality(string controlText, string[] equalText, string[] unequalText)
        {
            BigQueryNumeric control = BigQueryNumeric.Parse(controlText);

            BigQueryNumeric[] equal   = equalText.Select(BigQueryNumeric.Parse).ToArray();
            BigQueryNumeric[] unequal = unequalText.Select(BigQueryNumeric.Parse).ToArray();
            EqualityTester.AssertEqual(control, equal, unequal);
            EqualityTester.AssertEqualityOperators(control, equal, unequal);
        }
Ejemplo n.º 4
0
 public void Equality()
 {
     EqualityTester.AssertEqual(BigQueryGeography.Parse("POINT(30 10)"),
                                new[] { BigQueryGeography.Parse("POINT(30 10)") },
                                new[]
     {
         BigQueryGeography.Parse("POINT (30 10)"),     // Whitespace is relevant
         BigQueryGeography.Parse("POINT"),
         BigQueryGeography.Parse("LINESTRING (30 10, 10 30, 40 40)")
     });
 }
Ejemplo n.º 5
0
        public void Equality_DefaultHostAndPort()
        {
            string dataSource = "projects/p1/instances/i1/databases/d1";
            var    builder    = new SpannerConnectionStringBuilder {
                DataSource = dataSource
            };
            // Timeout doesn't matter
            var equalBuilder = new SpannerConnectionStringBuilder($"Data Source={dataSource}; Timeout=100");

            var unequalBuilders = new[]
            {
                new SpannerConnectionStringBuilder {
                    DataSource = dataSource, CredentialFile = "creds.json"
                },
                new SpannerConnectionStringBuilder($"Data Source={dataSource}", new ComputeCredential().ToChannelCredentials())
            };

            var options        = new SpannerClientCreationOptions(builder);
            var equalOptions   = new SpannerClientCreationOptions(equalBuilder);
            var unequalOptions = unequalBuilders.Select(b => new SpannerClientCreationOptions(b)).ToArray();

            EqualityTester.AssertEqual(options, new[] { equalOptions }, unequalOptions);
        }