コード例 #1
0
        public void ShouldCreateSystemAppApi()
        {
            // Arrange
            HttpHeaders     headers = new HttpHeaders();
            IServiceFactory factory = new ServiceFactory(Mock.Of <IHttpAddress>(), Mock.Of <IHttpFacade>(), Mock.Of <IContentSerializer>(), headers);

            // Act
            ISystemAppApi api = factory.CreateSystemAppApi();

            // Assert
            api.ShouldNotBe(null);
        }
コード例 #2
0
        public async Task RunAsync(IRestContext context)
        {
            ISystemAppApi appApi = context.Factory.CreateSystemAppApi();

            // Read
            SqlQuery query = new SqlQuery {
                Fields  = "*",
                Related = String.Join(",", RelatedResources.App.StorageService, RelatedResources.App.Roles)
            };
            IEnumerable <AppResponse> apps = (await appApi.GetAppsAsync(query)).ToList();

            Console.WriteLine("Apps:");
            foreach (AppResponse app in apps)
            {
                Console.WriteLine("\tName: {0}, ApiKey: {1}", app.Name, app.ApiKey);
            }

            // Cloning
            AppResponse adminApp        = apps.Single(x => x.Name == "admin");
            AppRequest  adminAppRequest = adminApp.Convert <AppResponse, AppRequest>();

            adminAppRequest.Id   = null;
            adminAppRequest.Name = adminApp.Name + "clone";

            // Creating a clone
            apps = await appApi.CreateAppsAsync(new SqlQuery(), adminAppRequest);

            AppResponse adminAppClone = apps.Single(x => x.Name == "adminclone");

            Console.WriteLine("Created a clone app Name:{0}, ApiKey:{1}", adminAppClone.Name, adminAppClone.ApiKey);

            // Deleting the clone
            Debug.Assert(adminAppClone.Id.HasValue);
            await appApi.DeleteAppsAsync(new SqlQuery(), adminAppClone.Id.Value);

            Console.WriteLine("Created clone has been deleted");
        }