public void Should_PassRegisteredUserPostLogicValidation_When_AllRulesPass() { // Arrange var restaurantSelectionDtoValidator = new RestaurantSelectionDtoValidator(); var restaurantSelectionDto = new RestaurantSelectionDto { City = "Los Angeles", State = "CA", FoodType = "American Food", DistanceInMiles = 10, FoodPreferences = new List <string> { "Halal", "Vegetarian" }, AvgFoodPrice = 1, CurrentUtcDateTime = DateTime.UtcNow }; // Act var result = restaurantSelectionDtoValidator.Validate(restaurantSelectionDto, ruleSet: "RegisteredUserPostLogic"); var isValid = result.IsValid; // Assert isValid.Should().Be(true); }
public void Should_FailRegisteredUserPostLogicValidation_When_CurrentUtcDateTimeIsEmpty() { // Arrange var restaurantSelectionDtoValidator = new RestaurantSelectionDtoValidator(); var restaurantSelectionDto = new RestaurantSelectionDto { City = "Los Angeles", State = "CA", FoodType = "", DistanceInMiles = 10, AvgFoodPrice = 1 }; // Act var result = restaurantSelectionDtoValidator.Validate(restaurantSelectionDto, ruleSet: "RegisteredUserPostLogic"); var isValid = result.IsValid; // Assert isValid.Should().Be(false); }
public void Should_FailPreLogicValidation_When_DistanceInMilesIsEmpty() { // Arrange var restaurantSelectionDtoValidator = new RestaurantSelectionDtoValidator(); var restaurantSelectionDto = new RestaurantSelectionDto { City = "Los Angeles", State = "CA", FoodType = "American Food", AvgFoodPrice = 1, CurrentUtcDateTime = DateTime.UtcNow }; // Act var result = restaurantSelectionDtoValidator.Validate(restaurantSelectionDto, ruleSet: "PreLogic"); var isValid = result.IsValid; // Assert isValid.Should().Be(false); }
public void Should_FailRegisteredUserPostLogicValidation_When_CityIsNull() { // Arrange var restaurantSelectionDtoValidator = new RestaurantSelectionDtoValidator(); var restaurantSelectionDto = new RestaurantSelectionDto { City = null, State = "CA", FoodType = "American Food", DistanceInMiles = 10, AvgFoodPrice = 1, CurrentUtcDateTime = DateTime.UtcNow }; // Act var result = restaurantSelectionDtoValidator.Validate(restaurantSelectionDto, ruleSet: "RegisteredUserPostLogic"); var isValid = result.IsValid; // Assert isValid.Should().Be(false); }