public void CoreApplicationRegistryServiceMustBeLoggedInToRegister()
        {
            ApplicationRegistryService svc = GetTestService();
            string              orgName    = 5.RandomLetters();
            string              appName    = 8.RandomLetters();
            ProcessDescriptor   descriptor = ProcessDescriptor.ForApplicationRegistration(svc.ApplicationRegistrationRepository, "localhost", 8080, appName, orgName);
            CoreServiceResponse response   = svc.RegisterApplicationProcess(descriptor);

            Expect.IsFalse(response.Success);
            Expect.IsNotNull(response.Data);
            Expect.IsInstanceOfType <ApplicationRegistrationResult>(response.Data);
            Expect.AreEqual(ApplicationRegistrationStatus.Unauthorized, ((ApplicationRegistrationResult)response.Data).Status);
        }
        public void OrganizationGetsCreated()
        {
            Log.Default = new ConsoleLogger();
            Log.Default.StartLoggingThread();
            string userName = 4.RandomLetters();
            string orgName  = 5.RandomLetters();
            string appName  = 8.RandomLetters();
            ApplicationRegistryService svc        = GetTestServiceWithUser(userName);
            ProcessDescriptor          descriptor = ProcessDescriptor.ForApplicationRegistration(svc.ApplicationRegistrationRepository, "localhost", 8080, appName, orgName);
            CoreServiceResponse        response   = svc.RegisterApplicationProcess(descriptor);

            Expect.IsTrue(response.Success);
            var user = svc.ApplicationRegistrationRepository.OneUserWhere(c => c.UserName == userName);

            user = svc.ApplicationRegistrationRepository.Retrieve <ApplicationRegistration.Data.User>(user.Id);
            Expect.IsNotNull(user);
            Expect.AreEqual(1, user.Organizations.Count);
            Thread.Sleep(1000);
            Pass($"{nameof(OrganizationGetsCreated)} Test Passed");
        }
 public void MustBeLoggedInToRegister()
 {
     After.Setup(setupContext =>
     {
         setupContext.CopyFrom((CoreServiceRegistryContainer.GetServiceRegistry()));
     })
     .WhenA <ApplicationRegistryService>("tries to register application when not logged in", applicationRegistryService =>
     {
         ProcessDescriptor descriptor = ProcessDescriptor.ForApplicationRegistration(applicationRegistryService.ApplicationRegistrationRepository, "localhost", 8080, "testApp", "testOrg");
         return(applicationRegistryService.RegisterApplicationProcess(descriptor));
     })
     .TheTest
     .ShouldPass((because, objectUnderTest) =>
     {
         because.ItsTrue($"object under test is of type {nameof(ApplicationRegistryService)}", objectUnderTest.GetType() == typeof(ApplicationRegistryService));
         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();
 }