public void WhenAddingEntity_ThenGetAndUpdate()
        {
            DatabaseTestUtility.DropCreateFirebrickDatabase();

            // Arrange
            var repository = new DomainRepository(new DatabaseFactory());
            Domain newEntity = DefaultModelHelper.DummyPopulatedDomain();

            // Act
            repository.Add(newEntity);
            repository.Commit();

            // Use a new context and repository to verify the vehicle was added
            var repositoryTwo = new DomainRepository(new DatabaseFactory());
            Domain loadedEntity = repositoryTwo.GetById(1);

            loadedEntity.HostHeader = "NewHostHeader";

            repositoryTwo.Update(loadedEntity);
            repositoryTwo.Commit();

            // Use a new context and repository to verify the vehicle was added
            var repositoryThree = new DomainRepository(new DatabaseFactory());
            newEntity = repositoryThree.GetById(1);

            Assert.NotNull(newEntity);
            Assert.Equal("NewHostHeader", newEntity.HostHeader);
        }
예제 #2
0
 /// <summary>
 /// Get's a persisted aggregate root by a given id
 /// </summary>
 /// <typeparam name="T">Type of aggregate root to load</typeparam>
 /// <param name="id">Id of the root object</param>
 /// <returns>Aggregate root of type T with events and snapshots replayed</returns>
 public virtual T GetById <T>(Guid id) where T : AggregateRoot, new()
 {
     return(_repository.GetById <T>(id));
 }
 protected override void Because()
 {
     scheduleMeetingCommandHandler.Handle(scheduleMeetingCommand);
     meeting = repository.GetById <Meeting>(meetingId);
 }