public void SerializeFromQueryTree_FromStream_AndReserialized_WithPartner()
        {
            var regions = new[] { "en-US", "en-GB", "es-MX", "es-ES", "de" };
            // Given
            var partnerFixture = new Faker <Dto>()
                                 .RuleFor(x => x.id, f => f.IndexGlobal)
                                 .RuleFor(x => x.Name, f => f.Person.FirstName)
                                 .RuleFor(x => x.region_code, f => f.PickRandom(regions))
                                 .RuleFor(x => x.partner, f => null)
                                 .RuleFor(x => x.favorite, f => null)
                                 .RuleFor(x => x.children, f => new List <DtoChild>());
            var fixture = new Faker <Dto>()
                          .RuleFor(x => x.id, f => f.IndexGlobal)
                          .RuleFor(x => x.Name, f => f.Person.FirstName)
                          .RuleFor(x => x.region_code, f => f.PickRandom(regions))
                          .RuleFor(x => x.partner, f => partnerFixture.Generate())
                          .RuleFor(x => x.favorite, f => null)
                          .RuleFor(x => x.children, f => new List <DtoChild>());

            var query = fixture.Generate(10).ToList();

            query.AddRange(query.Select(x => x.partner).ToList());
            var nodata  = new NoDataBuilder <Dto>(new Parameters("partner"), DefaultSettingsForType <Dto> .SettingsForType);
            var rawText = new StreamReader(nodata.Load(query.AsQueryable()).Stream()).ReadToEnd();

            // When
            var result = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Dto> >(rawText);

            // Then
            result.Should().BeEquivalentTo(query);
        }
예제 #2
0
        public void EfficiencyTests_NPlusOneTests_SetupIsValid_Queryable_BuilderApply_CalledOnce()
        {
            var queryable = ParentCollection().AsQueryable();
            var nodata    = new NoDataBuilder <Person>(null, null, null);
            var lst       = nodata.Load(queryable).BuildQueryable().ToList();

            lst.Should().NotBeNullOrEmpty();
            parentCalls.Should().Be(1);
        }
예제 #3
0
        public void EfficiencyTests_NPlusOneTests_SetupIsValid_Json()
        {
            var queryable = ParentCollection().AsQueryable();
            var nodata    = new NoDataBuilder <Person>(null, null, null);
            var json      = nodata.Load(queryable).AsJson();

            json.Should().NotBeNullOrEmpty();
            parentCalls.Should().Be(1);
        }
        public void SerializeFromQueryTree_FromStream_ReturnsText()
        {
            // Given
            var query  = FlatDtoEnumerable().ToList();
            var nodata = new NoDataBuilder <Dto>(new Parameters(), DefaultSettingsForType <Dto> .SettingsForType);

            // When
            var rawText = new StreamReader(nodata.Load(query.AsQueryable()).Stream()).ReadToEnd();

            // Then
            rawText.Should().NotBeNullOrWhiteSpace();
        }
        public void SerializeFromQueryTree_FromStream_AndReserialized_SamePrimitiveTypes()
        {
            // Given
            var query   = FlatDtoEnumerable().ToList();
            var nodata  = new NoDataBuilder <Dto>(new Parameters(), DefaultSettingsForType <Dto> .SettingsForType);
            var rawText = new StreamReader(nodata.Load(query.AsQueryable()).Stream()).ReadToEnd();

            // When
            var result = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Dto> >(rawText);

            // Then
            result.Should().BeEquivalentTo(query);
        }