Exemple #1
0
        /// <summary>
        /// Changes the Delete of a business unit to be a deactivate.  Allows for normal Deletion of all entities by the Test builder framework
        /// </summary>
        /// <returns></returns>
        public TDerived WithBusinessUnitDeleteAsDeactivate()
        {
            DeleteActions.Add((s, entityLogicalName, id) =>
            {
                if (entityLogicalName == BusinessUnit.EntityLogicalName)
                {
                    s.SetState(entityLogicalName, id, false);
                }

                s.Delete(entityLogicalName, id);
            });

            return(This);
        }
Exemple #2
0
        /// <summary>
        /// Asserts failure whenever an action is requested that would perform an update (Create / Delete / Update) of some sort
        /// </summary>
        /// <returns></returns>
        public TDerived IsReadOnly()
        {
            AssociateActions.Add((s, n, i, r, c) => { TestSettings.TestFrameworkProvider.AssertFail("An attempt was made to Associate Entities with a ReadOnly Service"); });
            WithNoCreates();
            DeleteActions.Add((s, n, i) => { TestSettings.TestFrameworkProvider.AssertFail($"An attempt was made to Delete a(n) {n} Entity with id {i}, using a ReadOnly Service"); });
            DisassociateActions.Add((s, n, i, r, c) => { TestSettings.TestFrameworkProvider.AssertFail("An attempt was made to Disassociate Entities with a ReadOnly Service"); });
            ExecuteFuncs.Add((s, r) =>
            {
                var readOnlyStartsWithNames = new List <string>
                {
                    "CanBe",
                    "CanManyToMany",
                    "Download",
                    "Execute",
                    "Export",
                    "FetchXmlToQueryExpression",
                    "FindParentResourceGroup",
                    "Get",
                    "Is",
                    "LocalTimeFromUtcTime",
                    "Query",
                    "Retrieve",
                    "Search",
                    "UtcTimeFromLocalTime",
                    "WhoAmI"
                };
                if (readOnlyStartsWithNames.Any(n => r.RequestName.StartsWith(n)))
                {
                    return(s.Execute(r));
                }

                throw TestSettings.TestFrameworkProvider.Value.GetFailedException($"An attempt was made to Execute Request {r.RequestName} with a ReadOnly Service");
            });
            UpdateActions.Add((s, e) => { throw TestSettings.TestFrameworkProvider.Value.GetFailedException($"An attempt was made to Update a(n) {e.LogicalName} Entity with id {e.Id}, using a ReadOnly Service"); });
            return(This);
        }