public async Task Given_MunicipalityWasRegistered_Then_expected_item_is_added() { var projection = new MunicipalityListProjections(); var resolver = ConcurrentResolve.WhenEqualToHandlerMessageType(projection.Handlers); var municipalityId = Guid.NewGuid(); var nisCode = "123"; var municipalityWasRegistered = new MunicipalityWasRegistered(new MunicipalityId(municipalityId), new NisCode(nisCode)); ((ISetProvenance)municipalityWasRegistered).SetProvenance(_provenance); await new ConnectedProjectionScenario <LegacyContext>(resolver) .Given( new Envelope <MunicipalityWasRegistered>(new Envelope( municipalityWasRegistered, EmptyMetadata))) .Verify(async context => { var municipality = await context.MunicipalityList.FirstAsync(a => a.MunicipalityId == municipalityId); municipality.MunicipalityId .Should() .Be(municipalityId); municipality.NisCode .Should() .Be(nisCode); return(VerificationResult.Pass()); }) .Assert(); }
public async Task Given_no_messages_Then_list_is_empty() { var projection = new MunicipalityListProjections(); var resolver = ConcurrentResolve.WhenEqualToHandlerMessageType(projection.Handlers); await new ConnectedProjectionScenario <LegacyContext>(resolver) .Given() .Verify(async context => await context.MunicipalityList.AnyAsync() ? VerificationResult.Fail() : VerificationResult.Pass()) .Assert(); }
public async Task Given_MunicipalityWasNamed_twice_and_municipality_was_registered_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 municipalityWasNamed = new MunicipalityWasNamed(municipalityId, new MunicipalityName("test", Language.Dutch)); ((ISetProvenance)municipalityWasNamed).SetProvenance(_provenance); var wasNamed = new MunicipalityWasNamed(municipalityId, new MunicipalityName("test21", Language.French)); ((ISetProvenance)wasNamed).SetProvenance(_provenance); await new ConnectedProjectionScenario <LegacyContext>(resolver) .Given( new Envelope <MunicipalityWasRegistered>(new Envelope( municipalityWasRegistered, EmptyMetadata)), new Envelope <MunicipalityWasNamed>(new Envelope( municipalityWasNamed, EmptyMetadata)), new Envelope <MunicipalityWasNamed>(new Envelope( wasNamed, EmptyMetadata))) .Verify(async context => { var municipality = await context.MunicipalityList.FirstAsync(a => a.MunicipalityId == municipalityId); municipality.MunicipalityId.Should().Be((Guid)municipalityId); municipality.NameDutch.Should().Be("test"); municipality.NameFrench.Should().Be("test21"); return(VerificationResult.Pass()); }) .Assert(); }
public async Task Given_MunicipalityDefinedNisCode_Then_nisCode_should_be_changed() { 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 municipalityNisCodeWasDefined = new MunicipalityNisCodeWasDefined(municipalityId, new NisCode(nisCode)); ((ISetProvenance)municipalityNisCodeWasDefined).SetProvenance(_provenance); await new ConnectedProjectionScenario <LegacyContext>(resolver) .Given( new Envelope <MunicipalityWasRegistered>(new Envelope( municipalityWasRegistered, EmptyMetadata)), new Envelope <MunicipalityNisCodeWasDefined>(new Envelope( municipalityNisCodeWasDefined, EmptyMetadata))) .Verify(async context => { var municipality = await context.MunicipalityList.FirstAsync(a => a.NisCode == nisCode); municipality.MunicipalityId.Should().Be((Guid)municipalityId); municipality.NisCode.Should().Be(nisCode); return(VerificationResult.Pass()); }) .Assert(); }
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(); }