Exemplo n.º 1
0
        public void CanGetById()
        {
            SPWeb      web  = RecorderManager.CreateMockedObject <SPWeb>();
            SPListItem item = this.RecordGetReturnSPListItem();
            RegistrationApprovalTask registrationApprovalTask = new RegistrationApprovalTask();

            MockListItemRepository.SPListItemReturnedByGet = item;
            serviceLocator.Register <IListItemRepository>(typeof(MockListItemRepository));
            RegistrationApprovalTaskRepository registrationApprovalTaskRepository = new RegistrationApprovalTaskRepository();

            registrationApprovalTask = registrationApprovalTaskRepository.Get(1, web);

            Assert.IsNotNull(registrationApprovalTask);
            Assert.AreEqual <int>(1, registrationApprovalTask.Id);
            Assert.AreEqual <string>("TestTitle", registrationApprovalTask.Title);
            Assert.AreEqual <int>(5, registrationApprovalTask.WorkflowItemId);
            MockManager.Verify();
        }
        public void Update_IdAndItemIsValid_ItemUpdated()
        {
            using (SPSite site = new SPSite(siteUrl))
            {
                using (SPWeb web = site.AllWebs[webId])
                {
                    #region Arrange

                    RegistrationApprovalTask taskAdded = new RegistrationApprovalTask();
                    taskAdded.Title          = "TestTitle";
                    taskAdded.WorkflowItemId = 5;
                    RegistrationApprovalTaskRepository target = new RegistrationApprovalTaskRepository();
                    int taskAddedId = target.Add(taskAdded, web);

                    #endregion

                    #region Act

                    taskAdded.Id             = taskAddedId;
                    taskAdded.Title          = "NewTitle";
                    taskAdded.WorkflowItemId = 6;
                    target.Update(taskAdded, web);

                    #endregion

                    #region Assert

                    RegistrationApprovalTask taskFound = target.Get(taskAddedId, web);
                    Assert.AreEqual("NewTitle", taskFound.Title);
                    Assert.AreEqual(6, taskFound.WorkflowItemId);

                    #endregion

                    #region Cleanup

                    target.Delete(taskAddedId, web);

                    #endregion
                }
            }
        }