public OphaevAendringHandler(AendringDefinition aendringDefinition, XElement aendringElement) : base(aendringDefinition, aendringElement) { if (aendringDefinition.AktionType != AktionType.Ophaev) { throw new InvalidOperationException($"Aendring aktion for this handler should be {AktionType.Ophaev}, but is {aendringDefinition.AktionType}."); } }
public IndsaetEfterHandler(AendringDefinition aendringDefinition, XElement changeDefinition) : base(aendringDefinition, changeDefinition) { if (aendringDefinition.AktionType != AktionType.IndsaetEfter) { throw new ApplyAendringerException($"AktionType for this handler should be {aendringDefinition.AktionType}."); } }
private void TestParseResult(string input, object[] expectedExplicatus, AktionType expectedAktionType, Type[] expectedTypes) { var parseResult = _sut.Parse(input); AssertErrors(parseResult); AendringDefinition parseResultResult = parseResult.Result; AssertTargetElementChain(expectedExplicatus, expectedAktionType, expectedTypes, parseResultResult, parseResultResult.Target); }
public void TestQuotedTextRemoved_Simple(string input, string textToRemove, object[] explicatusChain, Type[] targetChainTypes) { var result = _sut.Parse(input); AssertErrors(result); AendringDefinition parseResultResult = result.Result; AssertTargetElementChain(explicatusChain, AktionType.Ophaev, targetChainTypes, parseResultResult, parseResultResult.Target); Assert.Equal(textToRemove, result.Result.Target.SubElementTarget.Target); Assert.Null(result.Result.Target.SubElementTarget.Replacement); }
public void TestSimple_SubelementTargetLevel_Replace(string input, object[] expectedExplicatus, string quotedFrom, string quotedTo, Type[] aendringsType) { var parseResult = _sut.Parse(input); AssertErrors(parseResult); AendringDefinition parseResultResult = parseResult.Result; AssertTargetElementChain(expectedExplicatus, AktionType.Erstat, aendringsType, parseResultResult, parseResultResult.Target); AssertQuotedTextChange(quotedFrom, quotedTo, parseResult); }
private void AssertAllTargetChains(object[][] explicatusChains, Type[][] elementTypes, ParseResult <AendringDefinition> result, AktionType expectedAktionType) { Assert.Equal(explicatusChains.Length, result.Result.Targets.Length); int counter = 0; Assert.All(explicatusChains, chain => { AendringDefinition parseResultResult = result.Result; AssertTargetElementChain(chain, expectedAktionType, elementTypes[counter], parseResultResult, parseResultResult.Targets[counter]); counter++; }); }
private void AssertTargetElementChain(object[] expectedExplicatus, AktionType expectedAktionType, Type[] expectedType, AendringDefinition parseResultResult, Element elementTarget) { //Assert.Equal(Enumerable.Empty<string>(), parseResult.ErrorResult.Errors); //no errors Assert.Equal(expectedType.Count(), Enumerable.Count <Element>(elementTarget.GetAncestorsAndSelf)); //one target level Assert.Equal(expectedAktionType, parseResultResult.AktionType); //assert chain int counter = 0; Assert.All <Element>(elementTarget.GetAncestorsAndSelf, element => { Assert.IsType(expectedType[counter], element); Assert.Equal(expectedExplicatus[counter].ToString(), element.Nummer.ToString()); counter++; }); }
public void TestAendringDefinitionModelSerializer() { var sut = new ModelSerializer(); var input = new AendringDefinition() { Targets = new[] { new Stk() { NummerStrong = 3, ParentContext = new Paragraf() { NummerStrong = "3 a" } } } }; var serialize = sut.Serialize(input); Assert.NotNull(XDocument.Parse(serialize)); }
public IAendringAktionHandler Create(AendringDefinition aendringDefinition, XElement aendring) { switch (aendringDefinition.AktionType) { case AktionType.IndsaetEfter: return(new IndsaetEfterHandler(aendringDefinition, aendring)); case AktionType.Ophaev: return(new OphaevAendringHandler(aendringDefinition, aendring)); case AktionType.Erstat: return(new ErstatAendringHandler(aendringDefinition, aendring)); case AktionType.IndsaetFoer: return(new IndsaetFoerHandler(aendringDefinition, aendring)); case AktionType.Manuel: return(new NoopManuelHandler()); default: throw new ArgumentOutOfRangeException(); } }
public IndsaetFoerHandler(AendringDefinition aendringDefinition, XElement aendring) : base(aendringDefinition, aendring) { }
protected BaseAendringAktionHandler(AendringDefinition aendringDefinition, XElement aendringElement) { AendringDefinition = aendringDefinition; AendringElement = aendringElement; }
public ErstatAendringHandler(AendringDefinition aendringDefinition, XElement aendring) : base(aendringDefinition, aendring) { }