コード例 #1
0
        public void ForKeyFromNestedCollectionsWithIndexersShouldAddNewErrorWithProperName()
        {
            var errors = new ResultErrorsDictionary();

            errors.Add <Model>(m => m.CollectionA[0].CollectionB[0].PropertyD, "value");
            errors.Should().BeEquivalentTo(new Dictionary <string, string[]> {
                [$"Model.{nameof(Model.CollectionA)}.{nameof(Model.PropertyB.CollectionB)}.{nameof(Model.PropertyB.PropertyC.PropertyD)}"] = new[] { "value" }
            });
        }
コード例 #2
0
        public void ForKeyFromNestedClassMixedWithStructsPropertyShouldAddNewErrorWithProperName()
        {
            var errors = new ResultErrorsDictionary();

            errors.Add <Model>(m => m.PropertyB.PropertyC.PropertyD, "value");
            errors.Should().BeEquivalentTo(new Dictionary <string, string[]> {
                [$"Model.{nameof(Model.PropertyB)}.{nameof(Model.PropertyB.PropertyC)}.{nameof(Model.PropertyB.PropertyC.PropertyD)}"] = new[] { "value" }
            });
        }
コード例 #3
0
        public void ForKeyFromClassPropertyShouldAddNewErrorWithProperName()
        {
            var errors = new ResultErrorsDictionary();

            errors.Add <Model>(m => m.PropertyA, "value");
            errors.Should().BeEquivalentTo(new Dictionary <string, string[]> {
                [$"Model.{nameof(Model.PropertyA)}"] = new[] { "value" }
            });
        }
コード例 #4
0
        public void ForNewStringKeyShouldAddNewError()
        {
            var errors = new ResultErrorsDictionary
            {
                { "key", "value" }
            };

            errors.Should().BeEquivalentTo(new Dictionary <string, string[]> {
                ["key"] = new[] { "value" }
            });
        }
コード例 #5
0
        public void ForAlreadyExistingStringKeyShouldAddNewErrorMessage()
        {
            var errors = new ResultErrorsDictionary
            {
                { "key", "value" },
                { "key", "value2" }
            };

            errors.Should().BeEquivalentTo(new Dictionary <string, string[]> {
                ["key"] = new[] { "value", "value2" }
            });
        }