public void MSVIEWSS_S01_TC01_AddView_Success()
        {
            // Call AddView method to add a list view with valid parameters.
            string listName = TestSuiteBase.ListGUID;
            string displayName = this.GenerateRandomString(5);

            AddViewViewFields viewFields = new AddViewViewFields();
            viewFields.ViewFields = this.GetViewFields(true);

            AddViewQuery addViewQuery = new AddViewQuery();
            addViewQuery.Query = this.GetCamlQueryRootForWhere(false);

            AddViewRowLimit rowLimit = new AddViewRowLimit();
            rowLimit.RowLimit = this.GetAvailableRowLimitDefinition();

            string type = ViewType.Grid.ToString();

            AddViewResponseAddViewResult addViewResponseAddViewResult = Adapter.AddView(listName, displayName, viewFields, addViewQuery, rowLimit, type, false);
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult, "The added view should be got successfully.");
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View, "The server should return a View element that specifies the list view when the AddView method is successful!");

            //Verify MS-VIEWSS:MS-VIEWSS_R8014 and MS-VIEWSS_R8005001
            if (Common.IsRequirementEnabled(8014,this.Site))
            {
            Site.CaptureRequirementIfAreEqual(
                ">",
                addViewResponseAddViewResult.View.Text[0],
                8014,
                @"[In Appendix B: Product Behavior] Implementation does append ""&gt;"" after the View element. <2> Section 3.1.4.1.2.3:  SharePoint Foundation 2010  appends ""&gt;"" after the View element. (SharePoint Foundation 2010 follows this behavoir.)"); 
            }
            if (Common.IsRequirementEnabled(8005001, this.Site))
            {
                Site.CaptureRequirementIfIsNull(
                    addViewResponseAddViewResult.View.Text,
                    8005001,
                    @"[In Appendix B: Product Behavior] Implementation does not append ""&gt;"" after the View element. (SharePoint Foundation 2013 and above follow this behavior. )");
            }
            // Put the newly added view into ViewPool. 
            string viewName = addViewResponseAddViewResult.View.Name;
            TestSuiteBase.ViewPool.Add(viewName);

            // Call GetView method to get the list view created above.
            GetViewResponseGetViewResult getView = Adapter.GetView(listName, viewName);
            this.Site.Assert.IsNotNull(getView, "The created list view should be got successfully.");
            this.Site.Assert.IsNotNull(getView.View, "The response element \"getView.View\" should not be null.");
            this.Site.Assert.IsNotNull(getView.View.DisplayName, "The response element \"getView.View.DisplayName\" should not be null.");
            this.Site.Assert.AreEqual(displayName, getView.View.DisplayName, "The list view added in the step above should be got successfully!");

            // If the protocol server creates list view successfully include the resulting View element, then the following requirement can be captured.
            Site.CaptureRequirementIfIsNotNull(
                addViewResponseAddViewResult.View,
                102,
                @"[In AddViewResponse] It[The protocol server] MUST create the list view, and include the resulting View element when the operation succeeds.");
        }
        /// <summary>
        /// This operation is used to create a list view for the specified list.
        /// </summary>
        /// <param name="listName">Specify a list on the server.</param>
        /// <param name="viewName">Specify a list view on the server.</param>
        /// <param name="viewFields">Specify the fields included in a list view.</param>
        /// <param name="query">Include the information that affects how a list view displays the data.</param>
        /// <param name="rowLimit">Specify whether a list supports displaying items page-by-page, and the count of items a list view displays per page.</param>
        /// <param name="type">Specify the type of a list view.</param>
        /// <param name="makeViewDefault">Specify whether to make the list view the default list view for the specified list.</param>
        /// <returns>The result returns a list view that the type is BriefViewDefinition, if the operation succeeds.</returns>
        public AddViewResponseAddViewResult AddView(
            string listName,
            string viewName,
            AddViewViewFields viewFields,
            AddViewQuery query,
            AddViewRowLimit rowLimit,
            string type,
            bool makeViewDefault)
        {
            AddViewResponseAddViewResult addViewResult;

            try
            {
                addViewResult = this.viewssProxy.AddView(
                    listName,
                    viewName,
                    viewFields,
                    query,
                    rowLimit,
                    type,
                    makeViewDefault);

                // Used to validate the transport requirements.
                this.CaptureTransportRelatedRequirements();

                // Used to validate AddViewResult schema requirements.
                this.ValidateAddViewResult(addViewResult);
            }
            catch (SoapException soapException)
            {
                this.Site.Log.Add(
                    LogEntryKind.Debug,
                    @"There is an exception generated when calling [AddView] method:\r\n{0}",
                    soapException.Detail.InnerXml);

                // Used to validate the transport requirements.
                this.CaptureTransportRelatedRequirements();

                // Used to validate the schema of SoapFault.
                this.ValidateSOAPFaultDetails(soapException.Detail);

                throw;
            }

            return(addViewResult);
        }
        /// <summary>
        /// Add a view to the list.
        /// </summary>
        /// <param name="isDefault">Represents whether this view is a default view.</param>
        /// <param name="queryType">Represents the type of query condition of the view.</param>
        /// <param name="viewType">Represents the type of the view to be created.</param>
        /// <returns>The GUID of the view, which is also called the view name.</returns>
        protected string AddView(bool isDefault, Query queryType, ViewType viewType)
        {
            string listName = TestSuiteBase.ListGUID;

            string viewName = this.GenerateRandomString(5);

            AddViewViewFields viewFields = new AddViewViewFields();
            viewFields.ViewFields = this.GetViewFields(true);

            AddViewQuery addViewQuery = new AddViewQuery();
            addViewQuery.Query = this.GetCamlQueryRoot(queryType, false);

            AddViewRowLimit rowLimit = new AddViewRowLimit();
            rowLimit.RowLimit = this.GetAvailableRowLimitDefinition();

            string type = string.Empty;
            switch (viewType)
            {
                case ViewType.Calendar:
                    type = "Calendar";
                    break;
                case ViewType.Grid:
                    type = "Grid";
                    break;
                case ViewType.Html:
                    type = "Html";
                    break;
                default:
                    Site.Debug.Fail("Not supported view type {0}", viewType.ToString());
                    break;
            }

            AddViewResponseAddViewResult addViewResponseAddViewResult = TestSuiteBase.Adapter.AddView(
                                                                                          listName,
                                                                                          viewName,
                                                                                          viewFields,
                                                                                          addViewQuery,
                                                                                          rowLimit,
                                                                                          type,
                                                                                          isDefault);

            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View, "The call of the AddView operation SHOULD be successful.");

            string viewGUID = addViewResponseAddViewResult.View.Name;
            
            if (isDefault)
            {
                this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View.DefaultView, "The response element \"addViewResponseAddViewResult.View.DefaultView\" should not be null.");
                this.Site.Assert.AreEqual("true", addViewResponseAddViewResult.View.DefaultView.ToLower(), "The added view should be a default view.");

                // If the new default view is added successfully, the original default view lost its default view position.
                if (OriginalDefaultViewName != null)
                {
                    if (TestSuiteBase.OriginalDefaultViewLost == false)
                    {
                        TestSuiteBase.OriginalDefaultViewLost = true;
                    }
                }
            }

            TestSuiteBase.ViewPool.Add(viewGUID);
            return addViewResponseAddViewResult.View.Name;
        }
        public void MSVIEWSS_S01_TC02_AddView_EmptyViewFields()
        {
            // Call AddView method to add a list view with an empty viewFields.
            string listName = TestSuiteBase.ListGUID;
            string displayName = this.GenerateRandomString(5);

            AddViewViewFields viewFields = new AddViewViewFields();

            AddViewQuery addViewQuery = new AddViewQuery();
            addViewQuery.Query = this.GetCamlQueryRootForWhere(false);

            AddViewRowLimit rowLimit = new AddViewRowLimit();
            rowLimit.RowLimit = this.GetAvailableRowLimitDefinition();

            string type = ViewType.Html.ToString();

            AddViewResponseAddViewResult addViewResponseAddViewResult = Adapter.AddView(listName, displayName, viewFields, addViewQuery, rowLimit, type, false);
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult, "The added view should be got successfully.");
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View, "The server should return a View element that specifies the list view when the AddView method is successful!");

            // Put the newly added view into ViewPool.
            string viewName = addViewResponseAddViewResult.View.Name;
            TestSuiteBase.ViewPool.Add(viewName);

            // Call GetView method to get the list view created above.
            GetViewResponseGetViewResult getView = Adapter.GetView(listName, viewName);
            this.Site.Assert.IsNotNull(getView, "The created list view should be got successfully.");
            this.Site.Assert.IsNotNull(getView.View, "The response element \"getView.View\" should not be null.");
            this.Site.Assert.IsNotNull(getView.View.DisplayName, "The response element \"getView.View.DisplayName\" should not be null.");
            this.Site.Assert.AreEqual(displayName, getView.View.DisplayName, "The list view added in the step above should be got successfully!");            

            // If the protocol server creates list view with no fields included when the value of the viewFields element is empty, then the following requirement can be captured.
            Site.CaptureRequirementIfAreEqual(
                0,
                addViewResponseAddViewResult.View.ViewFields.Length,
                93,
                @"[In AddView] When the value of the viewFields element is empty, the protocol server MUST create the list view with no fields included.");
        }
        public void MSVIEWSS_S01_TC16_AddView_WithoutOptionalParameters()
        {
            // Call AddView method without the optional parameters to add a list view.
            string listName = TestSuiteBase.ListGUID;
            string displayName = this.GenerateRandomString(5);
            AddViewViewFields viewFields = new AddViewViewFields();
            AddViewQuery addViewQuery = new AddViewQuery();

            AddViewResponseAddViewResult addViewResponseAddViewResult = Adapter.AddView(listName, displayName, viewFields, addViewQuery, null, null, false);
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult, "The added view should be got successfully.");
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View, "The server should return a View element that specifies the list view when the AddView method is successful!");

            // Put the newly added view into ViewPool.
            string viewName = addViewResponseAddViewResult.View.Name;
            TestSuiteBase.ViewPool.Add(viewName);

            // Call GetView method to get the list view created above.
            GetViewResponseGetViewResult getView = Adapter.GetView(listName, viewName);
            this.Site.Assert.IsNotNull(getView, "The created list view should be got successfully.");
            this.Site.Assert.IsNotNull(getView.View, "The response element \"getView.View\" should not be null.");
            this.Site.Assert.IsNotNull(getView.View.DisplayName, "The response element \"getView.View.DisplayName\" should not be null.");
            this.Site.Assert.AreEqual(displayName, getView.View.DisplayName, "The list view added in the step above should be got successfully!");

            // If there is a View element that specifies the list view is returned, then the following requirement can be captured.
            Site.CaptureRequirement(
                102,
                @"[In AddViewResponse] It[The protocol server] MUST create the list view, and include the resulting View element when the operation succeeds.");
        }
        public void MSVIEWSS_S01_TC15_AddView_TrueCollapse_NoComputedFields()
        {
            this.Site.Assume.IsTrue(Common.IsRequirementEnabled(1507, this.Site), @"The test case is executed only when R1507Enabled is set to true.");

            // Call AddView method to add a list view without computed fields in viewFields and collapse is set to true in the query condition.
            string listName = TestSuiteBase.ListGUID;
            string displayName = this.GenerateRandomString(5);

            AddViewViewFields viewFields = new AddViewViewFields();
            viewFields.ViewFields = this.GetViewFields(false);

            AddViewQuery addViewQuery = new AddViewQuery();
            addViewQuery.Query = this.GetCamlQueryRootForGroupBy(true);

            AddViewRowLimit rowLimit = new AddViewRowLimit();
            rowLimit.RowLimit = this.GetAvailableRowLimitDefinition();

            string type = ViewType.Grid.ToString();               

            AddViewResponseAddViewResult addViewResponseAddViewResult = Adapter.AddView(listName, displayName, viewFields, addViewQuery, rowLimit, type, false);
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult, "The added view should be got successfully.");
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View, "The server should return a View element that specifies the list view when the AddView method is successful!");

            // Put the newly added view into ViewPool.
            string viewName = addViewResponseAddViewResult.View.Name;
            TestSuiteBase.ViewPool.Add(viewName);

            // Call GetView method to get the list view created above.
            GetViewResponseGetViewResult getView = Adapter.GetView(listName, viewName);
            this.Site.Assert.IsNotNull(getView, "The created list view should be got successfully.");
            this.Site.Assert.IsNotNull(getView.View, "The response element \"getView.View\" should not be null.");
            this.Site.Assert.IsNotNull(getView.View.DisplayName, "The response element \"getView.View.DisplayName\" should not be null.");
            this.Site.Assert.AreEqual(displayName, getView.View.DisplayName, "The list view added in the step above should be got successfully!");

            // Call GetItemsCount method to get the count of the list items in the specified view.
            int itemCollapseCount = SutControlAdapter.GetItemsCount(listName, viewName);
            int expectItemCollapseCount = int.Parse(Common.GetConfigurationPropertyValue("AllItemsCount", this.Site));

            // When the collapse attribute is true, if the number of view's items is the same as the number of all items in the list, then the following requirement can be captured.
            Site.CaptureRequirementIfAreEqual(
                expectItemCollapseCount,
                itemCollapseCount,
                1507,
                @"[In Appendix B: Product Behavior] Implementation does not restrict the number of rows present in the result set to the number of unique tuples where a tuple is a set of field values when there aren't any computed fields in the ViewFields section if Collapse is true.(Windows SharePoint Services 2.0 and above products follow this behavior.)");
        }
        public void MSVIEWSS_S01_TC14_AddView_InvalidListName()
        {
            string invalidListName = this.GenerateRandomString(10);
            string displayName = this.GenerateRandomString(5);

            AddViewViewFields viewFields = new AddViewViewFields();
            viewFields.ViewFields = this.GetViewFields(true);

            AddViewQuery addViewQuery = new AddViewQuery();
            addViewQuery.Query = this.GetCamlQueryRootForWhere(false);

            AddViewRowLimit rowLimit = new AddViewRowLimit();
            rowLimit.RowLimit = this.GetAvailableRowLimitDefinition();

            string type = ViewType.Grid.ToString();

            bool caughtSoapException = false; 

            // Call AddView method to add a list view with an invalid listName.
            try
            {             
                Adapter.AddView(invalidListName, displayName, viewFields, addViewQuery, rowLimit, type, false);
            }
            catch (SoapException soapException)
            {
                caughtSoapException = true; 

                // If server returns an exception when the listName element is not the name or GUID of a list, then the following requirement can be captured.
                Site.CaptureRequirementIfIsNotNull(
                    soapException,
                    13,
                    @"[In listName] If the value of listName element is not the name or GUID of a list, the operation MUST return a SOAP fault message.");
            }

            this.Site.Assert.IsTrue(caughtSoapException, "There should be a SOAP exception in the response.");

            string listName2 = TestSuiteBase.ListGUID;
            string displayName2 = "";
            caughtSoapException = false;

            // Call AddView method to add a list view with an empty viewName.
            try
            {
                Adapter.AddView(listName2, displayName2, viewFields, addViewQuery, rowLimit, type, false);
            }
            catch (SoapException soapException)
            {
                caughtSoapException = true;

                // If server returns an exception when the value of viewName element is empty, then the following requirement can be captured.
                Site.CaptureRequirementIfIsNotNull(
                    soapException,
                    265001,
                    @"[In AddView] viewName: If the value of viewName element is empty [or the viewName element is not present], the protocol server MUST return a SOAP fault message.");
            }

            this.Site.Assert.IsTrue(caughtSoapException, "There should be a SOAP exception in the response.");

            caughtSoapException = false;

            // Call AddView method to add a list view with an invalid viewName.
            try
            {
                Adapter.AddView(listName2, null, viewFields, addViewQuery, rowLimit, type, false);
            }
            catch (SoapException soapException)
            {
                caughtSoapException = true;

                // If server returns an exception when the value of viewName element is not present, then the following requirement can be captured.
                Site.CaptureRequirementIfIsNotNull(
                    soapException,
                    265002,
                    @"[In AddView] viewName: If [the value of viewName element is empty or] the viewName element is not present, the protocol server MUST return a SOAP fault message.");
            }

            this.Site.Assert.IsTrue(caughtSoapException, "There should be a SOAP exception in the response.");
        }
        public void MSVIEWSS_S01_TC13_AddView_InvalidType()
        {
            string listName = TestSuiteBase.ListGUID;
            string displayName = this.GenerateRandomString(5);

            AddViewViewFields viewFields = new AddViewViewFields();
            viewFields.ViewFields = this.GetViewFields(true);

            AddViewQuery addViewQuery = new AddViewQuery();
            addViewQuery.Query = this.GetCamlQueryRootForWhere(false);

            AddViewRowLimit rowLimit = new AddViewRowLimit();
            rowLimit.RowLimit = this.GetAvailableRowLimitDefinition();

            string type = this.GenerateRandomString(5);
            type = "a" + type;

            bool caughtSoapException = false;

            // Call AddView method to add a list view with invalid type.
            try
            {
                 Adapter.AddView(listName, displayName, viewFields, addViewQuery, rowLimit, type, false);
            }
            catch (SoapException soapException)
            {
                caughtSoapException = true; 

                // If server returns an exception when the type element is not empty and is not one of the values Calendar, Grid or Html, then the following requirement can be captured.
                Site.CaptureRequirementIfIsNotNull(
                    soapException,
                    101,
                    @"[In type] When the value of the element [the type element] is not empty and is not one of the values listed in the table [Calendar, Grid, Html], the protocol server MUST throw a SOAP fault message.");
            }

            this.Site.Assert.IsTrue(caughtSoapException, "There should be a SOAP exception in the response.");
        }
        public void MSVIEWSS_S01_TC09_AddView_NullRowLimit()
        {
            // Call AddView method to add a list view with null rowLimit.
            string listName = TestSuiteBase.ListGUID;
            string displayName = this.GenerateRandomString(5);

            AddViewViewFields viewFields = new AddViewViewFields();
            viewFields.ViewFields = this.GetViewFields(true);

            AddViewQuery addViewQuery = new AddViewQuery();
            addViewQuery.Query = this.GetCamlQueryRootForWhere(false);

            string type = ViewType.Grid.ToString();

            AddViewResponseAddViewResult addViewResponseAddViewResult = Adapter.AddView(listName, displayName, viewFields, addViewQuery, null, type, false);
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult, "The added view should be got successfully.");
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View, "The server should return a View element that specifies the list view when the AddView method is successful!");

            // Put the newly added view into ViewPool.
            string viewName = addViewResponseAddViewResult.View.Name;
            TestSuiteBase.ViewPool.Add(viewName);

            // Call GetView method to get the list view created above.
            GetViewResponseGetViewResult getView = Adapter.GetView(listName, viewName);
            this.Site.Assert.IsNotNull(getView, "The created list view should be got successfully.");
            this.Site.Assert.IsNotNull(getView.View, "The response element \"getView.View\" should not be null.");
            this.Site.Assert.IsNotNull(getView.View.DisplayName, "The response element \"getView.View.DisplayName\" should not be null.");
            this.Site.Assert.AreEqual(displayName, getView.View.DisplayName, "The list view added in the step above should be got successfully!");

            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View.RowLimit, "There should be a RowLimit element in the view.");

            // If the protocol server returns the default value of 0x0064 when the rowLimit element is not present, then the following requirement can be captured.
            Site.CaptureRequirementIfAreEqual(
                0x0064,
                addViewResponseAddViewResult.View.RowLimit.Value,
                9501,
                @"[In AddView] When the rowLimit element is not present, the server MUST use the default value of 0x0064.");

            // If the protocol server returns the list view support page-by-page displaying of items when the rowLimit element is not present, then the following requirement can be captured.
            Site.CaptureRequirementIfAreEqual(
                bool.TrueString.ToUpper(),
                addViewResponseAddViewResult.View.RowLimit.Paged.ToUpper(),
                9502,
                @"[In AddView] When the rowLimit element is not present, the list view MUST support page-by-page displaying of items.");
        }
        public void MSVIEWSS_S01_TC08_AddView_NullRowLimitAndGroupByFalseCollapse()
        {
            // Call AddView method to add a list view with null rowLimit and a query having GroupBy condition and Collapse as false.
            string listName = TestSuiteBase.ListGUID;
            string displayName = this.GenerateRandomString(5);

            AddViewViewFields viewFields = new AddViewViewFields();
            viewFields.ViewFields = this.GetViewFields(true);

            AddViewQuery addViewQuery = new AddViewQuery();
            addViewQuery.Query = this.GetCamlQueryRoot(Query.IsNotCollapse, false);

            string type = ViewType.Grid.ToString();

            AddViewResponseAddViewResult addViewResponseAddViewResult = Adapter.AddView(listName, displayName, viewFields, addViewQuery, null, type, false);
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult, "The added view should be got successfully.");
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View, "The server should return a View element that specifies the list view when the AddView method is successful!");

            // Put the newly added view into ViewPool.
            string viewName = addViewResponseAddViewResult.View.Name;
            TestSuiteBase.ViewPool.Add(viewName);

            // Call GetView method to get the list view created above.
            GetViewResponseGetViewResult getView = Adapter.GetView(listName, viewName);
            this.Site.Assert.IsNotNull(getView, "The created list view should be got successfully.");
            this.Site.Assert.IsNotNull(getView.View, "The response element \"getView.View\" should not be null.");
            this.Site.Assert.IsNotNull(getView.View.DisplayName, "The response element \"getView.View.DisplayName\" should not be null.");
            this.Site.Assert.AreEqual(displayName, getView.View.DisplayName, "The list view added in the step above should be got successfully!");

            // Call GetItemsCount method to get the count of the list items in the specified view.
            int itemNotCollapseCount = TestSuiteBase.SutControlAdapter.GetItemsCount(listName, viewName);

            // When the query's Collapse attribute is false, even there are field values that can be grouped up, the number of view's items is equal to the number of all items in the list, then the following requirement can be captured.
            Site.CaptureRequirementIfAreEqual(
                int.Parse(Common.GetConfigurationPropertyValue("AllItemsCount", this.Site)),
                itemNotCollapseCount,
                "MS-WSSCAML",
                67,
                @"[In Attributes] Otherwise[In GroupByDefinition: If Collapse is false], the number of rows in the result set MUST NOT be affected by the GroupBy element.");    
        }
        public void MSVIEWSS_S01_TC07_AddView_LogicalJoinDefinitionPresent()
        {
            // Call AddView method to add a list view for the specified list on the server when there are child elements in LogicalJoinDefinition.
            string listName = TestSuiteBase.ListGUID;
            string displayName = this.GenerateRandomString(5);

            AddViewViewFields viewFields = new AddViewViewFields();
            viewFields.ViewFields = this.GetViewFields(false);

            AddViewQuery addViewQuery = new AddViewQuery();
            addViewQuery.Query = this.GetCamlQueryRootForWhere(true);

            AddViewRowLimit rowLimit = new AddViewRowLimit();
            rowLimit.RowLimit = this.GetAvailableRowLimitDefinition();

            string type = ViewType.Grid.ToString();           

            AddViewResponseAddViewResult addViewResponseAddViewResult = Adapter.AddView(listName, displayName, viewFields, addViewQuery, null, type, false);
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult, "The added view should be got successfully.");
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View, "The server should return a View element that specifies the list view when the AddView method is successful!");

            // Put the newly added view into ViewPool.
            string viewName = addViewResponseAddViewResult.View.Name;
            TestSuiteBase.ViewPool.Add(viewName);

            // Call GetView method to get the list view created above.
            GetViewResponseGetViewResult getView = Adapter.GetView(listName, viewName);
            this.Site.Assert.IsNotNull(getView, "The created list view should be got successfully.");
            this.Site.Assert.IsNotNull(getView.View, "The response element \"getView.View\" should not be null.");
            this.Site.Assert.IsNotNull(getView.View.DisplayName, "The response element \"getView.View.DisplayName\" should not be null.");
            this.Site.Assert.AreEqual(displayName, getView.View.DisplayName, "The list view added in the step above should be got successfully!");

            // Call GetItemsCount method to get the count of the list items in the specified view.
            int itemCountWithoutLogicalJoinDefinition = TestSuiteBase.SutControlAdapter.GetItemsCount(listName, viewName);
            int expectItemCountWithLogicalJoinDefinition = int.Parse(Common.GetConfigurationPropertyValue("QueryItemsCount", this.Site));

            // If there is a query condition, the number of view's items should be equal to the number of items queried, then the following requirement can be captured.
            Site.CaptureRequirementIfAreEqual(
                expectItemCountWithLogicalJoinDefinition,
                itemCountWithoutLogicalJoinDefinition,
                "MS-WSSCAML",
                25,
                @"[In LogicalJoinDefinition Type] When this element[LogicalJoinDefinition] is present and has child elements, the server MUST return only list items that satisfy the conditions specified by those child elements.");       
        }
        public void MSVIEWSS_S01_TC05_AddView_EmptyRowLimitWithoutWhere()
        {
            // Call AddView method to add a list view with an empty rowLimit and a query without Where condition.
            string listName = TestSuiteBase.ListGUID;
            string displayName = this.GenerateRandomString(5);

            AddViewViewFields viewFields = new AddViewViewFields();
            viewFields.ViewFields = this.GetViewFields(true);

            AddViewQuery addViewQuery = new AddViewQuery();
            addViewQuery.Query = this.GetCamlQueryRootForGroupBy(true);

            AddViewRowLimit rowLimit = new AddViewRowLimit();

            string type = ViewType.Grid.ToString();

            AddViewResponseAddViewResult addViewResponseAddViewResult = Adapter.AddView(listName, displayName, viewFields, addViewQuery, rowLimit, type, false);
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult, "The added view should be got successfully.");
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View, "The server should return a View element that specifies the list view when the AddView method is successful!");

            // Put the newly added view into ViewPool.
            string viewName = addViewResponseAddViewResult.View.Name;
            TestSuiteBase.ViewPool.Add(viewName);

            // Call GetView method to get the list view created above.
            GetViewResponseGetViewResult getView = Adapter.GetView(listName, viewName);
            this.Site.Assert.IsNotNull(getView, "The created list view should be got successfully.");
            this.Site.Assert.IsNotNull(getView.View, "The response element \"getView.View\" should not be null.");
            this.Site.Assert.IsNotNull(getView.View.DisplayName, "The response element \"getView.View.DisplayName\" should not be null.");
            this.Site.Assert.AreEqual(displayName, getView.View.DisplayName, "The list view added in the step above should be got successfully!");

            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View.RowLimit, "There should be the RowLimit element in the view.");
            
            // Call GetItemsCount method to get the count of the list items in the specified view.
            int queryActualItemCount = TestSuiteBase.SutControlAdapter.GetItemsCount(listName, viewName);
            int expectItemCount = int.Parse(Common.GetConfigurationPropertyValue("AllItemsCount", this.Site));

            // If the rowLimit is not provided and there is a query condition, the number of view's items should be equal to the number of query items, then the following requirement can be captured.
            Site.CaptureRequirementIfAreEqual(
                expectItemCount,
                queryActualItemCount,
                "MS-WSSCAML",
                787,
                @"[In Child Elements] If [the content of RowLimitDefinition is ]not specified, the list schema consumer MUST return all items that meet the filter condition.");
        }
        public void MSVIEWSS_S01_TC03_AddView_EmptyQuery()
        {
            // Call AddView method to add a list view with an empty query.
            string listName = TestSuiteBase.ListGUID;
            string displayName = this.GenerateRandomString(5);

            AddViewViewFields viewFields = new AddViewViewFields();
            viewFields.ViewFields = this.GetViewFields(true);

            AddViewQuery addViewQuery = new AddViewQuery();

            AddViewRowLimit rowLimit = new AddViewRowLimit();
            rowLimit.RowLimit = this.GetAvailableRowLimitDefinition();

            string type = ViewType.Grid.ToString();

            AddViewResponseAddViewResult addViewResponseAddViewResult = Adapter.AddView(listName, displayName, viewFields, addViewQuery, rowLimit, type, false);
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult, "The added view should be got successfully.");
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View, "The server should return a View element that specifies the list view when the AddView method is successful!");

            // Put the newly added view into ViewPool.
            string viewName = addViewResponseAddViewResult.View.Name;
            TestSuiteBase.ViewPool.Add(viewName);

            // Call GetView method to get the list view created above.
            GetViewResponseGetViewResult getView = Adapter.GetView(listName, viewName);
            this.Site.Assert.IsNotNull(getView, "The created list view should be got successfully.");
            this.Site.Assert.IsNotNull(getView.View, "The response element \"getView.View\" should not be null.");
            this.Site.Assert.IsNotNull(getView.View.DisplayName, "The response element \"getView.View.DisplayName\" should not be null.");
            this.Site.Assert.AreEqual(displayName, getView.View.DisplayName, "The list view added in the step above should be got successfully!");

            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View.Query, "There should be a query in the view.");
            this.Site.Assert.IsNull(addViewResponseAddViewResult.View.Query.OrderBy, "The OrderBy clause of Query must be null.");
            this.Site.Assert.IsNull(addViewResponseAddViewResult.View.Query.Where, "The Where clause of Query must be null.");

            // Get the count of the items in the view.
            int itemCountOfEmptyQuery = TestSuiteBase.SutControlAdapter.GetItemsCount(TestSuiteBase.ListGUID, viewName);

            int expectAllItemsCount = int.Parse(Common.GetConfigurationPropertyValue("AllItemsCount", this.Site));

            // If the protocol server returns all the items of the list in the view, then the following requirement can be captured.
            Site.CaptureRequirementIfAreEqual(
                expectAllItemsCount,
                itemCountOfEmptyQuery,
                94,
                @"[In AddView] When the value of the query element is empty, the protocol server MUST create the list view without any additional restriction.");            
        }
        /// <summary>
        /// Add a view to the list.
        /// </summary>
        /// <param name="isDefault">Represents whether this view is a default view.</param>
        /// <param name="queryType">Represents the type of query condition of the view.</param>
        /// <param name="viewType">Represents the type of the view to be created.</param>
        /// <returns>The GUID of the view, which is also called the view name.</returns>
        protected string AddView(bool isDefault, Query queryType, ViewType viewType)
        {
            string listName = TestSuiteBase.ListGUID;

            string viewName = this.GenerateRandomString(5);

            AddViewViewFields viewFields = new AddViewViewFields();

            viewFields.ViewFields = this.GetViewFields(true);

            AddViewQuery addViewQuery = new AddViewQuery();

            addViewQuery.Query = this.GetCamlQueryRoot(queryType, false);

            AddViewRowLimit rowLimit = new AddViewRowLimit();

            rowLimit.RowLimit = this.GetAvailableRowLimitDefinition();

            string type = string.Empty;

            switch (viewType)
            {
            case ViewType.Calendar:
                type = "Calendar";
                break;

            case ViewType.Grid:
                type = "Grid";
                break;

            case ViewType.Html:
                type = "Html";
                break;

            default:
                Site.Debug.Fail("Not supported view type {0}", viewType.ToString());
                break;
            }

            AddViewResponseAddViewResult addViewResponseAddViewResult = TestSuiteBase.Adapter.AddView(
                listName,
                viewName,
                viewFields,
                addViewQuery,
                rowLimit,
                type,
                isDefault);

            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View, "The call of the AddView operation SHOULD be successful.");

            string viewGUID = addViewResponseAddViewResult.View.Name;

            if (isDefault)
            {
                this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View.DefaultView, "The response element \"addViewResponseAddViewResult.View.DefaultView\" should not be null.");
                this.Site.Assert.AreEqual("true", addViewResponseAddViewResult.View.DefaultView.ToLower(), "The added view should be a default view.");

                // If the new default view is added successfully, the original default view lost its default view position.
                if (OriginalDefaultViewName != null)
                {
                    if (TestSuiteBase.OriginalDefaultViewLost == false)
                    {
                        TestSuiteBase.OriginalDefaultViewLost = true;
                    }
                }
            }

            TestSuiteBase.ViewPool.Add(viewGUID);
            return(addViewResponseAddViewResult.View.Name);
        }
        public void MSVIEWSS_S01_TC12_AddView_EmptyType()
        {
            // Call AddView method to add a list view with an empty type.
            string listName = TestSuiteBase.ListGUID;
            string displayName = this.GenerateRandomString(5);

            AddViewViewFields viewFields = new AddViewViewFields();
            viewFields.ViewFields = this.GetViewFields(true);

            AddViewQuery addViewQuery = new AddViewQuery();
            addViewQuery.Query = this.GetCamlQueryRootForWhere(false);

            AddViewRowLimit rowLimit = new AddViewRowLimit();
            rowLimit.RowLimit = this.GetAvailableRowLimitDefinition();

            AddViewResponseAddViewResult addViewResponseAddViewResult = Adapter.AddView(listName, displayName, viewFields, addViewQuery, rowLimit, string.Empty, true);
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult, "The added view should be got successfully.");
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View, "The server should return a View element that specifies the list view when the AddView method is successful!");

            // Put the newly added view into ViewPool.
            string viewName = addViewResponseAddViewResult.View.Name;
            TestSuiteBase.ViewPool.Add(viewName);

            // If the new default view is added successfully, the original default view lost its default view position.
            this.Site.Assert.IsNotNull(addViewResponseAddViewResult.View.DefaultView, "The response element \"addViewResponseAddViewResult.View.DefaultView\" should not be null.");
            this.Site.Assert.AreEqual("true", addViewResponseAddViewResult.View.DefaultView.ToLower(), "The added view should be a default view.");
            if (TestSuiteBase.OriginalDefaultViewName != null)
            {
                if (TestSuiteBase.OriginalDefaultViewLost == false)
                {
                    TestSuiteBase.OriginalDefaultViewLost = true;
                }
            }

            // Call GetView method to get the list view created above.
            GetViewResponseGetViewResult getView = Adapter.GetView(listName, viewName);
            this.Site.Assert.IsNotNull(getView, "The created list view should be got successfully.");
            this.Site.Assert.IsNotNull(getView.View, "The response element \"getView.View\" should not be null.");
            this.Site.Assert.IsNotNull(getView.View.DisplayName, "The response element \"getView.View.DisplayName\" should not be null.");
            this.Site.Assert.AreEqual(displayName, getView.View.DisplayName, "The list view added in the step above should be got successfully!");

            // If the protocol server set the value of type is "Html" when it is an empty value, then the following requirement can be captured.
            Site.CaptureRequirementIfAreEqual<string>(
                ViewType.Html.ToString().ToUpper(),
                addViewResponseAddViewResult.View.Type.ToString().ToUpper(),
                10002,
                @"[In type] When this element[type] has an empty value, the protocol server MUST take it with a value of ""Html"".");
        }
        public void MSVIEWSS_S05_TC01_UpdateViewHtml2_Success()
        {
            this.Site.Assume.IsTrue(Common.IsRequirementEnabled(8016, this.Site), @"The test case is executed only when R8016Enabled is set to true.");

            // Add a view.
            string viewName = this.AddView(false, Query.EmptyQueryInfo, ViewType.Html);

            string updatedDisplayName = this.GenerateRandomString(6);
            UpdateViewHtml2ViewProperties viewProperties = this.GetViewProperties(false, updatedDisplayName, false, ViewScope.Recursive);
            UpdateViewHtml2Toolbar toolbar;
            UpdateViewHtml2ViewHeader viewHeader;
            UpdateViewHtml2ViewBody viewBody;
            UpdateViewHtml2ViewFooter viewFooter;
            UpdateViewHtml2ViewEmpty viewEmpty;
            UpdateViewHtml2RowLimitExceeded rowLimitExceeded;

            this.GetHtmlConfigure(
                                out toolbar,  
                                out viewHeader,
                                out viewBody,
                                out viewFooter,
                                out viewEmpty,
                                out rowLimitExceeded);

            UpdateViewHtml2Query queryValue = new UpdateViewHtml2Query();
            queryValue.Query = this.GetCamlQueryRoot(Query.AvailableQueryInfo, false);

            UpdateViewHtml2ViewFields viewFields = new UpdateViewHtml2ViewFields();
            viewFields.ViewFields = this.GetViewFields(false);

            UpdateViewHtml2Aggregations aggregations = new UpdateViewHtml2Aggregations();
            string aggregationsType = Common.GetConfigurationPropertyValue("FieldRefAggregations_AggregationsType", this.Site);
            aggregations.Aggregations = this.GetAggregationsDefinition(true, true, aggregationsType);

            UpdateViewHtml2Formats formats = new UpdateViewHtml2Formats();
            formats.Formats = this.GetViewFormatDefinitions();

            UpdateViewHtml2RowLimit rowLimitValue = new UpdateViewHtml2RowLimit();
            rowLimitValue.RowLimit = this.GetAvailableRowLimitDefinition();

            string openApplicationExtension = Common.GetConfigurationPropertyValue("OpenApplicationExtension", this.Site);

            // Call UpdateViewHtml2 to update the view including display properties and the possibility to be rendered with extended application.
            // All optional parameters in the request of UpdateViewHtml2 are present in this call.
            UpdateViewHtml2ResponseUpdateViewHtml2Result updateViewHtml2Re = Adapter.UpdateViewHtml2(
                                                                                       TestSuiteBase.ListGUID,
                                                                                       viewName,
                                                                                       viewProperties,
                                                                                       toolbar,
                                                                                       viewHeader,
                                                                                       viewBody,
                                                                                       viewFooter,
                                                                                       viewEmpty,
                                                                                       rowLimitExceeded,
                                                                                       queryValue,
                                                                                       viewFields,
                                                                                       aggregations,
                                                                                       formats,
                                                                                       rowLimitValue,
                                                                                       openApplicationExtension);

            this.Site.Assert.IsNotNull(updateViewHtml2Re, "There should be a result element returned from the UpdateViewHtml2 operation.");

            // Verify Requirement MS-VIEWSS_R145, if the server returns a View element in the update result.
            Site.CaptureRequirementIfIsNotNull(updateViewHtml2Re.View, 145, @"[In UpdateViewHtml2Response] UpdateViewHtml2Result: If the protocol server successfully updates the list view, it MUST return a View element that specifies the list view.");
            this.Site.Assert.IsNotNull(updateViewHtml2Re.View.DisplayName, "The response element \"updateViewHtml2Re.View.DisplayName\" should not be null.");
            this.Site.Assert.AreEqual(viewProperties.View.DisplayName, updateViewHtml2Re.View.DisplayName, "The display name should be the same as updated.");

            // Verify Requirement MS-VIEWSS_R8016, if the server returns a View element in the update result that indicates the UpdateViewHTML2 operation succeed on the server.
            Site.CaptureRequirementIfIsNotNull(updateViewHtml2Re.View, 8016, @"[In Appendix B: Product Behavior] Implementation does support this method[UpdateViewHtml2]. (Windows SharePoint Services 3.0 and above products follow this behavior.)");
            // Verify requirement: MS-VIEWSS_R8015
            if (Common.IsRequirementEnabled(8015, this.Site))
            {
                string listName = TestSuiteBase.ListGUID;
                string displayName = this.GenerateRandomString(5);
                string type = ViewType.Html.ToString();
                AddViewViewFields viewFields1 = new AddViewViewFields();
                viewFields.ViewFields = this.GetViewFields(true);
                AddViewQuery addViewQuery = new AddViewQuery();
                addViewQuery.Query = this.GetCamlQueryRootForWhere(false);
                AddViewRowLimit rowLimit = new AddViewRowLimit();
                rowLimit.RowLimit = this.GetAvailableRowLimitDefinition();

                AddViewResponseAddViewResult addViewResponseAddViewResult = Adapter.AddView(listName, displayName, viewFields1, addViewQuery, rowLimit, type, false);

                UpdateViewHtml2ResponseUpdateViewHtml2Result updateViewHtml2Re2 = Adapter.UpdateViewHtml2(
                                                                                          listName,
                                                                                          viewName,
                                                                                          viewProperties,
                                                                                          toolbar,
                                                                                          viewHeader,
                                                                                          viewBody,
                                                                                          viewFooter,
                                                                                          viewEmpty,
                                                                                          rowLimitExceeded,
                                                                                          queryValue,
                                                                                          viewFields,
                                                                                          aggregations,
                                                                                          formats,
                                                                                          rowLimitValue,
                                                                                          openApplicationExtension);
                GetViewResponseGetViewResult getView = Adapter.GetView(listName, viewName);
                Site.CaptureRequirementIfAreEqual(
                   openApplicationExtension,
                    getView.View.Text[0],
                    8015,
                    @"[In Appendix B: Product Behavior] Implementation does return the value of OpenApplicationExtension as the value of the View element when GetView is called after UpdateViewHtml2 (section 3.1.4.8) and the type of the view is HTML. <3> Section 3.1.4.3.2.2: In SharePoint Foundation 2010 and SharePoint Foundation 2013, when this method is called after UpdateViewHtml2 (section 3.1.4.8) and the type of the view is HTML, the value of OpenApplicationExtension is returned as the value of the View element. (SharePoint Server 2010 and above follow this hebavior.)");
            }
        }
        /// <summary>
        /// This operation is used to create a list view for the specified list.
        /// </summary>
        /// <param name="listName">Specify a list on the server.</param>
        /// <param name="viewName">Specify a list view on the server.</param>
        /// <param name="viewFields">Specify the fields included in a list view.</param>
        /// <param name="query">Include the information that affects how a list view displays the data.</param>
        /// <param name="rowLimit">Specify whether a list supports displaying items page-by-page, and the count of items a list view displays per page.</param>
        /// <param name="type">Specify the type of a list view.</param>
        /// <param name="makeViewDefault">Specify whether to make the list view the default list view for the specified list.</param>
        /// <returns>The result returns a list view that the type is BriefViewDefinition, if the operation succeeds.</returns>
        public AddViewResponseAddViewResult AddView(
           string listName,
           string viewName,
           AddViewViewFields viewFields,
           AddViewQuery query,
           AddViewRowLimit rowLimit,
           string type,
           bool makeViewDefault)
        {
            AddViewResponseAddViewResult addViewResult;

            try
            {
                addViewResult = this.viewssProxy.AddView(
                        listName,
                        viewName,
                        viewFields,
                        query,
                        rowLimit,
                        type,
                        makeViewDefault);

                // Used to validate the transport requirements.
                this.CaptureTransportRelatedRequirements();

                // Used to validate AddViewResult schema requirements.
                this.ValidateAddViewResult(addViewResult);
            }
            catch (SoapException soapException)
            {
                this.Site.Log.Add(
                                LogEntryKind.Debug,
                                @"There is an exception generated when calling [AddView] method:\r\n{0}",
                                soapException.Detail.InnerXml);

                // Used to validate the transport requirements.
                this.CaptureTransportRelatedRequirements();

                // Used to validate the schema of SoapFault.
                this.ValidateSOAPFaultDetails(soapException.Detail);

                throw;
            }

            return addViewResult;
        }