コード例 #1
0
 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}.");
     }
 }
コード例 #2
0
 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}.");
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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++;
            });
        }
コード例 #7
0
        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++;
            });
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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();
            }
        }
コード例 #10
0
 public IndsaetFoerHandler(AendringDefinition aendringDefinition, XElement aendring) : base(aendringDefinition, aendring)
 {
 }
コード例 #11
0
 protected BaseAendringAktionHandler(AendringDefinition aendringDefinition, XElement aendringElement)
 {
     AendringDefinition = aendringDefinition;
     AendringElement    = aendringElement;
 }
コード例 #12
0
 public ErstatAendringHandler(AendringDefinition aendringDefinition, XElement aendring) : base(aendringDefinition, aendring)
 {
 }