Exemple #1
0
        public void MSASCNTC_S02_TC02_ItemOperations_TruncateBody()
        {
            #region Call Sync command with Add element to add a contact with all Contact class elements to the server
            string picture = "SmallPhoto.jpg";

            Dictionary <Request.ItemsChoiceType8, object> contactProperties = this.SetContactProperties(picture);
            this.AddContact(this.User1Information.ContactsCollectionId, contactProperties);

            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.ContactsCollectionId, contactProperties[Request.ItemsChoiceType8.FileAs].ToString());

            // Get the new added contact
            Sync newAddedItem = this.GetSyncAddResult(contactProperties[Request.ItemsChoiceType8.FileAs].ToString(), this.User1Information.ContactsCollectionId, null, null);
            #endregion

            #region Call ItemOperations command with TruncationSize element smaller than the available data of the body
            Request.BodyPreference bodyPreference = new Request.BodyPreference
            {
                Type                    = 1,
                TruncationSize          = 8,
                TruncationSizeSpecified = true
            };

            ItemOperations item = this.GetItemOperationsResult(this.User1Information.ContactsCollectionId, newAddedItem.ServerId, bodyPreference, null);

            // Assert the body data is truncated.
            Site.Assert.AreEqual <string>(
                ((Request.Body)contactProperties[Request.ItemsChoiceType8.Body]).Data.Substring(0, (int)bodyPreference.TruncationSize),
                item.Contact.Body.Data,
                "The body data should be truncated when the value of TruncationSize element is smaller than the available data size.");
            #endregion
        }
 void CreateItemOperations()
 {
     fakeProjectService = new FakePackageManagementProjectService();
     fakeFileService    = new FakeFileService(null);
     dte            = new DTE(fakeProjectService, fakeFileService);
     itemOperations = dte.ItemOperations;
 }
Exemple #3
0
        public void MSASCNTC_S02_TC01_ItemOperations_RetrieveContact()
        {
            #region Call Sync command with Add element to add a contact with all Contact class elements to the server
            string picture = "SmallPhoto.jpg";

            Dictionary <Request.ItemsChoiceType8, object> contactProperties = this.SetContactProperties(picture);
            this.AddContact(this.User1Information.ContactsCollectionId, contactProperties);

            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.ContactsCollectionId, contactProperties[Request.ItemsChoiceType8.FileAs].ToString());

            // Get the new added contact
            Sync newAddedItem = this.GetSyncAddResult(contactProperties[Request.ItemsChoiceType8.FileAs].ToString(), this.User1Information.ContactsCollectionId, null, null);
            #endregion

            #region Call ItemOperations command to retrieve the contact item that added in previous step
            Request.BodyPreference bodyPreference = new Request.BodyPreference {
                Type = 1
            };

            ItemOperations itemOperationsItem = this.GetItemOperationsResult(this.User1Information.ContactsCollectionId, newAddedItem.ServerId, bodyPreference, null);
            #endregion

            #region Verify requirements
            this.VerifyContactClassElements(contactProperties, itemOperationsItem.Contact);
            #endregion
        }
Exemple #4
0
        protected void Item_Drop(object sender, DragEventArgs e)
        {
            var deferral = e.GetDeferral();

            e.Handled = true;
            ListedItem rowItem = GetItemFromElement(sender);

            ItemOperations.PasteItemWithStatus(e.DataView, (rowItem as ShortcutItem)?.TargetPath ?? rowItem.ItemPath, e.AcceptedOperation);
            deferral.Complete();
        }
Exemple #5
0
        protected void List_Drop(object sender, DragEventArgs e)
        {
            var deferral = e.GetDeferral();

            if (e.DataView.Contains(StandardDataFormats.StorageItems))
            {
                ItemOperations.PasteItemWithStatus(e.DataView, App.CurrentInstance.FilesystemViewModel.WorkingDirectory, e.AcceptedOperation);
                e.Handled = true;
            }

            deferral.Complete();
        }
Exemple #6
0
        public void TestAddNewTodoItem()
        {
            // given
            var newItem = new TodoRequest("yoga", false);

            // when
            TodoClients.PostNewTodoItem(newItem);
            // then
            List <TodoResponseItem> resultList = TodoClients.GetAllTodos();

            Assert.True(ItemOperations.todoContains(newItem.Name, newItem.IsComplete, resultList));
        }
Exemple #7
0
        private void PathBoxItem_Drop(object sender, DragEventArgs e)
        {
            if (!((sender as Grid).DataContext is PathBoxItem pathBoxItem) ||
                pathBoxItem.Path == "Home" || pathBoxItem.Path == ResourceController.GetTranslation("NewTab"))
            {
                return;
            }

            var deferral = e.GetDeferral();

            ItemOperations.PasteItemWithStatus(e.DataView, pathBoxItem.Path, e.AcceptedOperation);
            deferral.Complete();
        }
Exemple #8
0
        private void NavigationViewDriveItem_Drop(object sender, DragEventArgs e)
        {
            if (!((sender as Microsoft.UI.Xaml.Controls.NavigationViewItem).DataContext is DriveItem driveItem))
            {
                return;
            }

            VisualStateManager.GoToState(sender as Microsoft.UI.Xaml.Controls.NavigationViewItem, "Drop", false);

            var deferral = e.GetDeferral();

            ItemOperations.PasteItemWithStatus(e.DataView, driveItem.Path, e.AcceptedOperation);
            deferral.Complete();
        }
Exemple #9
0
        private void NavigationViewLocationItem_Drop(object sender, DragEventArgs e)
        {
            if (!((sender as Microsoft.UI.Xaml.Controls.NavigationViewItem).DataContext is LocationItem locationItem))
            {
                return;
            }

            // If the dropped item is a folder or file from a file system
            if (e.DataView.Contains(StandardDataFormats.StorageItems))
            {
                VisualStateManager.GoToState(sender as Microsoft.UI.Xaml.Controls.NavigationViewItem, "Drop", false);

                var deferral = e.GetDeferral();
                ItemOperations.PasteItemWithStatus(e.DataView, locationItem.Path, e.AcceptedOperation);
                deferral.Complete();
            }
            else if ((e.DataView.Properties["sourceLocationItem"] as Microsoft.UI.Xaml.Controls.NavigationViewItem).DataContext is LocationItem sourceLocationItem)
            {
                // Else if the dropped item is a location item

                // Swap the two items
                SidebarPinnedModel.SwapItems(sourceLocationItem, locationItem);
            }
        }
Exemple #10
0
        public void MSASTASK_S02_TC01_RetrieveTaskItemWithItemOperations()
        {
            #region Call Sync command to create a task item

            Dictionary <Request.ItemsChoiceType8, object> taskItem = new Dictionary <Request.ItemsChoiceType8, object>();
            string subject = Common.GenerateResourceName(Site, "subject");
            taskItem.Add(Request.ItemsChoiceType8.Subject2, subject);

            #endregion

            #region Call Sync command to add the task to the server

            // add task
            SyncStore syncResponse = this.SyncAddTask(taskItem);
            Site.Assert.AreEqual <int>(1, int.Parse(syncResponse.AddResponses[0].Status), "Adding a task item to server should success.");
            SyncItem task = this.GetChangeItem(this.UserInformation.TasksCollectionId, subject);
            Site.Assert.IsNotNull(task.Task, "The task which subject is {0} should exist in server.", subject);
            ItemsNeedToDelete.Add(subject);

            #endregion

            #region Call ItemOperations command to fetch tasks

            syncResponse = this.SyncChanges(this.UserInformation.TasksCollectionId);

            List <string> serverIds = new List <string>();
            for (int i = 0; i < syncResponse.AddElements.Count; i++)
            {
                serverIds.Add(syncResponse.AddElements[i].ServerId);
            }

            Request.Schema schema = new Request.Schema
            {
                ItemsElementName = new Request.ItemsChoiceType4[1],
                Items            = new object[1]
            };
            schema.ItemsElementName[0] = Request.ItemsChoiceType4.Body;
            schema.Items[0]            = new Request.Body();

            Request.BodyPreference bodyReference = new Request.BodyPreference {
                Type = 1
            };

            ItemOperationsRequest itemOperationsRequest  = TestSuiteHelper.CreateItemOperationsFetchRequest(this.UserInformation.TasksCollectionId, serverIds, null, bodyReference, schema);
            ItemOperationsStore   itemOperationsResponse = this.TASKAdapter.ItemOperations(itemOperationsRequest);
            Site.Assert.AreEqual <string>("1", itemOperationsResponse.Status, "The ItemOperations response should be successful.");

            #endregion

            // Get task item that created in this case.
            ItemOperations taskReturnedInItemOperations = null;
            foreach (ItemOperations item in itemOperationsResponse.Items)
            {
                if (task.Task.Body.Data.ToString().Contains(item.Task.Body.Data))
                {
                    taskReturnedInItemOperations = item;
                }
            }

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R356");

            // Verify MS-ASTASK requirement: MS-ASTASK_R356
            // If the Task item in response is not null, this requirement will be captured.
            Site.CaptureRequirementIfIsNotNull(
                taskReturnedInItemOperations.Task,
                356,
                @"[In ItemOperations Command Response] When a client uses an ItemOperations command request ([MS-ASCMD] section 2.2.2.8) to retrieve data from the server for one or more specific Task items, as specified in section 3.1.5.1, the server responds with an ItemOperations command response ([MS-ASCMD] section 2.2.2.8).");

            bool otherPropertiesNull = true;

            // Loop to verify if other properties except "Body" are not returned.
            foreach (System.Reflection.PropertyInfo propertyInfo in typeof(Task).GetProperties())
            {
                if (propertyInfo.Name != "Body")
                {
                    object value = propertyInfo.GetValue(taskReturnedInItemOperations.Task, null);
                    if (value != null)
                    {
                        otherPropertiesNull = false;
                        break;
                    }
                }
            }

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R358");

            // Verify MS-ASTASK requirement: MS-ASTASK_R358
            // If the body of the Task item in response is not null, this requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                otherPropertiesNull,
                358,
                @"[In ItemOperations Command Response] If an itemoperations:Schema element ([MS-ASCMD] section 2.2.3.135) is included in the ItemOperations command request, then the elements returned in the ItemOperations command response MUST be restricted to the elements that were included as child elements of the itemoperations:Schema element in the command request.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R359");

            // Since MS-ASTASK_R358 is captured, this requirement can be captured.
            Site.CaptureRequirement(
                359,
                @"[In ItemOperations Command Response] Top-level Task class elements, as specified in section 2.2, MUST be returned as child elements of the itemoperations:Properties element ([MS-ASCMD] section 2.2.3.128) in the ItemOperations command response.");
        }
        public void MSASRM_S02_TC01_ItemOperations_RightsManagedEmailMessages()
        {
            this.CheckPreconditions();

            #region The client logs on User1's account, calls Settings command to get a templateID with all rights allowed.
            string templateID = this.GetTemplateID("MSASRM_AllRights_AllowedTemplate");
            #endregion

            #region The client logs on User1's account, calls SendMail command with the templateID to send a rights-managed e-mail message to User2, switches to User2, and calls FolderSync command.
            string subject = this.SendMailAndFolderSync(templateID, false, null);
            #endregion

            #region The client logs on User2's account, calls Sync command with RightsManagementSupport element set to true to synchronize changes of Inbox folder in User2's mailbox, and gets the decompressed and decrypted rights-managed e-mail message.
            Sync item = this.SyncEmail(subject, this.UserTwoInformation.InboxCollectionId, true, true);
            Site.Assert.IsNotNull(item, "The returned item should not be null.");
            Site.Assert.IsNull(item.Email.Attachments, "The Attachments element in expected rights-managed e-mail message should be null.");
            Site.Assert.IsNotNull(item.Email.RightsManagementLicense, "The RightsManagementLicense element in expected rights-managed e-mail message should not be null.");
            Site.Assert.IsTrue(item.Email.RightsManagementLicense.ExportAllowed, "The ExportAllowed element in expected rights-managed e-mail message should be true.");
            #endregion

            #region The client logs on User2's account, calls ItemOperations command which contains the Fetch element without RemoveRightsManagementProtection element.
            Request.ItemOperationsFetch fetch = new Request.ItemOperationsFetch
            {
                CollectionId = this.UserTwoInformation.InboxCollectionId,
                Store        = SearchName.Mailbox.ToString(),
                ServerId     = item.ServerId,
                Options      = new Request.ItemOperationsFetchOptions
                {
                    Items            = new object[] { true },
                    ItemsElementName = new Request.ItemsChoiceType5[] { Request.ItemsChoiceType5.RightsManagementSupport }
                }
            };
            ItemOperationsRequest itemOperationsRequest = Common.CreateItemOperationsRequest(new object[] { fetch });
            ItemOperationsStore   itemOperationsStore   = this.ASRMAdapter.ItemOperations(itemOperationsRequest);
            Site.Assert.AreEqual <int>(1, itemOperationsStore.Items.Count, "There should be only 1 item fetched in ItemOperations command response.");
            ItemOperations itemOperations = itemOperationsStore.Items[0];
            Site.Assert.IsNotNull(itemOperations, "The returned item should not be null.");
            Site.Assert.IsNotNull(itemOperations.Email, "The expected rights-managed e-mail message should not be null.");
            Site.Assert.IsNull(itemOperations.Email.Attachments, "The Attachments element in expected rights-managed e-mail message should be null.");
            Site.Assert.IsNotNull(itemOperations.Email.RightsManagementLicense, "The RightsManagementLicense element in expected rights-managed e-mail message should not be null.");
            #endregion

            #region The client logs on User2's account, calls ItemOperations command which contains the Fetch element with RemoveRightsManagementProtection element.
            fetch.RemoveRightsManagementProtection = string.Empty;
            itemOperationsRequest = Common.CreateItemOperationsRequest(new object[] { fetch });
            itemOperationsStore   = this.ASRMAdapter.ItemOperations(itemOperationsRequest);
            Site.Assert.AreEqual <int>(1, itemOperationsStore.Items.Count, "There should be only 1 item fetched in ItemOperations command response.");
            itemOperations = itemOperationsStore.Items[0];
            Site.Assert.IsNotNull(itemOperations, "The returned item should not be null.");
            Site.Assert.IsNotNull(itemOperations.Email, "The expected rights-managed e-mail message should not be null.");
            Site.Assert.IsNull(itemOperations.Email.Attachments, "The Attachments element in expected rights-managed e-mail message should be null.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASRM_R91");

            // Verify MS-ASRM requirement: MS-ASRM_R91
            // If the response contains RightsManagementLicense element as null, represents the rights management protection is removed from the e-mail.
            Site.CaptureRequirementIfIsNull(
                itemOperations.Email.RightsManagementLicense,
                91,
                @"[In RemoveRightsManagementProtection] If present, it[RemoveRightsManagementProtection] indicates that the client is removing the IRM protection from the e-mail.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASRM_R94");

            // Verify MS-ASRM requirement: MS-ASRM_R94
            // If the response contains RightsManagementLicense element as null, represents the rights management protection is removed from the e-mail.
            Site.CaptureRequirementIfIsNull(
                itemOperations.Email.RightsManagementLicense,
                94,
                @"[In RemoveRightsManagementProtection] IRM protection can only be removed from e-mail messages when the ExportAllowed element is set to TRUE.");
            #endregion
        }
Exemple #12
0
 public TodoListTest()
 {
     ItemOperations.DeleteAllItems();
 }