public void WithNewSecondaryLanguage() { 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, (WkbGeometry)null) .Create(); var municipalityWasRegistered = new MunicipalityWasRegistered(_municipalityId, importMunicipalityFromCrab.NisCode); ((ISetProvenance)municipalityWasRegistered).SetProvenance(CreateProvenance(1)); var municipalityOfficialLanguageWasAdded = new MunicipalityOfficialLanguageWasAdded(_municipalityId, Language.French); ((ISetProvenance)municipalityOfficialLanguageWasAdded).SetProvenance(CreateProvenance(1)); Assert( new Scenario() .Given(_municipalityId, municipalityWasRegistered, _fixture.Create <MunicipalityNisCodeWasDefined>(), _fixture.Create <MunicipalityOfficialLanguageWasAdded>(), _fixture.Create <MunicipalityBecameCurrent>()) .When(importMunicipalityFromCrab) .Then(_municipalityId, municipalityOfficialLanguageWasAdded, importMunicipalityFromCrab.ToLegacyEvent())); }
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 ThenMunicipalityIsRegistered() { var municipalityWasRegistered = new MunicipalityWasRegistered(_municipalityId, _importMunicipalityFromCrab.NisCode); ((ISetProvenance)municipalityWasRegistered).SetProvenance(CreateProvenance(1)); var municipalityOfficialLanguageWasAdded = new MunicipalityOfficialLanguageWasAdded(_municipalityId, Language.Dutch); ((ISetProvenance)municipalityOfficialLanguageWasAdded).SetProvenance(CreateProvenance(1)); var municipalitySecondOfficialLanguageWasAdded = new MunicipalityOfficialLanguageWasAdded(_municipalityId, Language.French); ((ISetProvenance)municipalitySecondOfficialLanguageWasAdded).SetProvenance(CreateProvenance(1)); var facilityLanguageWasAdded = new MunicipalityFacilityLanguageWasAdded(_municipalityId, Language.English); ((ISetProvenance)facilityLanguageWasAdded).SetProvenance(CreateProvenance(1)); var municipalityWasDrawn = new MunicipalityWasDrawn(_municipalityId, new ExtendedWkbGeometry(GeometryHelpers.ExampleExtendedWkb)); ((ISetProvenance)municipalityWasDrawn).SetProvenance(CreateProvenance(1)); var municipalityBecameCurrent = new MunicipalityBecameCurrent(_municipalityId); ((ISetProvenance)municipalityBecameCurrent).SetProvenance(CreateProvenance(1)); Assert( new Scenario() .GivenNone() .When(_importMunicipalityFromCrab) .Then(_municipalityId, municipalityWasRegistered, municipalityOfficialLanguageWasAdded, municipalitySecondOfficialLanguageWasAdded, facilityLanguageWasAdded, municipalityWasDrawn, municipalityBecameCurrent, _importMunicipalityFromCrab.ToLegacyEvent())); }
public async Task Given_MunicipalityDefinedPrimaryLanguage_Then_expected_item_is_updated() { var projection = new MunicipalityListProjections(); var resolver = ConcurrentResolve.WhenEqualToHandlerMessageType(projection.Handlers); var crabMunicipalityId = new CrabMunicipalityId(1); var municipalityId = MunicipalityId.CreateFor(crabMunicipalityId); var nisCode = "456"; var municipalityWasRegistered = new MunicipalityWasRegistered(municipalityId, new NisCode(nisCode)); ((ISetProvenance)municipalityWasRegistered).SetProvenance(_provenance); var municipalityOfficialLanguageWasAdded = new MunicipalityOfficialLanguageWasAdded(municipalityId, Language.Dutch); ((ISetProvenance)municipalityOfficialLanguageWasAdded).SetProvenance(_provenance); await new ConnectedProjectionScenario <LegacyContext>(resolver) .Given( new Envelope <MunicipalityWasRegistered>(new Envelope( municipalityWasRegistered, EmptyMetadata)), new Envelope <MunicipalityOfficialLanguageWasAdded>(new Envelope( municipalityOfficialLanguageWasAdded, EmptyMetadata))) .Verify(async context => { var municipality = await context.MunicipalityList.FirstAsync(a => a.MunicipalityId == municipalityId); municipality.MunicipalityId.Should().Be((Guid)municipalityId); municipality.OfficialLanguages.Should().AllBeEquivalentTo(Language.Dutch); return(VerificationResult.Pass()); }) .Assert(); }
private void When(MunicipalityOfficialLanguageWasAdded @event) { _officialLanguages.Add(@event.Language); }