Skip to content

Commit cbab9dc

Browse files
committed
ShouldSendAndCopyMessageAsync -> FAIL
1 parent 6ddf20b commit cbab9dc

File tree

5 files changed

+81
-16
lines changed

5 files changed

+81
-16
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// ---------------------------------------
2+
// Copyright (c) 2024 Mabrouk Mahdhi.
3+
// Made with love for the .NET Community
4+
// ---------------------------------------
5+
6+
using FlexiMail.Models.Foundations.Bodies;
7+
using FlexiMail.Models.Foundations.Messages;
8+
9+
namespace FlexiMail.Test.Integration.Clients
10+
{
11+
public partial class FlexiMailClientTests
12+
{
13+
[Fact]
14+
public async void ShouldSendAndCopyMessageAsync()
15+
{
16+
// Given
17+
var flexiMessage = new FlexiMessage()
18+
{
19+
Subject = "FlexiMessage is a cool library",
20+
To = [GetReceiverTestEmail()],
21+
Body = new FlexiBody
22+
{
23+
Content = "<h3>This is a test</h3><p>Bonjour tout le monde!</p>",
24+
ContentType = BodyContentType.Html
25+
}
26+
};
27+
28+
// when
29+
var sendMessageTask =
30+
this.flexiMailClient.SendAndSaveCopyAsync(flexiMessage);
31+
32+
// then
33+
Assert.True(sendMessageTask.IsCompletedSuccessfully, "The message should be sent and copied successfully.");
34+
}
35+
}
36+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// ---------------------------------------
2+
// Copyright (c) 2024 Mabrouk Mahdhi.
3+
// Made with love for the .NET Community
4+
// ---------------------------------------
5+
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Linq;
9+
using FlexiMail.Models.Configurations;
10+
11+
namespace FlexiMail.Test.Integration.Clients
12+
{
13+
public partial class FlexiMailClientTests
14+
{
15+
private readonly IFlexiMailClient flexiMailClient;
16+
17+
public FlexiMailClientTests()
18+
{
19+
var tenantId = Environment.GetEnvironmentVariable("TenantId",EnvironmentVariableTarget.Machine);
20+
var authority = $"https://login.microsoftonline.com/{tenantId}";
21+
22+
var configurations = new ExchangeConfigurations
23+
{
24+
ClientId = Environment.GetEnvironmentVariable("ClientId"),
25+
ClientSecret = Environment.GetEnvironmentVariable("ClientSecret"),
26+
TenantId = tenantId,
27+
Authority = authority,
28+
SmtpAddress = Environment.GetEnvironmentVariable("SmtpAddress"),
29+
PrincipalName = Environment.GetEnvironmentVariable("PrincipalName"),
30+
Sid = Environment.GetEnvironmentVariable("Sid"),
31+
Scopes = ["https://outlook.office365.com/.default"],
32+
};
33+
34+
this.flexiMailClient = new FlexiMailClient(configurations);
35+
}
36+
37+
private static string GetReceiverTestEmail() =>
38+
Environment.GetEnvironmentVariable("FlexiTestEmail");
39+
}
40+
}

FlexiMail.Test.Integration/DeleteMe.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

FlexiMail/FlexiMailClient.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//---------------------------------------
55

66
using System;
7+
using System.Threading.Tasks;
78
using FlexiMail.Brokers.Exchanges;
89
using FlexiMail.Models.Configurations;
910
using FlexiMail.Models.Foundations.Messages;
@@ -24,8 +25,8 @@ public FlexiMailClient(ExchangeConfigurations configurations)
2425
serviceProvider.GetRequiredService<IFlexiExchangeService>();
2526
}
2627

27-
public void SendAndSaveCopyAsync(FlexiMessage flexiMessage) =>
28-
this.exchangeService.SendAndSaveCopyAsync(flexiMessage);
28+
public async ValueTask SendAndSaveCopyAsync(FlexiMessage flexiMessage) =>
29+
await this.exchangeService.SendAndSaveCopyAsync(flexiMessage);
2930

3031
private static IServiceProvider RegisterServices(ExchangeConfigurations configurations)
3132
{

FlexiMail/IFlexiMailClient.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
// Made with love for the .NET Community
44
// ---------------------------------------
55

6+
using System.Threading.Tasks;
67
using FlexiMail.Models.Foundations.Messages;
78

89
namespace FlexiMail
910
{
1011
public interface IFlexiMailClient
1112
{
12-
void SendAndSaveCopyAsync(FlexiMessage flexiMessage);
13+
ValueTask SendAndSaveCopyAsync(FlexiMessage flexiMessage);
1314
}
1415
}

0 commit comments

Comments
 (0)