Exemplo n.º 1
0
        public static int SetUpDefaultRemoteAppApplications(Mock<IRemoteAppManagementClient> clientMock, string collectionName)
        {
            ISetup<IRemoteAppManagementClient, Task<GetPublishedApplicationListResult>> setup = null;

            GetPublishedApplicationListResult response = new GetPublishedApplicationListResult()
            {
                RequestId = "122-13342",
                StatusCode = System.Net.HttpStatusCode.OK
            };

            response.ResultList = new List<PublishedApplicationDetails>()
            {
                new PublishedApplicationDetails()
                {
                    Name = "Mohoro RemoteApp1",
                    Alias = "App1",
                    AvailableToUsers = true,
                    CommandLineArguments = "Arg1, Arg2, Arg3",
                    Status =  AppPublishingStatus.Published
                },

                new PublishedApplicationDetails()
                {
                    Name = "Mohoro RemoteApp2",
                    Alias = "App2",
                    AvailableToUsers = false,
                    Status =  AppPublishingStatus.Publishing
                }
            };

            mockApplicationList = new List<PublishedApplicationDetails>();
            foreach (PublishedApplicationDetails app in response.ResultList)
            {
                PublishedApplicationDetails mockApp = new PublishedApplicationDetails()
                {
                    Name = app.Name,
                    Alias = app.Alias,
                    AvailableToUsers = app.AvailableToUsers,
                    CommandLineArguments = app.CommandLineArguments,
                    Status = app.Status
                };
                mockApplicationList.Add(mockApp);
            }

            setup = clientMock.Setup(c => c.Publishing.ListAsync(collectionName, It.IsAny<CancellationToken>()));
            setup.Returns(Task.Factory.StartNew(() => response));

            return mockApplicationList.Count;
        }
        public void CanPublishModifyUnpublishApps()
        {
            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();

                RemoteAppManagementClient client = GetRemoteAppManagementClient();

                CollectionListResult serviceList = null;
                Assert.DoesNotThrow(() =>
                {
                    serviceList = client.Collections.List();
                });

                Assert.NotNull(serviceList);
                Assert.NotEmpty(serviceList.Collections);

                Collection activeCollection = null;
                ApplicationDetailsListParameter appDetailsList = new ApplicationDetailsListParameter();
                PublishedApplicationDetails publishApp = new PublishedApplicationDetails();
                string publishingAppName = TestUtilities.GenerateName("TestApp");
                string publishingAppAlias = null;
                GetPublishedApplicationResult publishedAppResult = null;

                // Find collection in "Active" state so that publishing operations can be performed
                foreach (Collection ser in serviceList.Collections)
                {
                    if (ser.Status == "Active")
                    {
                        activeCollection = ser;
                        break;
                    }
                }

                Assert.NotNull(activeCollection);

                // Publish an App
                {
                    appDetailsList.DetailsList = new List<PublishedApplicationDetails>();
                    publishApp.AvailableToUsers = true;
                    publishApp.Name = publishingAppName;
                    publishApp.VirtualPath = "%systemroot%\\system32\\notepad.exe";
                    publishApp.IconPngUris = new IconPngUrisType();     // backend throws exception if this is null

                    appDetailsList.DetailsList.Add(publishApp);

                    PublishApplicationsResult publishResult = client.Publishing.PublishApplications(activeCollection.Name, appDetailsList);

                    // Verify for publish operation
                    Assert.NotNull(publishResult);
                    Assert.NotEmpty(publishResult.ResultList);
                    foreach (PublishingOperationResult oneResult in publishResult.ResultList)
                    {
                        Assert.True(oneResult.Success);
                        publishingAppAlias = oneResult.ApplicationAlias;
                        break;
                    }
                }

                // Wait for app status to change to Published
                publishedAppResult = WaitForAppStatus(client, activeCollection.Name, publishingAppAlias, AppPublishingStatus.Published);

                // Modify Published application
                {
                    PublishedApplicationDetails newAppDetails = publishedAppResult.Result;
                    ApplicationDetailsParameter newAppDetailsParam = new ApplicationDetailsParameter();

                    newAppDetails.Name = TestUtilities.GenerateName("ModTestApp");
                    newAppDetailsParam.Details = newAppDetails;

                    ModifyApplicationResult modifiedAppResult = client.Publishing.ModifyApplication(activeCollection.Name, publishingAppAlias, newAppDetailsParam);

                    // Verify Modify app result
                    Assert.NotNull(modifiedAppResult);
                    Assert.NotNull(modifiedAppResult.Result);
                    Assert.True(modifiedAppResult.StatusCode == HttpStatusCode.OK);
                }

                // Wait for app status to change to Published
                publishedAppResult = WaitForAppStatus(client, activeCollection.Name, publishingAppAlias, AppPublishingStatus.Published);

                // Unpublish the application
                {
                    UnpublishApplicationsResult unpublishAppResult = client.Publishing.Unpublish(activeCollection.Name, new AliasesListParameter { AliasesList = { publishingAppAlias } });

                    // Verify unpublish app result
                    Assert.NotNull(unpublishAppResult);
                    Assert.NotEmpty(unpublishAppResult.ResultList);
                    foreach (PublishingOperationResult oneResult in unpublishAppResult.ResultList)
                    {
                        Assert.True(oneResult.Success);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public static bool ContainsExpectedApplication(List<PublishedApplicationDetails> expectedResult, PublishedApplicationDetails actual)
        {
            bool isIdentical = false;

            foreach (PublishedApplicationDetails expected in expectedResult)
            {
                isIdentical = expected.Name == actual.Name;
                isIdentical &= expected.Alias == actual.Alias;
                isIdentical &= expected.AvailableToUsers == actual.AvailableToUsers;
                isIdentical &= expected.Status == actual.Status;

                if (isIdentical)
                {
                    break;
                }
            }

            return isIdentical;
        }