protected override RChoice ParseChoice(ChoiceRef choiceRef) { if (choiceRef.Guids?.Any() ?? false) { return(new RChoice.GuidsChoice(choiceRef.Guids.ToList())); } return(base.ParseChoice(choiceRef)); }
public void ParseValue_ValueIsNull_ReturnsCorrectValue() { //ARRANGE var choice = new ChoiceRef(123); //ACT var result = _parser.ParseValue(null); //ASSERT Assert.Null(result); }
public void ParseValue_ValueIsSingleChoiceWithArtifactId_ReturnsCorrectValue() { //ARRANGE var choice = new ChoiceRef(123); //ACT var result = _parser.ParseValue(choice); //ASSERT Assert.IsType <RChoice.ArtifactIdChoice>(result); Assert.Equal(123, ((RChoice.ArtifactIdChoice)result).ArtifactID); }
public void ParseValue_ValueIsSingleChoiceWithGuid_ReturnsCorrectValue() { //ARRANGE var g = Guid.NewGuid(); var choice = new ChoiceRef(g); //ACT var result = _parser.ParseValue(choice); //ASSERT Assert.IsType <RChoice.GuidChoice>(result); Assert.Equal(g, ((RChoice.GuidChoice)result).Guid); }
public static ChoiceRef ToChoiceRef(this Choice choice) { var choiceRef = new ChoiceRef(); choiceRef.ArtifactId = choice.ArtifactID; choiceRef.Guids = new List <Guid>(); if (choice.Guids?.Any() ?? false) { choiceRef.Guids = choice.Guids?.ToList() ?? new List <Guid>(); } choiceRef.Name = choice.Name; return(choiceRef); }
protected virtual RChoice ParseChoice(ChoiceRef choiceRef) { var c = choiceRef; if (c.ArtifactId > 0) { return(new RChoice.ArtifactIdChoice(c.ArtifactId)); } if (c.Guids?.Any() ?? false) { return(new RChoice.GuidChoice(c.Guids.First())); } throw new NotSupportedException("ArtifactId or Guid must be set on choice"); }
public void ParseValue_ValueIsMultiChoice_ReturnsCorrectValue() { //ARRANGE var choice = new ChoiceRef(123); //ACT var result = _parser.ParseValue(new List <ChoiceRef> { choice }); //ASSERT Assert.True(typeof(IEnumerable <RChoice>).IsAssignableFrom(result.GetType())); var rChoice = ((IEnumerable <RChoice>)result).Single(); Assert.Equal(123, ((RChoice.ArtifactIdChoice)rChoice).ArtifactID); }
public static Choice ToRelativityChoice(this ChoiceRef choiceRef) { if (choiceRef == null) { return(null); } var choice = new Choice(); if (choiceRef.ArtifactId > 0) { choice = new Choice(choiceRef.ArtifactId); } choice.Guids = choiceRef.Guids?.ToList() ?? new List <Guid>(); choice.Name = choiceRef.Name; return(choice); }
/// <summary> /// Creates a Client object with a random number and active status /// </summary> /// <param name="name"></param> /// <returns></returns> public int Create(string name) { using (IClientManager proxy = _helper.GetServicesManager().CreateProxy <IClientManager>(API.ExecutionIdentity.System)) { List <ChoiceRef> choiceRefs = proxy.GetStatusChoicesForClientAsync().Result; ChoiceRef statusRef = choiceRefs.Find(x => x.Name == "Active"); var newClient = new Relativity.Services.Client.Client { Name = name, Number = new Random().Next(1000).ToString(), Status = statusRef, Keywords = "Integration Test Client" }; int clientArtifactId = proxy.CreateSingleAsync(newClient).Result; return(clientArtifactId); } }
public static int Create_Client(IRSAPIClient client, Relativity.Services.ServiceProxy.ServiceFactory serviceFactory, string name) { var workspaceId = client.APIOptions.WorkspaceID; client.APIOptions.WorkspaceID = -1; using (IClientManager proxy = serviceFactory.CreateProxy <IClientManager>()) { List <ChoiceRef> choiceRefs = proxy.GetStatusChoicesForClientAsync().Result; ChoiceRef statusRef = choiceRefs.Find(x => x.Name == "Active"); var newClient = new Relativity.Services.Client.Client { Name = name, Number = Guid.NewGuid().ToString(), Status = statusRef, Keywords = "Temp Client", Notes = "Used in the Disable Inactve User Integration Test." }; int clientArtifactId = proxy.CreateSingleAsync(newClient).Result; client.APIOptions.WorkspaceID = workspaceId; return(clientArtifactId); } }
public async Task UpdateAsync_UpdateSingleChoiceByGuidUsingChoiceGuid_ReturnsSuccess() { //ARRANGE var fieldGuid = Guid.Parse(DocumentFieldDefinitions.SingleChoice); //ACT var value = new ChoiceRef(Guid.Parse(SingleChoiceChoiceDefinitions.Single1)); var(uResult, result) = await SharedTestCases.RunUpdateTestAsync(_manager, _fixture.WorkspaceId, _creation.DocIds.First(), new FieldRef(fieldGuid), value); //ASSERT Assert.True(uResult.EventHandlerStatuses.All(x => x.Success)); Assert.Equal(_creation.DocIds.Single(), result.ArtifactId); Assert.Contains(result.FieldValues, (f) => f.Field.Guids.Contains(fieldGuid)); Assert.Equal(value.Guids.First(), result[fieldGuid].ValueAsSingleChoice().Guids.First()); }
public static async Task UpdateAsync_UpdateSingleChoiceByGuidUsingChoiceArtifactId_ReturnsSuccess(this IObjectManager manager, IHelper helper, int workspaceId, int docId) { //ARRANGE var fieldGuid = Guid.Parse(DocumentFieldDefinitions.SingleChoice); var client = helper.GetServicesManager().CreateProxy <IRSAPIClient>(Relativity.API.ExecutionIdentity.System); client.APIOptions.WorkspaceID = workspaceId; var choice = client.Repositories.Choice.ReadSingle(Guid.Parse(SingleChoiceChoiceDefinitions.Single1)); //ACT var value = new ChoiceRef(choice.ArtifactID); var(uResult, result) = await SharedTestCases.RunUpdateTestAsync(manager, workspaceId, docId, new FieldRef(fieldGuid), value); //ASSERT Assert.True(uResult.EventHandlerStatuses.All(x => x.Success)); Assert.Equal(docId, result.ArtifactId); Assert.Contains(result.FieldValues, (f) => f.Field.Guids.Contains(fieldGuid)); Assert.Equal(choice.ArtifactID, result[fieldGuid].ValueAsSingleChoice().ArtifactId); }