Esempio n. 1
0
        internal void CreateUserCreatedEventAndSaveOnEventStore(string userCreateUserId, string userCreatedUserName, string userCreatedUserEmail, int userCreatedVersion, string createUserUserId, string createUserUserName, string createUserUserEmail, int createUserVersion)
        {
            var createUserCommand = BuildCreateUserCommand(createUserUserId, createUserUserName, createUserUserEmail, createUserVersion);
            var userCreatedEvent  = BuildUserCreatedEvent(UserId.FromString(userCreateUserId), userCreatedUserName, userCreatedUserEmail, userCreatedVersion);

            EventStore.SaveEvents(createUserCommand, EntityId.FromString(userCreateUserId), new IEvent[] { userCreatedEvent }, createUserCommand.Version);
        }
Esempio n. 2
0
 private ChangeUserEmailCommand BuildChangeUserEmailCommand(string userId, string newUserEmail, int version)
 {
     return(new ChangeUserEmailCommand()
     {
         UserId = UserId.FromString(userId), NewUserEmail = newUserEmail, Version = version
     });
 }
Esempio n. 3
0
 private CreateUserCommand BuildCreateUserCommand(string userId, string userName, string userEmail, int version)
 {
     return(new CreateUserCommand()
     {
         UserId = UserId.FromString(userId), UserName = userName, UserEmail = userEmail, Version = version
     });
 }
Esempio n. 4
0
 internal void AssertThatCommandHandlerReceivedCreateUserCommand(string userId, string userName, string userEmail, int version)
 {
     CreateUserCommandReceivedOnHandler.Should().NotBeNull();
     CreateUserCommandReceivedOnHandler.UserId.Should().Be(UserId.FromString(userId));
     CreateUserCommandReceivedOnHandler.UserName.Should().Be(userName);
     CreateUserCommandReceivedOnHandler.UserEmail.Should().Be(userEmail);
     CreateUserCommandReceivedOnHandler.Version.Should().Be(version);
 }
Esempio n. 5
0
        internal void AssertThatUserIsSavedRepository(string userId, string userName, string userEmail, int version)
        {
            var user = FindUserOnRepository(userId);

            user.Should().NotBeNull();
            user.Id.Should().Be(UserId.FromString(userId));
            user.Name.Should().Be(userName);
            user.Email.Should().Be(userEmail);
            user.Version.Should().Be(version);
        }
Esempio n. 6
0
        internal void AssertThatUserEmailChangedWasPublished(string userId, string userName, string newUserEmail, int version)
        {
            var userEventChangedEvent = BuildUserEmailChangedEvent(UserId.FromString(userId), userName, newUserEmail, version);

            userEventChangedEvent.Should().NotBeNull();
            var userEmailChangedPublished = PublisedUserEmailChangedEvents.FirstOrDefault(s => s.UserId == userEventChangedEvent.UserId && s.Version == userEventChangedEvent.Version);

            userEmailChangedPublished.Should().NotBeNull();
            AreUserEmailChangeEventsEqual(userEmailChangedPublished, userEventChangedEvent).Should().BeTrue();
        }
Esempio n. 7
0
        private Snapshot <User> BuildUserSnapshotEvent(string userId, string userName, string userEmail, int version)
        {
            var user = new User();

            user.Id      = UserId.FromString(userId);
            user.Name    = userName;
            user.Email   = userEmail;
            user.Version = version;
            return(new Snapshot <User>()
            {
                Object = user, Version = version
            });
        }
Esempio n. 8
0
        internal void AssertThatUserEmailChangedEventWasnotStoredOnEventStore(string userId, string userName, string newUserEmail, int version)
        {
            var userEventChangedEvent = BuildUserEmailChangedEvent(UserId.FromString(userId), userName, newUserEmail, version);

            userEventChangedEvent.Should().NotBeNull();
            var userEvents = EventStore.AllEvents(EntityId.FromString(userId));
            var userEmailChangedEventWasStoredOnEventStore = userEvents.Any(userEvent =>
            {
                return(IsOfType <UserEmailChanged>(userEvent) && AreUserEmailChangeEventsEqual(userEventChangedEvent, userEvent as UserEmailChanged));
            });

            userEmailChangedEventWasStoredOnEventStore.Should().BeFalse();
        }
Esempio n. 9
0
        public static Travel FromDalModel(TravelDal travelDal)
        {
            List <Customer> customers = new List <Customer>();

            if (travelDal.Customers != null && travelDal.Customers.Count > 0)
            {
                foreach (var customer in travelDal.Customers)
                {
                    customers.Add(new Customer(UserId.FromString(customer.Id), customer.FirstName, customer.SurName));
                }
            }

            return(new Travel(TravelId.FromString(travelDal.Id), travelDal.Destination, customers));
        }
Esempio n. 10
0
        internal void CreateUserEmailChangedEventAndSaveOnEventStore(string userEmailChangedUserId, string userEmailChangedUserName, string userEmailChangedNewUserEmail, int userEmailChangedEventVersion, string createUserUserId, string createUserUserEmail, int createUserVersion)
        {
            var changeUserEmailCommand = BuildChangeUserEmailCommand(createUserUserId, createUserUserEmail, createUserVersion);
            var userEmailChangedEvent  = BuildUserEmailChangedEvent(UserId.FromString(userEmailChangedUserId), userEmailChangedUserName, userEmailChangedNewUserEmail, userEmailChangedEventVersion);

            try
            {
                EventStore.SaveEvents(changeUserEmailCommand, EntityId.FromString(userEmailChangedUserId), new IEvent[] { userEmailChangedEvent }, changeUserEmailCommand.Version);
            }
            catch (ConcurrencyException e)
            {
                ConcurrencyTransactionException = e;
            }
        }
Esempio n. 11
0
        public void Configure(EntityTypeBuilder <Advertisement> builder)
        {
            builder.Property(c => c.Price).HasConversion(c => c.Value.Value,
                                                         d => Price.FromLong(d));

            builder.Property(c => c.OwnerId).HasConversion(c => c.Value.ToString(),
                                                           d => UserId.FromString(d));

            builder.Property(c => c.ApprovedBy).HasConversion(c => c.Value.ToString(),
                                                              d => UserId.FromString(d));

            builder.Property(c => c.Description).HasConversion(c => c.Value,
                                                               d => AdvertisementDescription.FromString(d));

            builder.Property(c => c.Title).HasConversion(c => c.Value,
                                                         d => AdvertisementTitle.FromString(d));
        }
Esempio n. 12
0
 public static Customer FromDalModel(CustomerDal customerDal)
 {
     return(new Customer(UserId.FromString(customerDal.Id), customerDal.FirstName, customerDal.SurName));
 }