Пример #1
0
        public void EnsureSingleDoesntDuplicate()
        {
            ServiceRegistry glooRegistry           = ApplicationServiceRegistryContainer.GetServiceRegistry();
            ApplicationRegistrationRepository repo = glooRegistry.Get <ApplicationRegistrationRepository>();
            CompositeRepository compositeRepo      = glooRegistry.Get <CompositeRepository>();

            compositeRepo.UnwireBackup();
            Machine machine = Machine.Current;

            repo.Delete(machine);
            Machine retrieved = repo.Query <Machine>(Filter.Where("Name") == machine.Name && Filter.Where("Cuid") == machine.Cuid).FirstOrDefault();

            if (retrieved != null)
            {
                repo.Delete(retrieved);
            }
            retrieved = repo.Query <Machine>(Filter.Where("Name") == machine.Name && Filter.Where("Cuid") == machine.Cuid).FirstOrDefault();
            Expect.IsNull(retrieved);
            Machine ensured = machine.EnsureSingle <Machine>(repo, "Test UserName of modifier", "Cuid");

            Expect.IsNotNull(ensured, "Ensured was null");
            Machine ensuredAgain = ensured.EnsureSingle <Machine>(repo, "Test UserName of modifier", "Cuid");

            Expect.AreEqual(ensured.Id, ensuredAgain.Id);
            Expect.AreEqual(ensured.Uuid, ensuredAgain.Uuid);
            Expect.AreEqual(ensured.Cuid, ensuredAgain.Cuid);

            Expect.AreEqual(1, repo.Query <Machine>(new { Name = machine.Name, Cuid = machine.Cuid }).Count());
            repo.Delete(machine);
        }
Пример #2
0
        private ApplicationRegistrationService GetTestService()
        {
            ServiceRegistry registry           = ApplicationServiceRegistryContainer.GetServiceRegistry();
            ApplicationRegistrationService svc = registry.Get <ApplicationRegistrationService>();

            registry.SetProperties(svc);
            return(svc);
        }
Пример #3
0
 private void SetLocalProperties(string organizationName, string applicationName, string hostName, int port)
 {
     LocalCoreRegistryRepository = new ApplicationRegistrationRepository()
     {
         Database = new SQLiteDatabase(WorkspaceDirectory, nameof(CoreClient))
     };
     ApplicationServiceRegistryContainer.GetServiceRegistry().Get <IStorableTypesProvider>().AddTypes(LocalCoreRegistryRepository);
     ProcessDescriptor = ProcessDescriptor.ForApplicationRegistration(LocalCoreRegistryRepository, hostName, port, applicationName, organizationName);
 }
Пример #4
0
        public void CanSaveMachineInCoreRegistryRepo()
        {
            ApplicationRegistrationRepository repo = ApplicationServiceRegistryContainer.GetServiceRegistry().Get <ApplicationRegistrationRepository>();
            Client test = Client.Of(repo, "test", "test", 80);//Machine.ClientOf(repo, "test", 80);

            test = repo.Save(test);
            Expect.IsTrue(test.Id > 0);
            Client test2 = Client.Of(repo, "test", "test", 80);//Machine.ClientOf(repo, "test", 90);

            test2 = repo.Save(test2);
            Expect.IsTrue(test2.Id > 0);
        }
Пример #5
0
        public void CanSaveUserToCompositeRepo()
        {
            CompositeRepository repo = ApplicationServiceRegistryContainer.GetServiceRegistry().Get <CompositeRepository>();

            ApplicationRegistration.Data.User user = new ApplicationRegistration.Data.User();
            user.UserName = 9.RandomLetters();
            user          = repo.Save(user);
            ApplicationRegistration.Data.User retrieved = repo.Retrieve <ApplicationRegistration.Data.User>(user.Uuid);
            Expect.AreEqual(user.UserName, retrieved.UserName);
            Expect.AreEqual(user.Id, retrieved.Id);
            Expect.AreEqual(user.Uuid, retrieved.Uuid);
        }
Пример #6
0
        public void WhoAmITest()
        {
            //OutLineFormat("This test requires a gloo server to be running on port 9100 of the localhost", ConsoleColor.Yellow);
            ConsoleLogger logger = new ConsoleLogger()
            {
                AddDetails = false
            };
            const string server = "localhost";// "int-heart.bamapps.net";
            const int    port   = 80;

            logger.StartLoggingThread();
            ApplicationRegistrationRepository repo = ApplicationServiceRegistryContainer.GetServiceRegistry().Get <ApplicationRegistrationRepository>();
            CoreClient client = new CoreClient("TestOrg", "TestApp", server, port, logger)
            {
                UseServiceSubdomains        = false,
                LocalCoreRegistryRepository = repo
            };

            client.InvocationException += (o, args) => logger.AddEntry("Invocation Exception: {0}", ((ServiceProxyInvokeEventArgs)args).Exception, args.PropertiesToString());
            client.MethodInvoked       += (o, args) => logger.AddEntry("ProxyClient Method Invoked: {0}", args.PropertiesToString());

            CoreServiceResponse registrationResponse = client.RegisterClient();
            Client current = Client.Of(client.LocalCoreRegistryRepository, client.ApplicationName, server, port);

            CoreServiceResponse response = client.Connect();

            string whoAmI = client.UserRegistryService.WhoAmI();

            Expect.AreEqual(current.ToString(), whoAmI);

            whoAmI = client.ApplicationRegistryService.WhoAmI();
            Expect.AreEqual(current.ToString(), whoAmI);

            whoAmI = client.ConfigurationService.WhoAmI();
            Expect.AreEqual(current.ToString(), whoAmI);

            whoAmI = client.LoggerService.WhoAmI();
            Expect.AreEqual(current.ToString(), whoAmI);

            whoAmI = client.DiagnosticService.WhoAmI();
            Expect.AreEqual(current.ToString(), whoAmI);

            Pass($"You are {whoAmI}");
        }
Пример #7
0
        public void RegisterCreatesMachineEntry()
        {
            OutLineFormat("This test requires a gloo server to be running on port 9100 of the localhost", ConsoleColor.Yellow);
            ConsoleLogger logger = new ConsoleLogger()
            {
                AddDetails = false
            };

            logger.StartLoggingThread();
            ApplicationRegistrationRepository repo = ApplicationServiceRegistryContainer.GetServiceRegistry().Get <ApplicationRegistrationRepository>();
            CoreClient client = CoreClient.Local;//new CoreClient("TestOrg", "TestApp", $".\\{nameof(RegisterCreatesMachineEntry)}", logger);

            client.WorkspaceDirectory          = $".\\{nameof(RegisterCreatesMachineEntry)}";
            client.LocalCoreRegistryRepository = repo;
            CoreServiceResponse registrationResponse = client.RegisterClient();
            Machine             machine = repo.OneMachineWhere(m => m.Name == Machine.Current.Name);

            Expect.IsNotNull(machine);
            Pass(nameof(RegisterCreatesMachineEntry));
        }
Пример #8
0
        public void CoreClientCanRegisterAndConnectClient()
        {
            OutLineFormat("This test requires a gloo server to be running on port 9100 of the localhost", ConsoleColor.Yellow);
            ApplicationRegistrationRepository repo = ApplicationServiceRegistryContainer.GetServiceRegistry().Get <ApplicationRegistrationRepository>();
            ConsoleLogger logger = new ConsoleLogger()
            {
                AddDetails = false
            };

            logger.StartLoggingThread();
            CoreClient client = new CoreClient("ThreeHeadz", "CoreServicesTestApp", "localhost", 9100, logger);

            client.LocalCoreRegistryRepository = repo;
            CoreServiceResponse registrationResponse = client.RegisterClient();

            Expect.IsTrue(registrationResponse.Success, registrationResponse.Message);
            CoreServiceResponse        response  = client.Connect();
            List <CoreServiceResponse> responses = response.Data.FromJObject <List <CoreServiceResponse> >();

            Expect.IsTrue(response.Success, string.Join("\r\n", responses.Select(r => r.Message).ToArray()));
        }
Пример #9
0
 public void MustBeLoggedInToRegister()
 {
     After.Setup((Action <SetupContext>)(ctx =>
     {
         ctx.CopyFrom((Incubation.Incubator)ApplicationServiceRegistryContainer.GetServiceRegistry());
     }))
     .WhenA <ApplicationRegistrationService>("tries to register application when not logged in", cars =>
     {
         ProcessDescriptor descriptor = ProcessDescriptor.ForApplicationRegistration(cars.ApplicationRegistrationRepository, "localhost", 8080, "testApp", "testOrg");
         return(cars.RegisterApplicationProcess(descriptor));
     })
     .TheTest
     .ShouldPass(because =>
     {
         CoreServiceResponse result = because.ResultAs <CoreServiceResponse>();
         because.ItsTrue("the response was not successful", !result.Success, "request should have failed");
         because.ItsTrue("the message says 'You must be logged in to do that'", result.Message.Equals("You must be logged in to do that"));
         because.IllLookAtIt(result.Message);
     })
     .SoBeHappy()
     .UnlessItFailed();
 }
        private static T GetService <T>()
        {
            ServiceRegistry svcRegistry = ApplicationServiceRegistryContainer.GetServiceRegistry();

            return(svcRegistry.Get <T>());
        }