This repository has been archived by the owner on Jan 18, 2022. It is now read-only.
/
SpatialDeploymentManagerTests.cs
58 lines (52 loc) · 2.06 KB
/
SpatialDeploymentManagerTests.cs
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
using System;
using System.Linq;
using System.Net;
using NUnit.Framework;
namespace Improbable.Gdk.TestUtils.Editor.Tests
{
[TestFixture]
public class SpatialDeploymentManagerTests
{
[Test]
public void Start_throws_an_exception_if_deployment_config_does_not_exist()
{
var task = SpatialDeploymentManager.Start("does_not_exist.json", "snapshots/default.snapshot");
Assert.IsTrue(task.IsFaulted);
Assert.IsInstanceOf<ArgumentException>(task.Exception.InnerExceptions.First());
}
[Test]
public void Start_throws_an_exception_if_snapshot_does_not_exist()
{
var task = SpatialDeploymentManager.Start("default_launch.json", "does_not_exist.snapshot");
Assert.IsTrue(task.IsFaulted);
Assert.IsInstanceOf<ArgumentException>(task.Exception.InnerExceptions.First());
}
[Test]
public void Start_correctly_starts_a_spatial_deployment()
{
using (SpatialDeploymentManager.Start("default_launch.json", "snapshots/default.snapshot").Result)
{
var request = WebRequest.Create("http://localhost:21000/inspector");
Assert.DoesNotThrow(() => request.GetResponse());
}
}
[Test]
public void Deployment_is_dead_after_Dispose()
{
using (SpatialDeploymentManager.Start("default_launch.json", "snapshots/default.snapshot").Result)
{
}
var request = WebRequest.Create("http://localhost:21000/inspector");
Assert.Throws<WebException>(() => request.GetResponse());
}
[Test]
public void Start_throws_if_deployment_fails_to_start()
{
using (SpatialDeploymentManager.Start("default_launch.json", "snapshots/default.snapshot").Result)
{
var task = SpatialDeploymentManager.Start("default_launch.json", "snapshots/default.snapshot");
Assert.Throws<AggregateException>(() => task.Wait());
}
}
}
}