From fe1821159649ce06de8279f84793079e4821d579 Mon Sep 17 00:00:00 2001 From: Adrian Hall Date: Wed, 16 Jul 2025 10:10:52 -0700 Subject: [PATCH] (#353) Backed out sample service tests. --- .../Live/SampleServerTests.cs | 51 ------------------- .../Databases/ConnectionStrings.cs | 12 ++++- 2 files changed, 11 insertions(+), 52 deletions(-) delete mode 100644 tests/CommunityToolkit.Datasync.Client.Test/Live/SampleServerTests.cs diff --git a/tests/CommunityToolkit.Datasync.Client.Test/Live/SampleServerTests.cs b/tests/CommunityToolkit.Datasync.Client.Test/Live/SampleServerTests.cs deleted file mode 100644 index 7e97f7f..0000000 --- a/tests/CommunityToolkit.Datasync.Client.Test/Live/SampleServerTests.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using CommunityToolkit.Datasync.TestCommon.Databases; -using System.Net; -using System.Net.Http.Json; - -namespace CommunityToolkit.Datasync.Client.Test.Live; - -[ExcludeFromCodeCoverage] -public class SampleServerTests -{ - private readonly bool liveTestsAreEnabled = ConnectionStrings.Service is not null; - private readonly string serviceEndpoint = ConnectionStrings.Service; - - [SkippableFact] - public async Task Metadata_GetsSetByServer() - { - Skip.IfNot(this.liveTestsAreEnabled); - - DateTimeOffset now = DateTimeOffset.UtcNow; - HttpClient client = new(); - TodoItem source = new() { Title = "Test item" }; - HttpResponseMessage response = await client.PostAsJsonAsync($"{this.serviceEndpoint}/tables/TodoItem", source); - - response.StatusCode.Should().Be(HttpStatusCode.Created); - - TodoItem result = await response.Content.ReadFromJsonAsync(); - result.Id.Should().NotBeNullOrEmpty(); - result.UpdatedAt.Should().NotBeNull().And.BeAfter(now); - result.Version.Should().NotBeNullOrEmpty(); - result.Deleted.Should().BeFalse(); - result.Title.Should().Be("Test item"); - result.IsComplete.Should().BeFalse(); - - response.Headers.Location.Should().NotBeNull().And.BeEquivalentTo(new Uri($"{this.serviceEndpoint}/tables/TodoItem/{result.Id}")); - response.Headers.ETag.ToString().Should().Be($"\"{result.Version}\""); - } - - // This must match the TodoItem class in the server project. - public class TodoItem - { - public string Id { get; set; } - public DateTimeOffset? UpdatedAt { get; set; } - public string Version { get; set; } - public bool Deleted { get; set; } - public string Title { get; set; } - public bool IsComplete { get; set; } - } -} diff --git a/tests/CommunityToolkit.Datasync.TestCommon/Databases/ConnectionStrings.cs b/tests/CommunityToolkit.Datasync.TestCommon/Databases/ConnectionStrings.cs index 16899e0..9876a4b 100644 --- a/tests/CommunityToolkit.Datasync.TestCommon/Databases/ConnectionStrings.cs +++ b/tests/CommunityToolkit.Datasync.TestCommon/Databases/ConnectionStrings.cs @@ -7,8 +7,18 @@ namespace CommunityToolkit.Datasync.TestCommon.Databases; [ExcludeFromCodeCoverage] public static class ConnectionStrings { + /// + /// The connection string for CosmosDb database with standard NoSQL API. + /// public static readonly string CosmosDb = Environment.GetEnvironmentVariable("COSMOS_CONNECTION_STRING"); + + /// + /// The connection string for CosmosDb database with MongoDB API. + /// public static readonly string CosmosMongo = Environment.GetEnvironmentVariable("MONGO_CONNECTION_STRING"); - public static readonly string Service = Environment.GetEnvironmentVariable("SERVICE_ENDPOINT"); + + /// + /// If true, enables logging of SQL queries to the console. + /// public static readonly bool EnableLogging = (Environment.GetEnvironmentVariable("ENABLE_SQL_LOGGING") ?? "false") == "true"; } \ No newline at end of file