Пример #1
0
 public void VerifyCreateOrUpdateError(Entity workflow)
 {
     try
     {
         if (workflow.Id == Guid.Empty)
         {
             XrmService.Create(workflow);
         }
         else
         {
             XrmService.Update(workflow);
         }
         Assert.Fail();
     }
     catch (Exception ex)
     {
         Assert.IsFalse(ex is AssertFailedException);
     }
 }
Пример #2
0
        public virtual Entity CreateAndRetrieve(Entity entity, XrmService xrmService = null)
        {
            if (xrmService == null)
            {
                xrmService = XrmService;
            }
            var primaryField = xrmService.GetPrimaryField(entity.LogicalName);

            if (!entity.Contains(primaryField))
            {
                entity.SetField(primaryField, ("Test Scripted Record" + DateTime.UtcNow.ToFileTime()).Left(xrmService.GetMaxLength(primaryField, entity.LogicalName)));
            }
            if (entity.LogicalName == Entities.contact && !entity.Contains(Fields.contact_.firstname))
            {
                entity.SetField(Fields.contact_.firstname, "Test");
            }
            if (entity.LogicalName == Entities.lead && !entity.Contains(Fields.lead_.firstname))
            {
                entity.SetField(Fields.lead_.firstname, "Test");
            }
            var id = xrmService.Create(entity);

            return(xrmService.Retrieve(entity.LogicalName, id));
        }