public async Task AddTreeAndFindWithInclude() { #region Arrange var repository = Context.MyDisconnectedEntities; var nestedEntityBefore = new MyNestedEntity() { Id = 1, Name = Guid.NewGuid().ToString() }; var entityBefore = new MyEntity() { Id = 1, AddedDate = DateTime.Now.AddDays(-1), Name = "Component before", MyNestedEntity = nestedEntityBefore }; repository.Add(entityBefore); Context.Save(); #endregion #region Act RootSpecification <MyEntity> createdBefore = new MyEntityCreatedBeforeSpecification(DateTime.Now); var entities = await repository.FindAsync(createdBefore); #endregion #region Assert Assert.NotNull(entities); Assert.Equal(1, entities.First().Id); Assert.NotNull(entities.First().MyNestedEntity); Assert.Equal(1, entities.First().MyNestedEntity.Id); Assert.Equal(1, entities.First().Id); #endregion }
public async Task AddAndFindAsync() { #region Arrange var repository = Context.MyDisconnectedEntities; var entityAfter = new MyEntity() { AddedDate = DateTime.Now.AddDays(1), Name = "Component after" }; var entityBefore = new MyEntity() { AddedDate = DateTime.Now.AddDays(-1), Name = "Component before" }; //-- Add 2 entities repository.Add(entityAfter); repository.Add(entityBefore); Context.Save(); var nbAdded = await repository.AllAsync(); #endregion #region Act RootSpecification <MyEntity> createdBefore = new MyEntityCreatedBeforeSpecification(DateTime.Now); var entities = await repository.FindAsync(createdBefore); #endregion #region Assert Assert.Equal(2, nbAdded.Count()); Assert.Single(entities); Assert.Equal("Component before", entities.FirstOrDefault().Name); #endregion }