public void AddPromotion_OnValidInput_ShouldAddPromotion() { // Arrange var mockPromo = new Promotion() { Id = Guid.NewGuid(), DiscountPerUnit = 0, FixedPrice = 0, Name = "test", NumberOfSKUItems = 1, PrmotionTypeId = PromotionsDb.promotionTypes[0].Id }; // Act var result = _promotionsRepository.AddPromotion(mockPromo); // Assert Assert.IsTrue(result); }
public async Task <IActionResult> AddPromotion([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "promotions")] HttpRequest request) { var promotionRequest = await request.DeserializeBody <AddPromotionRequestModel>(); var promotionRequestValidation = promotionRequest.Validate(); if (promotionRequestValidation.Any()) { return(new BadRequestObjectResult(promotionRequestValidation)); } repository.AddPromotion(new Promotion(promotionRequest)); return(ActionResults.Created()); }