public void ReceptionistFlow_connects_to_local_deployment_by_default()
        {
            var receptionistFlow = new ReceptionistFlow("My-Worker-Id");

            Assert.DoesNotThrow(() => connection = receptionistFlow.CreateAsync(GetConnectionParameters()).Result);
            Assert.AreEqual(ConnectionStatusCode.Success, connection.GetConnectionStatusCode());
        }
Пример #2
0
            public override void AcknowledgeAuthorityLoss(ComponentGroup group, ComponentSystemBase system,
                                                          Improbable.Worker.CInterop.Connection connection)
            {
                var authorityLossType = system.GetArchetypeChunkComponentType <AuthorityLossImminent <Improbable.Gdk.Tests.ExhaustiveBlittableSingular.Component> >();
                var spatialEntityType = system.GetArchetypeChunkComponentType <SpatialEntityId>();

                var chunkArray = group.CreateArchetypeChunkArray(Allocator.TempJob);

                foreach (var chunk in chunkArray)
                {
                    var authorityArray       = chunk.GetNativeArray(authorityLossType);
                    var spatialEntityIdArray = chunk.GetNativeArray(spatialEntityType);

                    for (int i = 0; i < authorityArray.Length; ++i)
                    {
                        if (authorityArray[i].AcknowledgeAuthorityLoss)
                        {
                            connection.SendAuthorityLossImminentAcknowledgement(spatialEntityIdArray[i].EntityId.Id,
                                                                                197720);
                        }
                    }
                }

                chunkArray.Dispose();
            }
        public void ReceptionistFlow_propagates_my_worker_id()
        {
            var receptionistFlow = new ReceptionistFlow("My-Worker-Id");

            connection = receptionistFlow.CreateAsync(GetConnectionParameters()).Result;

            Assert.AreEqual("My-Worker-Id", connection.GetWorkerId());
        }
Пример #4
0
        public void LocatorFlow_dev_auth_fails_if_no_deployment_running()
        {
            var flow = GetLocatorFlow();

            flow.DevAuthToken = DevAuthTokenUtils.DevAuthToken;
            var aggregateException = Assert.Throws <AggregateException>(() => connection = flow.CreateAsync(GetConnectionParameters()).Result);

            Assert.IsInstanceOf <AuthenticationFailedException>(aggregateException.InnerExceptions[0]);
        }
Пример #5
0
        public void LocatorFlow_dev_auth_fails_if_invalid_dev_auth_token()
        {
            var flow = GetLocatorFlow();

            flow.DevAuthToken = "notvalid";
            var aggregateException = Assert.Throws <AggregateException>(() => connection = flow.CreateAsync(GetConnectionParameters()).Result);

            Assert.IsInstanceOf <AuthenticationFailedException>(aggregateException.InnerExceptions[0]);
        }
Пример #6
0
        public void LocatorFlow_dev_auth_fails_if_depl_isnt_tagged()
        {
            using (spatiald.StartLocalDeployment("test", "default_launch.json").Result)
            {
                var flow = GetLocatorFlow();
                flow.DevAuthToken = DevAuthTokenUtils.DevAuthToken;

                var aggregateException = Assert.Throws <AggregateException>(() => connection = flow.CreateAsync(GetConnectionParameters()).Result);
                Assert.IsInstanceOf <AuthenticationFailedException>(aggregateException.InnerExceptions[0]);
            }
        }
Пример #7
0
        public void LocatorFlow_dev_auth_works_with_tagged_depl()
        {
            using (var depl = spatiald.StartLocalDeployment("test", "default_launch.json").Result)
            {
                depl.AddDevLoginTag().Wait();
                var flow = GetLocatorFlow();
                flow.DevAuthToken = DevAuthTokenUtils.DevAuthToken;

                Assert.DoesNotThrow(() => connection = flow.CreateAsync(GetConnectionParameters()).Result);
                Assert.AreEqual(ConnectionStatusCode.Success, connection.GetConnectionStatusCode());
            }
        }
        public void ReceptionistFlow_fails_to_connection_with_invalid_port()
        {
            var receptionistFlow = new ReceptionistFlow("My-Worker-Id")
            {
                ReceptionistPort = 1337
            };

            var aggregateException = Assert.Throws <AggregateException>(() =>
                                                                        connection = receptionistFlow.CreateAsync(GetConnectionParameters()).Result);

            Assert.IsInstanceOf <ConnectionFailedException>(aggregateException.InnerExceptions[0]);
        }
Пример #9
0
        public void CreateAsync_fails_if_no_matching_deployment()
        {
            using (var depl = spatiald.StartLocalDeployment("a_different_deployment", LaunchConfigName).Result)
            {
                depl.AddDevLoginTag().Wait();

                var flow = GetFlow("target_deployment");
                flow.DevAuthToken = DevAuthTokenUtils.DevAuthToken;

                var aggregateException = Assert.Throws <AggregateException>(() => connection = flow.CreateAsync(GetConnectionParameters()).Result);
                Assert.IsInstanceOf <ArgumentException>(aggregateException.InnerExceptions[0]);
            }
        }
Пример #10
0
        public void CreateAsync_succeeds_if_there_is_matching_deployment()
        {
            using (var depl = spatiald.StartLocalDeployment("target_deployment", LaunchConfigName).Result)
            {
                depl.AddDevLoginTag().Wait();

                var flow = GetFlow("target_deployment");
                flow.DevAuthToken = DevAuthTokenUtils.DevAuthToken;

                Assert.DoesNotThrow(() => connection = flow.CreateAsync(GetConnectionParameters()).Result);
                Assert.AreEqual(ConnectionStatusCode.Success, connection.GetConnectionStatusCode());
            }
        }
Пример #11
0
 public void TearDown()
 {
     connection?.Dispose();
     connection = null;
 }