-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(os): migrate from Windows to Ubuntu linux and add tests
- Loading branch information
Showing
25 changed files
with
1,160 additions
and
468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Timezone.Core.Models; | ||
|
||
public class TimeZoneConversionResultDomain | ||
{ | ||
public DateTime DateTime { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Timezone.Core.Models; | ||
|
||
public class TimeZoneConversionResultResponse | ||
{ | ||
public DateTime DateTime { get; set; } | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/Timezone.FunctionalTests/Features/ConvertController.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Feature: Timezone Conversion | ||
As an API user, | ||
I want to ensure that the timezone conversion API is accurate | ||
So that I can reliably convert date and time across different timezones | ||
|
||
Scenario Outline: Requesting to convert time from one timezone to another timezone should return the correct time | ||
Given I have a request to convert date '<DateTime>' from '<FromTimezone>' to '<ToTimezone>' | ||
When I send the request | ||
Then the response should return '200' status code | ||
And the response should correctly convert the time into '<ExpectedDateTime>' | ||
|
||
Examples: | ||
| DateTime | FromTimezone | ToTimezone | ExpectedDateTime | | ||
| "2023-02-01T12:00:00" | "UTC" | "America/New_York" | "2023-02-01T07:00:00" | | ||
| "2023-02-01T07:00:00" | "America/New_York" | "UTC" | "2023-02-01T12:00:00" | | ||
| "2023-02-01T07:00:00" | "America/New_York" | "Europe/London" | "2023-02-01T12:00:00" | | ||
| "2023-02-01T07:00:00" | "America/New_York" | "Asia/Tokyo" | "2023-02-01T21:00:00" | | ||
|
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
tests/Timezone.FunctionalTests/Features/TimezoneController.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Feature: Timezone Retrieval | ||
As an API user, | ||
I want to be able to interact with the timezone data, | ||
So that I can retrieve all timezones, request specific timezone information, and receive proper error handling for invalid timezone requests. | ||
|
||
Scenario: Requesting all timezones should return all timezones | ||
Given I have a request to get all timezones | ||
When I send the request | ||
Then the response should return '200' status code | ||
# As of 15th of December 2024, there are 419 timezones. | ||
Then I should get at least 400 timezones | ||
|
||
Scenario: Request one valid timezone should return one timezone | ||
Given I have a request to get 'America/New_York' timezone | ||
When I send the request | ||
Then the response should return '200' status code | ||
Then the response should contain timezone information: | ||
| Name | Offset | | ||
| (UTC-05:00) America/New_York | -5 | | ||
|
||
Scenario: Request one invalid timezone should return 404 | ||
Given I have a request to get 'invalid-timezone' timezone | ||
When I send the request | ||
Then the response should return '404' status code |
47 changes: 47 additions & 0 deletions
47
tests/Timezone.FunctionalTests/StepDefinitions/ConvertStepDefinitions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
namespace Timezone.FunctionalTests.StepDefinitions; | ||
|
||
using System.Globalization; | ||
using System.Text.Json; | ||
using Core.Models; | ||
using FluentAssertions; | ||
using RestSharp; | ||
using Support; | ||
|
||
[Binding] | ||
public class ConvertStepDefinitions(ScenarioContext context) : TestBase(context) | ||
{ | ||
private static JsonSerializerOptions JsonSerializerOptions => new() | ||
{ | ||
PropertyNameCaseInsensitive = true, | ||
}; | ||
|
||
[Given(@"I have a request to convert date '""([^""]*)""' from '""([^""]*)""' to '""([^""]*)""'")] | ||
public void GivenIHaveARequestToConvertDateFromTo(string dateTimeString, string fromTimezone, string toTimezone) | ||
{ | ||
var request = new RestRequest("/convert", Method.Post) { RequestFormat = DataFormat.Json }; | ||
|
||
request.AddBody(new TimeZoneConversionRequest | ||
{ | ||
DateTime = DateTime.Parse(dateTimeString, CultureInfo.InvariantCulture), | ||
FromTimezone = fromTimezone, | ||
ToTimezone = toTimezone | ||
}); | ||
|
||
// Add to context | ||
Context.Set(request); | ||
} | ||
|
||
[Then(@"the response should correctly convert the time into '""([^""]*)""'")] | ||
public void ThenTheResponseShouldCorrectlyConvertTheTimeInto(string dateTime) | ||
{ | ||
// Arrange | ||
var expected = DateTime.Parse(dateTime, CultureInfo.InvariantCulture); | ||
|
||
// Act | ||
var rawResponse = Context.Get<RestResponse>(); | ||
var response = JsonSerializer.Deserialize<TimeZoneConversionResultResponse> | ||
(rawResponse.Content, JsonSerializerOptions); | ||
|
||
response.DateTime.Should().Be(expected); | ||
} | ||
} |
Oops, something went wrong.