コード例 #1
0
ファイル: ConverterTest.cs プロジェクト: tgropper/Bardock.R2O
        public void Convert_DynamicObjectWithInvalidColumnName_ShouldThrowInvalidColumnException(Converter sut)
        {
            //Setup
            var invalidColumnName = "address..zipCode";
            var columns = new List<string>() {
                "id",
                "name",
                "value"
            };
            var matrix = new List<List<object>>()
            {
                new List<object>() { 1, invalidColumnName, "firstName1" }
            };

            //Exercise
            Action exercise = () => sut.ConvertDynamic(columns, matrix);

            //Verify
            exercise.ShouldThrow<ConverterInvalidColumnNameException>()
                .Where(x => x.Message.Contains(invalidColumnName));
        }
コード例 #2
0
ファイル: ConverterTest.cs プロジェクト: tgropper/Bardock.R2O
        public void Convert_NestedDynamicObject_ShouldSucced(Converter sut)
        {
            //Setup
            var columns = new List<string>() {
                "id",
                "name",
                "value"
            };
            var matrix = new List<List<object>>()
            {
                new List<object>() { 1, "city.name", "cityName" },
                new List<object>() { 1, "city.country.isoCode", "countryIsoCode" },
                new List<object>() { 2, "school.name", "schoolName" }
            };

            //Exercise
            var actual = sut.ConvertDynamic(columns, matrix);

            //Verify
            actual.Should().HaveCount(2)
                .And.DeepContain(new Dictionary<string, object>()
                {
                    { "id", 1},
                    { "city", new Dictionary<string, object>()
                        {
                            { "name", "cityName" },
                            { "country", new Dictionary<string, object>()
                                {
                                    { "isoCode", "countryIsoCode" }
                                }
                           }
                        }
                    }
                })
                .And.DeepContain(new Dictionary<string, object>()
                {
                    { "id", 2},
                    { "school", new Dictionary<string, object>()
                        {
                            { "name", "schoolName" }
                        }
                    }
                });
        }
コード例 #3
0
ファイル: ConverterTest.cs プロジェクト: tgropper/Bardock.R2O
        public void Convert_DynamicObjectWithRepeatedColumns_ShouldThrowRepeatedColumnException(Converter sut)
        {
            //Setup
            var repeatedLabelName = "firstName";
            var columns = new List<string>() {
                "id",
                "name",
                "value"
            };
            var matrix = new List<List<object>>()
            {
                new List<object>() { 1, repeatedLabelName, "firstName1" },
                new List<object>() { 1, repeatedLabelName, "firstName2" }
            };

            //Exercise
            Action exercise = () => sut.ConvertDynamic(columns, matrix);

            //Verify
            exercise.ShouldThrow<ConverterRepeatedColumnException>()
                .Where(x => x.Message.Contains(repeatedLabelName));
        }
コード例 #4
0
ファイル: ConverterTest.cs プロジェクト: tgropper/Bardock.R2O
        public void Convert_SimpleDynamicObject_ShouldSucced(Converter sut)
        {
            //Setup
            var columns = new List<string>() {
                "id",
                "name",
                "value"
            };
            var matrix = new List<List<object>>()
            {
                new List<object>() { 1, "firstName", "firstName" },
                new List<object>() { 1, "lastName", "lastName" },
                new List<object>() { 2, "hasPets", true }
            };

            //Exercise
            var actual = sut.ConvertDynamic(columns, matrix);

            //Verify
            actual.Should().NotBeEmpty()
                .And.HaveCount(2)
                .And.DeepContain(new Dictionary<string, object>() { { "id", 1 }, { "firstName", "firstName" }, { "lastName", "lastName" } })
                .And.DeepContain(new Dictionary<string, object>() { { "id", 2 }, { "hasPets", true } });
        }