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" } }); }
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" } }); }
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" } }); }
public void ForNewStringKeyShouldAddNewError() { var errors = new ResultErrorsDictionary { { "key", "value" } }; errors.Should().BeEquivalentTo(new Dictionary <string, string[]> { ["key"] = new[] { "value" } }); }
public void ForAlreadyExistingStringKeyShouldAddNewErrorMessage() { var errors = new ResultErrorsDictionary { { "key", "value" }, { "key", "value2" } }; errors.Should().BeEquivalentTo(new Dictionary <string, string[]> { ["key"] = new[] { "value", "value2" } }); }