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()));
        }
コード例 #2
0
        public void With2LanguagesAndInfiniteLifeTime()
        {
            var importMunicipalityFromCrab = _fixture
                                             .Build <ImportMunicipalityFromCrab>()
                                             .With(x => x.PrimaryLanguage, CrabLanguage.Dutch)
                                             .With(x => x.SecondaryLanguage, CrabLanguage.French)
                                             .With(x => x.FacilityLanguage, (CrabLanguage?)null)
                                             .With(x => x.Lifetime, new CrabLifetime(_fixture.Create <LocalDateTime>(), null))
                                             .With(x => x.Geometry, new WkbGeometry(GeometryHelpers.ExampleWkb))
                                             .Create();

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

            var municipalityWasRegistered = new MunicipalityWasRegistered(_municipalityId, importMunicipalityFromCrab.NisCode);

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

            var municipalityBecameCurrent = new MunicipalityBecameCurrent(_municipalityId);

            ((ISetProvenance)municipalityBecameCurrent).SetProvenance(provenance);

            var municipalityOfficialLanguageWasAdded = new MunicipalityOfficialLanguageWasAdded(_municipalityId, Language.Dutch);

            ((ISetProvenance)municipalityOfficialLanguageWasAdded).SetProvenance(provenance);

            var municipalitySecondOfficialLanguageWasAdded = new MunicipalityOfficialLanguageWasAdded(_municipalityId, Language.French);

            ((ISetProvenance)municipalitySecondOfficialLanguageWasAdded).SetProvenance(provenance);

            var municipalityWasDrawn = new MunicipalityWasDrawn(_municipalityId, new ExtendedWkbGeometry(GeometryHelpers.ExampleExtendedWkb));

            ((ISetProvenance)municipalityWasDrawn).SetProvenance(provenance);

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

                .When(importMunicipalityFromCrab)

                .Then(_municipalityId,
                      municipalityOfficialLanguageWasAdded,
                      municipalitySecondOfficialLanguageWasAdded,
                      municipalityWasDrawn,
                      municipalityBecameCurrent,
                      importMunicipalityFromCrab.ToLegacyEvent()));
        }
        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.")));
        }