Skip to content

Commit

Permalink
More warnings fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidJGapCR committed Sep 30, 2024
1 parent 71b02b5 commit 8df3501
Show file tree
Hide file tree
Showing 32 changed files with 258 additions and 265 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// Licensed to the Ed-Fi Alliance under one or more agreements.
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.
Expand All @@ -24,7 +24,7 @@ namespace EdFi.Tools.ApiPublisher.Tests.Configuration.Serilog;
public class TextFormatterTests
{
[TestFixture]
public class When_use_the_TextFormatter_in_Serilog
public class When_use_the_TextFormatter_in_Serilog
{
private const string Message = "My text format message";
private const string LevelInfoPlain = "INFO";
Expand Down Expand Up @@ -71,8 +71,8 @@ public void Should_render_the_messages_with_default_format()
textWriter.ToString().ShouldContain(LevelInfoFormatted);
textWriter.ToString().ShouldContain(logEvent.Timestamp.ToString("yyyy-MM-dd HH:mm:ss,fff"));
}
}
}

[TestCase("[{Level}] - {Message}")]
public void Should_display_the_messages_with_custom_format(string format)
{
Expand Down Expand Up @@ -154,7 +154,5 @@ private LogEvent CreateSerilogEntry(LogEventLevel logEventLevel = LogEventLevel.

return logEvent;
}
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace EdFi.Tools.ApiPublisher.Tests.Extensions
{
public static class HttpRequestMessageExtensions
public static class HttpRequestMessageExtensions
{
public static bool HasParameter(this HttpRequestMessage request, string parameterName)
{
Expand All @@ -28,8 +28,8 @@ public static T QueryString<T>(this HttpRequestMessage request, string parameter
{
return default;
}
return (T) Convert.ChangeType(value, typeof(T));

return (T)Convert.ChangeType(value, typeof(T));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace EdFi.Tools.ApiPublisher.Tests.Extensions
{
public static class ObjectExtensions
public static class ObjectExtensions
{
private static readonly ILogger _logger = Log.ForContext(typeof(ObjectExtensions));

Expand Down Expand Up @@ -99,7 +99,7 @@ public static IDictionary<string, string> ToQueryStringParams(this object instan
MockRequests.SerializerSettings);

var obj = JObject.Parse(json);

var queryStringParms = new Dictionary<string, string>();

foreach (var property in obj.Properties())
Expand All @@ -109,7 +109,7 @@ public static IDictionary<string, string> ToQueryStringParams(this object instan

return queryStringParms;
}

public static NameValueCollection ParseQueryString(this Uri uri)
{
return HttpUtility.ParseQueryString(uri.Query);
Expand Down
7 changes: 1 addition & 6 deletions src/EdFi.Tools.ApiPublisher.Tests/FakeResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace EdFi.Tools.ApiPublisher.Tests
{
public static class FakeResponse
public static class FakeResponse
{
public static HttpResponseMessage OK(string content) =>
new HttpResponseMessage(HttpStatusCode.OK)
Expand All @@ -25,11 +25,6 @@ public static HttpResponseMessage OK(object data) =>
};

public static HttpResponseMessage NotFound() => new HttpResponseMessage(HttpStatusCode.NotFound);

// public static HttpResponseMessage StatusCodeResult(HttpStatusCode responseCode)
// {
// return new HttpResponseMessage(responseCode);
// }
}

public static class HttpResponseMessageExtensions
Expand Down
20 changes: 10 additions & 10 deletions src/EdFi.Tools.ApiPublisher.Tests/Helpers/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

namespace EdFi.Tools.ApiPublisher.Tests.Helpers
{
public class TestHelpers
public class TestHelpers
{
public const string AnyResourcePattern = "/(ed-fi|tpdm)/\\w+";
// public const string AnyResourcePattern = "/ed-fi/\\w+";
Expand All @@ -56,7 +56,7 @@ public static Faker<GenericResource<FakeKey>> GetGenericResourceFaker()
public static Faker<FakeKey> GetKeyValueFaker()
{
var linkValueFaker = GetLinkValueFaker();

// Initialize a generator for the fake natural key class
var keyValueFaker = new Faker<FakeKey>().StrictMode(true)
.RuleFor(o => o.Name, f => f.Name.FirstName())
Expand Down Expand Up @@ -113,14 +113,14 @@ public static ApiConnectionDetails GetSourceApiConnectionDetails(
Secret = "secret",
Scope = null,
SchoolYear = schoolYear,

Include = include == null ? null : string.Join(",", include),
IncludeOnly = includeOnly == null ? null : string.Join(",", includeOnly),
Exclude = exclude == null ? null : string.Join(",", exclude),
ExcludeOnly = excludeOnly == null ? null : string.Join(",", excludeOnly),

IgnoreIsolation = ignoreIsolation,

// LastChangeVersionProcessed = null,
// LastChangeVersionsProcessed = "{ 'TestTarget': 1234 }",
TreatForbiddenPostAsWarning = true,
Expand All @@ -146,13 +146,13 @@ public static ApiConnectionDetails GetTargetApiConnectionDetails(int? schoolYear
Include = null, // "abc,def,ghi",
Exclude = null,
ExcludeOnly = null,

IgnoreIsolation = true,

LastChangeVersionProcessed = null,
LastChangeVersionsProcessed = null,
TreatForbiddenPostAsWarning = true,
LastChangeVersionProcessedByTargetName = {},
LastChangeVersionProcessedByTargetName = { },

ProfileName = profileName,
};
Expand All @@ -177,7 +177,7 @@ public static string[] GetResourcesWithUpdatableKeys()

public static AuthorizationFailureHandling[] GetAuthorizationFailureHandling()
{
return new []
return new[]
{
new AuthorizationFailureHandling
{
Expand Down Expand Up @@ -221,7 +221,7 @@ public static IFakeHttpRequestHandler GetFakeBaselineSourceApiRequestHandler(
.SetChangeQueriesUrlSegment(changeQueriesUrlSegment)
.OAuthToken()
.ApiVersionMetadata()
.Snapshots(new []{ new Snapshot { Id = Guid.NewGuid(), SnapshotIdentifier = "ABC123", SnapshotDateTime = DateTime.Now } })
.Snapshots(new[] { new Snapshot { Id = Guid.NewGuid(), SnapshotIdentifier = "ABC123", SnapshotDateTime = DateTime.Now } })
.LegacySnapshotsNotFound();
}

Expand Down Expand Up @@ -301,7 +301,7 @@ EdFiApiClient TargetApiClientFactory() =>

var streamingResourceProcessor = new StreamingResourceProcessor(
new StreamResourceBlockFactory(
(withReversePaging) ?
(withReversePaging) ?
new EdFiApiChangeVersionReversePagingStreamResourcePageMessageProducer(
new EdFiApiSourceTotalCountProvider(sourceEdFiApiClientProvider)) :
new EdFiApiLimitOffsetPagingStreamResourcePageMessageProducer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace EdFi.Tools.ApiPublisher.Tests
{
public class HttpClientHandlerFakeBridge : HttpClientHandler
public class HttpClientHandlerFakeBridge : HttpClientHandler
{
private readonly IFakeHttpRequestHandler _handler;

Expand All @@ -24,7 +24,7 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
Console.WriteLine($"Requested URL: {request.Method} {request.RequestUri}");

string requestPath = $"{request.RequestUri.Scheme}://{request.RequestUri.Host}{request.RequestUri.LocalPath}";

switch (request.Method.ToString().ToUpper())
{
case "GET":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace EdFi.Tools.ApiPublisher.Tests
{
public interface IFakeHttpRequestHandler
public interface IFakeHttpRequestHandler
{
string BaseUrl { get; }
string DataManagementUrlSegment { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@

namespace EdFi.Tools.ApiPublisher.Tests.JavascriptHosting
{
[TestFixture]
[TestFixture]
public class ScriptExecutionTests
{
class Result
private class Result
{
public string? greeting { get; set; }
}

class Person
private class Person
{
public string? name { get; set; }
public int age { get; set; }
}

[Test]
public async Task Should_execute_JavaScript()
{

var result = await StaticNodeJSService.InvokeFromStringAsync<Result>(
@"
module.exports = (callback, name) => {
Expand All @@ -42,7 +42,7 @@ public async Task Should_execute_JavaScript()
result!.greeting.ShouldBe("Hello Bob!");
}

const string HelloNameSource = @"
private const string HelloNameSource = @"
module.exports = {
sayHello: async (name) => {
const result = { greeting: `Hello ${name}!` };
Expand All @@ -60,19 +60,19 @@ public async Task Should_execute_JavaScript()
public async Task Should_execute_JavaScript_object_with_functions()
{
var result = await StaticNodeJSService.InvokeFromStringAsync<Result>(
HelloNameSource,
HelloNameSource,
cacheIdentifier: "helloNameModule",
exportName: "sayHello",
exportName: "sayHello",
args: new object?[] { "Bob" });

result!.greeting.ShouldBe("Hello Bob!");

var result2 = await StaticNodeJSService.InvokeFromStringAsync<Result>(
HelloNameSource,
HelloNameSource,
cacheIdentifier: "helloNameModule",
exportName: "sayGoodbye",
exportName: "sayGoodbye",
args: new object?[] { "Bob" });

result2!.greeting.ShouldBe("Goodbye Bob!");
}

Expand All @@ -89,11 +89,11 @@ await StaticNodeJSService.InvokeFromStringAsync<Result>(
args: new object?[] { "Bob" });
});
}

[Test]
public async Task Should_execute_JavaScript_object_with_object_argument()
{
const string helloPersonSource = @"
const string HelloPersonSource = @"
module.exports = {
sayHello: async (person) => {
const result = { greeting: `Hello ${person.name}! You are ${person.age} years old already!` };
Expand All @@ -107,26 +107,26 @@ public async Task Should_execute_JavaScript_object_with_object_argument()
";

var results = await StaticNodeJSService.InvokeFromStringAsync<Result>(
helloPersonSource,
HelloPersonSource,
cacheIdentifier: "helloPersonModule",
exportName: "sayHello",
args: new object?[] { new Person { name = "Bob", age = 42 }});
args: new object?[] { new Person { name = "Bob", age = 42 } });

results?.greeting.ShouldBe("Hello Bob! You are 42 years old already!");

var results2 = await StaticNodeJSService.InvokeFromStringAsync<Result>(
helloPersonSource,
HelloPersonSource,
cacheIdentifier: "helloPersonModule",
exportName: "sayGoodbye",
args: new object?[] { new Person { name = "Bob", age = 42 }});
args: new object?[] { new Person { name = "Bob", age = 42 } });

results2?.greeting.ShouldBe("Goodbye Bob! You are 42 years old already!");
}

[Test]
public async Task Should_execute_JavaScript_object_with_status_codes_with_object_argument()
{
const string helloPersonSource2 = @"
const string HelloPersonSource2 = @"
module.exports = {
200: async (person) => {
const result = { greeting: `Hello ${person.name}! You are ${person.age} years old already!` };
Expand All @@ -140,26 +140,26 @@ public async Task Should_execute_JavaScript_object_with_status_codes_with_object
";

var results = await StaticNodeJSService.InvokeFromStringAsync<Result>(
helloPersonSource2,
HelloPersonSource2,
cacheIdentifier: "helloPersonModule2",
exportName: "200",
args: new object?[] { new Person { name = "Bob", age = 42 }});
args: new object?[] { new Person { name = "Bob", age = 42 } });

results?.greeting.ShouldBe("Hello Bob! You are 42 years old already!");

var results2 = await StaticNodeJSService.InvokeFromStringAsync<Result>(
helloPersonSource2,
HelloPersonSource2,
cacheIdentifier: "helloPersonModule2",
exportName: "500",
args: new object?[] { new Person { name = "Bob", age = 42 }});
args: new object?[] { new Person { name = "Bob", age = 42 } });

results2?.greeting.ShouldBe("Goodbye Bob! You are 42 years old already!");
}

[Test]
public async Task Should_execute_JavaScript_object_with_resource_paths_with_object_argument()
{
const string helloPersonSource3 = @"
const string HelloPersonSource3 = @"
module.exports = {
'/ed-fi/students/200': async (person) => {
const result = { greeting: `Hello ${person.name}! You are ${person.age} years old already!` };
Expand All @@ -173,18 +173,18 @@ public async Task Should_execute_JavaScript_object_with_resource_paths_with_obje
";

var results = await StaticNodeJSService.InvokeFromStringAsync<Result>(
helloPersonSource3,
HelloPersonSource3,
cacheIdentifier: "helloPersonModule3",
exportName: "/ed-fi/students/200",
args: new object?[] { new Person { name = "Bob", age = 42 }});
args: new object?[] { new Person { name = "Bob", age = 42 } });

results?.greeting.ShouldBe("Hello Bob! You are 42 years old already!");

var results2 = await StaticNodeJSService.InvokeFromStringAsync<Result>(
helloPersonSource3,
HelloPersonSource3,
cacheIdentifier: "helloPersonModule3",
exportName: "/ed-fi/students/500",
args: new object?[] { new Person { name = "Bob", age = 42 }});
args: new object?[] { new Person { name = "Bob", age = 42 } });

results2?.greeting.ShouldBe("Goodbye Bob! You are 42 years old already!");
}
Expand Down
6 changes: 3 additions & 3 deletions src/EdFi.Tools.ApiPublisher.Tests/MockRateLimitingMethod.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// Licensed to the Ed-Fi Alliance under one or more agreements.
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.
Expand All @@ -20,11 +20,11 @@ public MockRateLimitingMethod(IRateLimiting<HttpResponseMessage> rateLimiter)
_rateLimiter = rateLimiter;
}

public async Task<HttpResponseMessage> ExecuteAsync(int id=0)
public async Task<HttpResponseMessage> ExecuteAsync(int id = 0)
{
return await _rateLimiter.ExecuteAsync(async () =>
{
await Task.Delay(100);
await Task.Delay(100);
return new HttpResponseMessage(System.Net.HttpStatusCode.OK)
{
Content = new StringContent("Execution completed successfully!")
Expand Down
Loading

0 comments on commit 8df3501

Please sign in to comment.