public async Task CreateProduct_Failed()
        {
            const string titleText       = "Title Text";
            const string descriptionText = "Description Text";
            const string jwt             = "";

            var product = new DelegateOffer
            {
                Title       = titleText,
                Description = descriptionText
            };

            var createProductModel = new CreateDelegateOfferModel {
                Title       = "",
                Description = ""
            };

            _marketplaceRepository.Setup(x => x.CreateDelegateOffer(It.IsAny <DelegateOffer>())).ReturnsAsync(product);

            var result = await Assert.ThrowsAsync <EmptyFieldException>(() =>
                                                                        _marketplaceService.CreateDelegateOffer(createProductModel, jwt));

            Assert.NotNull(result);
            Assert.IsType <EmptyFieldException>(result);
        }
Esempio n. 2
0
 public async Task <IActionResult> CreateDelegateOffer([FromBody] CreateDelegateOfferModel createDelegateOfferModel, [FromHeader(Name = "Authorization")] string jwt)
 {
     try
     {
         return(Ok(await _delegateService.CreateDelegateOffer(createDelegateOfferModel, jwt)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }