-
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.
- Loading branch information
1 parent
11d8bc5
commit c3c0acc
Showing
13 changed files
with
120 additions
and
41 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
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
79 changes: 76 additions & 3 deletions
79
src/Hooki.UnitTests/MicrosoftTeams/BuilderTests/TargetBuilderTests.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 |
---|---|---|
@@ -1,6 +1,79 @@ | ||
using FluentAssertions; | ||
using Hooki.MicrosoftTeams.Builders; | ||
using Hooki.MicrosoftTeams.Enums; | ||
|
||
namespace Hooki.UnitTests.MicrosoftTeams.BuilderTests; | ||
|
||
public class TargetBuilderTests | ||
{ | ||
|
||
} | ||
{ | ||
private const string ValidUri = "https://example.com"; | ||
|
||
private const OperatingSystemType DefaultOperatingSystem = OperatingSystemType.Default; | ||
private const OperatingSystemType CustomOperatingSystem = OperatingSystemType.Android; | ||
|
||
[Fact] | ||
public void Build_With_All_Properties_Returns_Correct_Target() | ||
{ | ||
// Arrange | ||
var builder = new TargetBuilder() | ||
.WithOperatingSystem(CustomOperatingSystem) | ||
.WithUri(ValidUri); | ||
|
||
// Act | ||
var result = builder.Build(); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.OperatingSystem.Should().Be(CustomOperatingSystem); | ||
result.Uri.Should().Be(ValidUri); | ||
} | ||
|
||
[Fact] | ||
public void Build_With_Only_Uri_Returns_Target_With_Default_OS() | ||
{ | ||
// Arrange | ||
var builder = new TargetBuilder() | ||
.WithUri(ValidUri); | ||
|
||
// Act | ||
var result = builder.Build(); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.OperatingSystem.Should().Be(DefaultOperatingSystem); | ||
result.Uri.Should().Be(ValidUri); | ||
} | ||
|
||
[Fact] | ||
public void Build_Without_Uri_Throws_InvalidOperationException() | ||
{ | ||
// Arrange | ||
var builder = new TargetBuilder() | ||
.WithOperatingSystem(CustomOperatingSystem); | ||
|
||
// Act & Assert | ||
builder.Invoking(b => b.Build()) | ||
.Should().Throw<InvalidOperationException>() | ||
.WithMessage("Uri is required for Target."); | ||
} | ||
|
||
[Theory] | ||
[InlineData(OperatingSystemType.IOS)] | ||
[InlineData(OperatingSystemType.Android)] | ||
[InlineData(OperatingSystemType.Windows)] | ||
public void Build_With_Different_OS_Types_Returns_Correct_Target(OperatingSystemType osType) | ||
{ | ||
// Arrange | ||
var builder = new TargetBuilder() | ||
.WithOperatingSystem(osType) | ||
.WithUri(ValidUri); | ||
|
||
// Act | ||
var result = builder.Build(); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.OperatingSystem.Should().Be(osType); | ||
result.Uri.Should().Be(ValidUri); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Runtime.Serialization; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Hooki.MicrosoftTeams.Enums; | ||
|
||
//ToDo: Refactor this in .NET 9 with new attribute: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonStringEnumMemberNameAttribute.cs | ||
[JsonConverter(typeof(JsonStringEnumMemberConverter))] | ||
public enum OperatingSystemType | ||
{ | ||
[EnumMember(Value = "default")] | ||
Default, | ||
|
||
[EnumMember(Value = "iOS")] | ||
IOS, | ||
|
||
[EnumMember(Value = "android")] | ||
Android, | ||
|
||
[EnumMember(Value = "windows")] | ||
Windows | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,12 @@ | ||
using System.Runtime.Serialization; | ||
using System.Text.Json.Serialization; | ||
using Hooki.MicrosoftTeams.Enums; | ||
|
||
namespace Hooki.MicrosoftTeams.Models.BuildingBlocks; | ||
|
||
public class Target | ||
{ | ||
[JsonPropertyName("os")] public required OperatingSystemTypes OperatingSystem { get; set; } = OperatingSystemTypes.Default; | ||
[JsonPropertyName("os")] public required OperatingSystemType OperatingSystem { get; set; } = OperatingSystemType.Default; | ||
|
||
[JsonPropertyName("uri")] public required string Uri { get; set; } | ||
} | ||
|
||
//ToDo: Refactor this in .NET 9 with new attribute: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonStringEnumMemberNameAttribute.cs | ||
[JsonConverter(typeof(JsonStringEnumMemberConverter))] | ||
public enum OperatingSystemTypes | ||
{ | ||
[EnumMember(Value = "default")] | ||
Default, | ||
|
||
[EnumMember(Value = "iOS")] | ||
Ios, | ||
|
||
[EnumMember(Value = "android")] | ||
Android, | ||
|
||
[EnumMember(Value = "windows")] | ||
Windows | ||
} |
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