示例#1
0
        public void Validate_InvalidDto_ReturnsErrors()
        {
            var fixture   = new Fixture();
            var items     = fixture.CreateMany <Foo>();
            var updateDto = new UpdateFooDto {
                Id = Guid.NewGuid(), Name = fixture.Create <string>()
            };

            var fooRepository = new FooRepository(items);
            var validator     = new UpdateFooValidator(fooRepository);

            var validationResult = validator.Validate(updateDto);

            Assert.That(validationResult.IsValid, Is.False);
            Assert.That(validationResult.Errors.Count, Is.EqualTo(1));
        }
示例#2
0
        public void Validate_ValidDto_NoErrors()
        {
            var fixture      = new Fixture();
            var items        = fixture.CreateMany <Foo>();
            var itemToUpdate = items.First();
            var updateDto    = new UpdateFooDto {
                Id = itemToUpdate.Id, Name = fixture.Create <string>()
            };

            var fooRepository = new FooRepository(items);
            var validator     = new UpdateFooValidator(fooRepository);

            var validationResult = validator.Validate(updateDto);

            Assert.That(validationResult.IsValid, Is.True);
            Assert.That(validationResult.Errors.Count, Is.EqualTo(0));
        }