Ejemplo n.º 1
0
            public static GameServerResponse CreateMockResponse()
            {
                var mockResponseStatus = new Status
                {
                    Address = "127.0.0.1",
                    Ports   = new[] {
                        new PortInfo
                        {
                            Name = "http",
                            Port = 8080,
                        }
                    },
                    State = "Ready",
                };
                var mockResponseObjectMeta = new ObjectMeta
                {
                    Name              = "mock",
                    Namespace         = "default",
                    Generation        = "gen1",
                    ResourceVersion   = "v1",
                    Uid               = "0",
                    CreationTimestamp = new DateTime(2020, 1, 1, 0, 0, 0).ToString("yyyyMMdd_HHMMss"),
                    Annotations       = new[]
                    {
                        new Annotation
                        {
                            Key   = "key",
                            Value = "value",
                        },
                    },
                    Labels = new[]
                    {
                        new Label
                        {
                            Key   = "key",
                            Value = "value",
                        },
                    },
                };
                var response = new GameServerResponse()
                {
                    ObjectMeta = mockResponseObjectMeta,
                    Status     = mockResponseStatus,
                };

                return(response);
            }
Ejemplo n.º 2
0
        public async Task AssertSdkComplete()
        {
            var options = new AgonesSdkOptions();
            var mock    = new MockAgonesSdk(options);
            var cts     = new CancellationTokenSource();

            Assert.Null(await Record.ExceptionAsync(() => mock.Allocate(cts.Token)));
            Assert.Null(await Record.ExceptionAsync(() => mock.Annotation("key", "value", cts.Token)));
            {
                GameServerResponse response = null;
                var exception = await Record.ExceptionAsync(async() => response = await mock.GameServer(cts.Token));

                Assert.Null(exception);
                Assert.NotNull(response.ObjectMeta);
                Assert.NotNull(response.Status);
            }
            Assert.Null(await Record.ExceptionAsync(() => mock.Health(cts.Token)));
            Assert.Null(await Record.ExceptionAsync(() => mock.Label("key", "value", cts.Token)));
            Assert.Null(await Record.ExceptionAsync(() => mock.Ready(cts.Token)));
            Assert.Null(await Record.ExceptionAsync(() => mock.Reserve(1, cts.Token)));
            Assert.Null(await Record.ExceptionAsync(() => mock.Shutdown(cts.Token)));
            Assert.Null(await Record.ExceptionAsync(() => mock.Watch(cts.Token)));
        }