Exemplo n.º 1
0
        public void Should_create_line_with_all_properties_witho_one_full_specification()
        {
            var expected = new object[] {
                "PartnerPartNumber",
                new object[] {
                    new object[]
                    { SpecificationType.Full, "Label", "Value", "UnitOfMeasure", "Id", "GroupId", "GroupName" }
                }
            };
            var specifications = new Specifications {
                PartnerPartNumber = (string)expected[(int)CasSpecificationsColumnEnum.PartnerPartNumber],
                Items             = ((object[])expected[(int)CasSpecificationsColumnEnum.Items])
                                    .Select(x => {
                    var option = (object[])x;
                    return(new Specification {
                        Type = (SpecificationType)option[(int)CasSpecificationColumnEnum.Type],
                        Label = (string)option[(int)CasSpecificationColumnEnum.Label],
                        Value = (string)option[(int)CasSpecificationColumnEnum.Value],
                        UnitOfMeasure = (string)option[(int)CasSpecificationColumnEnum.UnitOfMeasure],
                        Id = (string)option[(int)CasSpecificationColumnEnum.Id],
                        GroupId = (string)option[(int)CasSpecificationColumnEnum.GroupId],
                        GroupName = (string)option[(int)CasSpecificationColumnEnum.GroupName]
                    });
                })
                                    .ToList()
            };
            var writer =
                new CsvSpecificationsGenerator(
                    new DefaultObjectPool <StringBuilder>(new StringBuilderPooledObjectPolicy()));

            writer.TryGenerateLine(specifications, out var data);
            data.Should().Be($"{string.Join("\t", expected.Select(x => x.ToDebugString()))}{Environment.NewLine}");
        }
Exemplo n.º 2
0
        public void Should_create_line_with_all_properties_null()
        {
            var specifications = new Specifications {
                PartnerPartNumber = "0"
            };
            var writer =
                new CsvSpecificationsGenerator(
                    new DefaultObjectPool <StringBuilder>(new StringBuilderPooledObjectPolicy()));

            writer.TryGenerateLine(specifications, out var data).Should().BeFalse();
            data.Should().BeNull();
        }
Exemplo n.º 3
0
        public void Should_skip_line_with_all_properties_without_options()
        {
            var expected       = new object[] { "PartnerPartNumber", null };
            var specifications = new Specifications {
                PartnerPartNumber = (string)expected[(int)CasSpecificationsColumnEnum.PartnerPartNumber],
                Items             = (List <Specification>)expected[(int)CasSpecificationsColumnEnum.Items]
            };
            var writer =
                new CsvSpecificationsGenerator(
                    new DefaultObjectPool <StringBuilder>(new StringBuilderPooledObjectPolicy()));

            writer.TryGenerateLine(specifications, out var data).Should().BeFalse();
            data.Should().BeNull();
        }