Skip to content

Commit

Permalink
Fix Tests for Folder
Browse files Browse the repository at this point in the history
  • Loading branch information
boonkerz committed Jan 8, 2025
1 parent 85e5a6c commit 7ca7b7f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public async Task GetMessage_ValidMime()

var dbMessage = await new MessageConverter().ConvertAsync(message, [to]);
dbMessage.Mailbox = new DbModel.Mailbox { Name = MailboxOptions.DEFAULTNAME };
dbMessage.Folder = new DbModel.Folder { Name = "INBOX", Path = "INBOX"};

return dbMessage;
}
Expand Down
2 changes: 1 addition & 1 deletion Rnwood.Smtp4dev.Tests/Controllers/RelayMessageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public RelayMessagesTests()
var sqlLiteForTesting = new SqliteInMemory();
context = new Smtp4devDbContext(sqlLiteForTesting.ContextOptions);
InitRepo();
messagesRepository.GetMessages(Arg.Any<string>(), Arg.Any<bool>())
messagesRepository.GetMessages(Arg.Any<string>(), null, Arg.Any<bool>())
.Returns(context.Messages);
messagesRepository.TryGetMessageById(Arg.Any<Guid>(), Arg.Any<bool>())

Expand Down
19 changes: 14 additions & 5 deletions Rnwood.Smtp4dev.Tests/TestMessagesRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,28 @@ public Task DeleteAllMessages(string mailboxName)
}

public Smtp4devDbContext DbContext => throw new NotImplementedException();

public Task DeleteMessage(Guid id)
public Task CopyMessageToFolder(Guid id, string targetFolder)
{
Messages.RemoveAll(m => m.Id == id);
var message = Messages.FirstOrDefault(m => m.Id == id);
if (message != null)
{
message.Folder = new Folder() { Name = targetFolder, Path = targetFolder };
}
return Task.CompletedTask;
}

public IQueryable<Message> GetAllMessages(bool unTracked = true)
public IQueryable<Message> GetMessages(string mailboxName, string folder = null, bool unTracked = true)
{
return Messages.AsQueryable();
}

public IQueryable<Message> GetMessages(string mailboxName, bool unTracked = true)
public Task DeleteMessage(Guid id)
{
Messages.RemoveAll(m => m.Id == id);
return Task.CompletedTask;
}

public IQueryable<Message> GetAllMessages(bool unTracked = true)
{
return Messages.AsQueryable();
}
Expand Down

0 comments on commit 7ca7b7f

Please sign in to comment.