Esempio n. 1
0
        public void WithCorrectedNameAndMuncipalityHasName(CrabLanguage language, Language expectedLanguage)
        {
            var newName = _fixture.Create <string>();
            var municipalityNameFromCrab = _fixture
                                           .Build <ImportMunicipalityNameFromCrab>()
                                           .With(x => x.Modification, CrabModification.Correction)
                                           .With(x => x.MunicipalityName, new CrabMunicipalityName(newName, language))
                                           .Create();

            var municipalityWasRegistered = new MunicipalityWasRegistered(_municipalityId, _nisCode);

            ((ISetProvenance)municipalityWasRegistered).SetProvenance(CreateProvenance(1));

            var municipalityNameWasCorrected = new MunicipalityNameWasCorrected(_municipalityId, new MunicipalityName(newName, expectedLanguage));

            ((ISetProvenance)municipalityNameWasCorrected).SetProvenance(CreateProvenance(1));

            Assert(
                new Scenario()
                .Given(_municipalityId,
                       municipalityWasRegistered,
                       _fixture.Create <MunicipalityWasNamed>())

                .When(municipalityNameFromCrab)

                .Then(_municipalityId,
                      municipalityNameWasCorrected,
                      municipalityNameFromCrab.ToLegacyEvent()));
        }
Esempio n. 2
0
        public void WithNewNameAsNullAndCorrectionAndMuncipalityHasName(CrabLanguage language, Language expectedLanguage)
        {
            var municipalityNameFromCrab = _fixture
                                           .Build <ImportMunicipalityNameFromCrab>()
                                           .With(x => x.Modification, CrabModification.Correction)
                                           .With(x => x.MunicipalityName, new CrabMunicipalityName(null, language))
                                           .Create();

            var municipalityWasRegistered = new MunicipalityWasRegistered(_municipalityId, _nisCode);

            ((ISetProvenance)municipalityWasRegistered).SetProvenance(CreateProvenance(1));

            var municipalityNameWasCorrectedToCleared = new MunicipalityNameWasCorrectedToCleared(_municipalityId, expectedLanguage);

            ((ISetProvenance)municipalityNameWasCorrectedToCleared).SetProvenance(CreateProvenance(1));

            var municipalityWasNamed = new MunicipalityWasNamed(_municipalityId, new MunicipalityName(_fixture.Create <string>(), expectedLanguage));

            ((ISetProvenance)municipalityWasNamed).SetProvenance(CreateProvenance(1));

            Assert(
                new Scenario()
                .Given(_municipalityId,
                       municipalityWasRegistered,
                       municipalityWasNamed)

                .When(municipalityNameFromCrab)

                .Throws(new NoNameException("Cannot give a municipality an empty name.")));
        }
        public void WithName(CrabLanguage language, Language expectedLanguage)
        {
            var name = _fixture.Create <string>();
            var municipalityNameFromCrab = _fixture
                                           .Build <ImportMunicipalityNameFromCrab>()
                                           .With(x => x.MunicipalityName, new CrabMunicipalityName(name, language))
                                           .Create();

            var provenance = new MunicipalityProvenanceFactory().CreateFrom(1, false, municipalityNameFromCrab.Timestamp, municipalityNameFromCrab.Modification, municipalityNameFromCrab.Operator, municipalityNameFromCrab.Organisation);

            var municipalityWasRegistered = new MunicipalityWasRegistered(_municipalityId, _nisCode);

            ((ISetProvenance)municipalityWasRegistered).SetProvenance(provenance);

            var municipalityWasNamed = new MunicipalityWasNamed(_municipalityId, new MunicipalityName(name, expectedLanguage));

            ((ISetProvenance)municipalityWasNamed).SetProvenance(provenance);

            Assert(
                new Scenario()
                .Given(_municipalityId,
                       municipalityWasRegistered)

                .When(municipalityNameFromCrab)

                .Then(_municipalityId,
                      municipalityWasNamed,
                      municipalityNameFromCrab.ToLegacyEvent()));
        }
Esempio n. 4
0
        public static Language ToLanguage(this CrabLanguage language)
        {
            switch (language)
            {
            case CrabLanguage.Dutch:
                return(Language.Dutch);

            case CrabLanguage.French:
                return(Language.French);

            case CrabLanguage.German:
                return(Language.German);

            case CrabLanguage.English:
                return(Language.English);

            default:
                throw new ArgumentOutOfRangeException(nameof(language), language, $"Non existing language '{language}'.");
            }
        }
        public void WithNoName(CrabLanguage language)
        {
            var municipalityNameFromCrab = _fixture
                                           .Build <ImportMunicipalityNameFromCrab>()
                                           .With(x => x.MunicipalityName, new CrabMunicipalityName(null, language))
                                           .Create();

            var provenance = new MunicipalityProvenanceFactory().CreateFrom(1, false, municipalityNameFromCrab.Timestamp, municipalityNameFromCrab.Modification, municipalityNameFromCrab.Operator, municipalityNameFromCrab.Organisation);

            var municipalityWasRegistered = new MunicipalityWasRegistered(_municipalityId, _nisCode);

            ((ISetProvenance)municipalityWasRegistered).SetProvenance(provenance);

            Assert(
                new Scenario()
                .Given(_municipalityId,
                       municipalityWasRegistered)

                .When(municipalityNameFromCrab)
                .Throws(new NoNameException("Cannot give a municipality an empty name.")));
        }