public void Validate_Returns_1_Error_When_Access_Window_StartTime_Is_Lower_Than_Current_Date() { // Arrange var sut = new CreateDeliveryCommandValidator(); // Act var validation = sut.Validate(NewDeliveryCommand( new AccessWindowDto { StartTime = DateTime.UtcNow.AddHours(-1), EndTime = DateTime.UtcNow.AddHours(5) }, new OrderDto { OrderNumber = "123456", Sender = "Ikea", }, new RecipientDto { Address = "address", Email = "*****@*****.**", Name = "name", PhoneNumber = "+447000000000" }, userId: 123, partnerId: 456)); //Assert Assert.False(validation.IsValid); Assert.Equal(1, validation.Errors.Count); Assert.Equal("AccessWindow.StartTime", validation.Errors[0].PropertyName); Assert.Equal("GreaterThanValidator", validation.Errors[0].ErrorCode); }
public void Validate_Returns_1_Error_When_Access_Window_Is_Null() { // Arrange var sut = new CreateDeliveryCommandValidator(); // Act var validation = sut.Validate(NewDeliveryCommand( null, new OrderDto { OrderNumber = "123456", Sender = "Ikea", }, new RecipientDto { Address = "address", Email = "*****@*****.**", Name = "name", PhoneNumber = "+447000000000" }, userId: 123, partnerId: 456)); //Assert Assert.False(validation.IsValid); Assert.Equal(1, validation.Errors.Count); Assert.Equal("AccessWindow", validation.Errors[0].PropertyName); Assert.Equal("NotNullValidator", validation.Errors[0].ErrorCode); }
public void Validate_Returns_1_Error_When_Order_Sender_Length_Is_Greater_Than_Expected() { // Arrange var sut = new CreateDeliveryCommandValidator(); // Act var validation = sut.Validate(NewDeliveryCommand( new AccessWindowDto { StartTime = DateTime.UtcNow, EndTime = DateTime.UtcNow.AddHours(5) }, new OrderDto { OrderNumber = "123456", Sender = "sendersendersendersendersendersendersendersendersendersendersendersendersendersendersendersendersendersender", }, new RecipientDto { Address = "address", Email = "*****@*****.**", Name = "name", PhoneNumber = "+447000000000" }, userId: 123, partnerId: 456)); //Assert Assert.False(validation.IsValid); Assert.Equal(1, validation.Errors.Count); Assert.Equal("Order.Sender", validation.Errors[0].PropertyName); Assert.Equal("MaximumLengthValidator", validation.Errors[0].ErrorCode); }
public void Validate_Returns_1_Error_When_Recipient_Email_Is_Empty() { // Arrange var sut = new CreateDeliveryCommandValidator(); // Act var validation = sut.Validate(NewDeliveryCommand( new AccessWindowDto { StartTime = DateTime.UtcNow, EndTime = DateTime.UtcNow.AddHours(5) }, new OrderDto { OrderNumber = "123456", Sender = "Ikea", }, new RecipientDto { Address = "address", Email = "", Name = "name", PhoneNumber = "+447000000000" }, userId: 123, partnerId: 456)); //Assert Assert.False(validation.IsValid); Assert.Equal(1, validation.Errors.Count); Assert.Equal("Recipient.Email", validation.Errors[0].PropertyName); Assert.Equal("NotEmptyValidator", validation.Errors[0].ErrorCode); }
public void Validate_Returns_1_Error_When_Recipient_Is_Null() { // Arrange var sut = new CreateDeliveryCommandValidator(); // Act var validation = sut.Validate(NewDeliveryCommand( new AccessWindowDto { StartTime = DateTime.UtcNow, EndTime = DateTime.UtcNow.AddHours(5) }, new OrderDto { OrderNumber = "123456", Sender = "Ikea", }, null, userId: 123, partnerId: 456)); //Assert Assert.False(validation.IsValid); Assert.Equal(1, validation.Errors.Count); Assert.Equal("Recipient", validation.Errors[0].PropertyName); Assert.Equal("NotNullValidator", validation.Errors[0].ErrorCode); }
public void Validate_Returns_0_Error_When_All_The_Conditions_Are_Met() { // Arrange var sut = new CreateDeliveryCommandValidator(); // Act var validation = sut.Validate(NewDeliveryCommand( new AccessWindowDto { StartTime = DateTime.UtcNow, EndTime = DateTime.UtcNow.AddHours(5) }, new OrderDto { OrderNumber = "123456", Sender = "Ikea", }, new RecipientDto { Address = "address", Email = "*****@*****.**", Name = "name", PhoneNumber = "+447000000000" }, userId: 123, partnerId: 456)); //Assert Assert.True(validation.IsValid); }
public void SetUp() { this.drones = new List <Drone>(); this.droneRepository = new Mock <IRepository <Drone> >(); this.generalSettings = new Mock <IGeneralSettings>(); this.droneRepository.SetupGet(c => c.Items) .Returns(() => this.drones.AsQueryable()); this.generalSettings.SetupGet(c => c.MaxRoutesPerDrone) .Returns(() => this.maxRoutes); this.validator = new CreateDeliveryCommandValidator(this.droneRepository.Object, this.generalSettings.Object); this.model = new CreateDeliveryCommand(); }
public CreateDeliveryCommandValidatorTests() { _validator = new CreateDeliveryCommandValidator(); }