-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoreAiFacadeEditModeTests.cs
More file actions
70 lines (62 loc) · 2.57 KB
/
CoreAiFacadeEditModeTests.cs
File metadata and controls
70 lines (62 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using NUnit.Framework;
using CoreAI;
namespace CoreAI.Tests.EditMode
{
/// <summary>
/// EditMode coverage for the static <see cref="CoreAi"/> facade when no
/// <c>CoreAILifetimeScope</c> is present in the scene.
/// </summary>
public sealed class CoreAiFacadeEditModeTests
{
[SetUp]
public void ResetFacade()
{
CoreAi.Invalidate();
}
[Test]
public void IsReady_WithoutLifetimeScope_ReturnsFalse()
{
Assert.IsFalse(CoreAi.IsReady, "Без CoreAILifetimeScope в сцене фасад не должен считаться готовым");
}
[Test]
public void Invalidate_DoesNotThrow_WhenCalledMultipleTimes()
{
Assert.DoesNotThrow(() => CoreAi.Invalidate());
Assert.DoesNotThrow(() => CoreAi.Invalidate());
Assert.DoesNotThrow(() => CoreAi.Invalidate());
}
[Test]
public void GetSettings_WithoutLifetimeScope_ReturnsNull()
{
ICoreAISettings settings = CoreAi.GetSettings();
Assert.IsNull(settings,
"Без scope GetSettings возвращает null (caller должен сам использовать CoreAISettings.Instance)");
}
[Test]
public void GetChatService_WithoutLifetimeScope_ThrowsInvalidOperation()
{
InvalidOperationException ex = Assert.Throws<InvalidOperationException>(() => CoreAi.GetChatService());
StringAssert.Contains("CoreAILifetimeScope", ex.Message,
"Исключение должно подсказывать, где искать проблему");
}
[Test]
public void TryGetChatService_WithoutLifetimeScope_ReturnsFalse()
{
Assert.IsFalse(CoreAi.TryGetChatService(out _),
"Без scope TryGet не бросает исключение и возвращает false");
}
[Test]
public void GetOrchestrator_WithoutLifetimeScope_ThrowsInvalidOperation()
{
InvalidOperationException ex = Assert.Throws<InvalidOperationException>(() => CoreAi.GetOrchestrator());
StringAssert.Contains("IAiOrchestrationService", ex.Message,
"Исключение должно объяснять, что не зарегистрирован оркестратор");
}
[Test]
public void TryGetOrchestrator_WithoutLifetimeScope_ReturnsFalse()
{
Assert.IsFalse(CoreAi.TryGetOrchestrator(out _));
}
}
}