private void AssertValidDtoGraph(Detail detail, Master master, DetailCyclicDto dto)
        {
            dto.ShouldNotBeNull();
            detail.Id.ShouldEqual(dto.Id);

            detail.Master.ShouldNotBeNull();
            master.Details.ShouldNotBeEmpty();
            detail.Master.Id.ShouldEqual(master.Id);
            
            dto.Master.Details.Single().Id.ShouldEqual(dto.Id, "Dto was not added to inner collection");
            //dto.GetHashCode().ShouldEqual(dto.Master.Details.Single().GetHashCode()); // "Underlying provider always creates two distinct instances"
        }
        public void CanMapCaclicExpressionGraph_WithPropertyPathEqualityFilter_Single()
        {
            // Arrange
            var mapper = SetupAutoMapper();
            var master = new Master()
            {
                Name = "Harry Marry",
                Id = Guid.NewGuid(),
            };
            var detail = new Detail()
            {
                Id = Guid.NewGuid(),
                Name = "Test Order",
                Master = master,
            };
            master.Details.Add(detail);
            var detailQuery = new List<Detail> { detail }.AsQueryable();

            // Act
            var detailDtoQuery = detailQuery.UseAsDataSource(mapper)
                .For<DetailCyclicDto>()
                .Where(d => d.Master.Name == "Harry Marry");

            // Assert
            var dto = detailDtoQuery.Single();

            AssertValidDtoGraph(detail, master, dto);
        }
        public void Should_support_propertypath_expressons_with_equally_named_properties()
        {
            // Arrange
            var mapper = SetupAutoMapper();

            var master = new Master { Id = Guid.NewGuid(), Name = "Harry Marry" };
            var detail = new Detail { Id = Guid.NewGuid(), Master = master, Name = "Some detail" };
            master.Details.Add(detail);
            var source = new List<Detail> { detail };

            // Act
            var detailDtoQuery = source.AsQueryable().UseAsDataSource(mapper)
                .For<DetailDto>()
                .Where(d => d.Master.Name == "Harry Marry");

            // Assert
            detailDtoQuery.ToList().Count().ShouldEqual(1);
        }
        public void CanMapCyclicObjectGraph()
        {
            // Arrange
            var mapper = SetupAutoMapper();
            var master = new Master()
            {
                Name = "Harry Marry",
                Id = Guid.NewGuid(),
            };
            var detail = new Detail()
            {
                Id = Guid.NewGuid(),
                Name = "Test Order",
                Master = master,
            };
            master.Details.Add(detail);

            // Act
            var dto = mapper.Map<DetailCyclicDto>(detail);

            // Assert
            AssertValidDtoGraph(detail, master, dto);
        }