public void AddReference_Returns_NotFound_If_Root_Is_NotFound() { //Arrange var id = A <int>(); var rootType = A <ReferenceRootType>(); ExpectGetRootEntityReturns(id, rootType, Maybe <IEntityWithExternalReferences> .None); //Act var result = _sut.AddReference(id, rootType, A <string>(), A <string>(), A <string>(), A <Display>()); //Assert Assert.True(result.Failed); Assert.Equal(new OperationError("Root entity could not be found", OperationFailure.NotFound), result.Error); }
Guid IEntityHandler <EntityType> .CreateUpdateSegment(object value, string path, ListUpdateType listUpdateType) { Guid segmentId = CreateSegmentId(); _updateSegments.Add(segmentId, new UpdateSegment { Path = path, Value = value, CreationDate = DateTime.Now, ListUpdateType = listUpdateType }); _referenceService?.AddReference(segmentId, _firstPropertyInfo.GetValue(Entity), _firstPropertyInfo); return(segmentId); }
public ResultData DoStuff(EventData data) { ReferenceService refsvc; string res; switch ((CodesEnum)data.Code) { case CodesEnum.DEKBELCODE_ADDVOLUMETITLE: refsvc = new ReferenceService(); res = refsvc.EditVolumeTitle(data); Result = new ResultData { Code = 0, Message = $"New title set: {res}.", Cancel = string.IsNullOrWhiteSpace(res), }; break; case CodesEnum.DEKBELCODE_ADDBOOKTITLE: refsvc = new ReferenceService(); res = refsvc.AddReference <Book>(data); Result = new ResultData { Code = 0, Message = $"Added book: {res}.", Cancel = string.IsNullOrWhiteSpace(res), }; break; case CodesEnum.DEKBELCODE_ADDCHAPTER: refsvc = new ReferenceService(); res = refsvc.AddReference <Chapter>(data); Result = new ResultData { Code = 0, Message = $"Added chapter: {res}.", Cancel = string.IsNullOrWhiteSpace(res), }; break; case CodesEnum.DEKBELCODE_ADDSUBCHAPTER: refsvc = new ReferenceService(); res = refsvc.AddReference <SubChapter>(data); Result = new ResultData { Code = 0, Message = $"Added subchapter: {res}.", Cancel = string.IsNullOrWhiteSpace(res), }; break; case CodesEnum.DEKBELCODE_ADDPARAGRAPH: refsvc = new ReferenceService(); res = refsvc.AddReference <Paragraph>(data); Result = new ResultData { Code = 0, Message = $"Added paragraph: {res}.", Cancel = string.IsNullOrWhiteSpace(res), }; break; case CodesEnum.DEKBELCODE_ADDRAWCITATION: var mainService = new MainService(); var result = mainService.AddRawCitations(data); Result = new ResultData { Code = 0, Message = $"Added raw citation. Id = {result.Id}.", Cancel = false, }; break; case CodesEnum.DEKBELCODE_SHOWBEL: case CodesEnum.DEKBELCODE_ADDANDSHOWCITATION: BelGui belAdd = new BelGui(data); if (belAdd.IsDisposed) { Result = new ResultData { Cancel = true, Code = -1, Message = "Cancel" }; break; } belAdd.ShowDialog(); Result = belAdd.Result; break; case CodesEnum.DEKBELCODE_ADDCITATIONSILENT: var mainService2 = new MainService(); bool result2 = mainService2.AddCitationSilent(data); if (!result2) { Result = new ResultData { Cancel = true, Code = -1, Message = "Cancel" }; break; } break; case CodesEnum.DEKBELCODE_EDITCITATION: BelGui belEdit = new BelGui(data); if (belEdit.IsDisposed) { Result = new ResultData { Cancel = true, Code = -1, Message = "Cancel" }; break; } belEdit.ShowDialog(); Result = belEdit.Result; break; case CodesEnum.DEKBELCODE_STARTAUTOPAGINATION: refsvc = new ReferenceService(); var page = refsvc.AddPage(data); Result = new ResultData { Code = 0, Message = page == null ? "Page add canceled." : $"Added page reference. Id = {page.Id}.", Cancel = page == null, }; refsvc.Dispose(); break; default: break; } return(Result); }