Add promt fix tests
All checks were successful
SonarQube / Build and analyze (push) Successful in 2m54s
All checks were successful
SonarQube / Build and analyze (push) Successful in 2m54s
This commit is contained in:
@@ -152,25 +152,23 @@ public static class TestDataBuilder
|
||||
var mock = new Mock<ISessionStorage>();
|
||||
var sessions = new Dictionary<long, ChatSession>();
|
||||
|
||||
mock.Setup(x => x.GetOrCreate(It.IsAny<long>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Returns<long, string, string>(
|
||||
(chatId, chatType, chatTitle) =>
|
||||
mock.Setup(x => x.GetOrCreateAsync(It.IsAny<long>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.ReturnsAsync((long chatId, string chatType, string chatTitle) =>
|
||||
{
|
||||
if (!sessions.TryGetValue(chatId, out var session))
|
||||
{
|
||||
if (!sessions.TryGetValue(chatId, out var session))
|
||||
{
|
||||
session = TestDataBuilder.ChatSessions.CreateBasicSession(
|
||||
chatId,
|
||||
chatType
|
||||
);
|
||||
session.ChatTitle = chatTitle;
|
||||
sessions[chatId] = session;
|
||||
}
|
||||
return session;
|
||||
session = TestDataBuilder.ChatSessions.CreateBasicSession(
|
||||
chatId,
|
||||
chatType
|
||||
);
|
||||
session.ChatTitle = chatTitle;
|
||||
sessions[chatId] = session;
|
||||
}
|
||||
);
|
||||
return session;
|
||||
});
|
||||
|
||||
mock.Setup(x => x.Get(It.IsAny<long>()))
|
||||
.Returns<long>(chatId =>
|
||||
mock.Setup(x => x.GetAsync(It.IsAny<long>()))
|
||||
.ReturnsAsync((long chatId) =>
|
||||
sessions.TryGetValue(chatId, out var session) ? session : null
|
||||
);
|
||||
|
||||
@@ -181,12 +179,12 @@ public static class TestDataBuilder
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
|
||||
mock.Setup(x => x.Remove(It.IsAny<long>()))
|
||||
.Returns<long>(chatId => sessions.Remove(chatId));
|
||||
mock.Setup(x => x.RemoveAsync(It.IsAny<long>()))
|
||||
.ReturnsAsync((long chatId) => sessions.Remove(chatId));
|
||||
|
||||
mock.Setup(x => x.GetActiveSessionsCount()).Returns(() => sessions.Count);
|
||||
mock.Setup(x => x.GetActiveSessionsCountAsync()).ReturnsAsync(() => sessions.Count);
|
||||
|
||||
mock.Setup(x => x.CleanupOldSessions(It.IsAny<int>())).Returns<int>(hoursOld => 0);
|
||||
mock.Setup(x => x.CleanupOldSessionsAsync(It.IsAny<int>())).ReturnsAsync((int hoursOld) => 0);
|
||||
|
||||
return mock;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user