Ejemplo n.º 1
0
        public async Task StreetNamePersistentLocalIdWasAssignedAssignsOsloId()
        {
            var id = Arrange(Produce.Guid());
            var persistentLocalId = Arrange(Produce.Integer(10000, 15000));

            await GivenEvents(Generate.EventsFor.StreetName(id))
            .Project(Generate.StreetNamePersistentLocalIdWasAssigned
                     .Select(e => e.WithId(id)
                             .WithPersistentLocalId(persistentLocalId)))
            .Then(async ct =>
            {
                var entity = await ct.FindAsync <StreetNameListItem>(id);
                entity.Should().NotBeNull();
                entity.PersistentLocalId.Should().Be(persistentLocalId);
            });
        }
        public void AppliesPersistentLocalIdWhenAlreadyAssignedDoesNothing()
        {
            //Arrange
            var streetNameId      = Arrange(Generate.StreetNameId);
            var sut               = RegisterWithId(streetNameId);
            var persistentLocalId = Arrange(Produce.Integer(10000, 15000));
            var date              = Arrange(Produce.Instant());

            sut.AssignPersistentLocalId(new PersistentLocalId(persistentLocalId), new PersistentLocalIdAssignmentDate(date));
            sut.ClearChanges();

            //Act
            sut.AssignPersistentLocalId(new PersistentLocalId(Arrange(Produce.Integer(10000, 15000))), new PersistentLocalIdAssignmentDate(date));

            //Assert
            sut.Should().HaveCountOfChanges <object>(0);
        }
        public void AppliesPersistentLocalIdWasAssigned()
        {
            //Arrange
            var streetNameId      = Arrange(Generate.StreetNameId);
            var sut               = RegisterWithId(streetNameId);
            var date              = Arrange(Produce.Instant());
            var persistentLocalId = Arrange(Produce.Integer(10000, 15000));

            //Act
            sut.AssignPersistentLocalId(new PersistentLocalId(persistentLocalId), new PersistentLocalIdAssignmentDate(date));

            //Assert
            sut.Should().HaveChanges();
            sut.Should().HaveSingleChange <StreetNamePersistentLocalIdWasAssigned>()
            .Which.Should().HaveStreetNameId(streetNameId)
            .And.HavePersistentLocalId(persistentLocalId)
            .And.HaveAssignmentDate(date);
        }
        public async Task MunicipalityEventInsertsRecord(MunicipalityEvent @event)
        {
            var id       = Arrange(Produce.Guid());
            var position = Arrange(Produce.Integer(100, 6000));

            await Given()
            .Project(Generate.AtomEntry(@event, position)
                     .Select(e => e
                             .WithObjectId <Gemeente>(id))
                     .Generate(new Random()))
            .Then(async context =>
            {
                var entry = await context.FindAsync <MunicipalitySyndicationItem>(id, (long)position);

                entry.Should().NotBeNull();
                entry.MunicipalityId.Should().Be(id);
                entry.Position.Should().Be(position);
            });
        }