public void PassValidObject()
        {
            GetStoreProductQuery query = new GetStoreProductQuery
            {
                ProductId = Guid.NewGuid()
            };
            GetStoreProductQueryValidator testSubject = new GetStoreProductQueryValidator();

            ValidationResult result = testSubject.Validate(query);

            Assert.True(result.IsValid);
        }
        public void FailsOnEmptyProductId()
        {
            GetStoreProductQuery query = new GetStoreProductQuery
            {
                ProductId = Guid.Empty
            };
            GetStoreProductQueryValidator testSubject = new GetStoreProductQueryValidator();

            ValidationResult result = testSubject.Validate(query);

            Assert.False(result.IsValid);
            Assert.Equal("ProductId", result.Errors[0].PropertyName);
        }
Beispiel #3
0
        public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger logger)
        {
            Logger.Value = logger;
            logger.LogInformation("C# HTTP trigger function processed a request.");

            IDirectCommandExecuter executer = ServiceProvider.GetService <IDirectCommandExecuter>();

            GetStoreProductQuery query = new GetStoreProductQuery
            {
                ProductId = Guid.Parse(req.GetQueryParameterDictionary()["ProductId"])
            };
            CommandResponse <StoreProduct> result = await executer.ExecuteAsync(query);

            return(new OkObjectResult(result));
        }
Beispiel #4
0
 public async Task <CommandResponse <StoreProduct> > ExecuteAsync(GetStoreProductQuery command, CommandResponse <StoreProduct> previousResult)
 {
     return(CommandResponse <StoreProduct> .Ok(await _repository.GetAsync(command.ProductId)));
 }
 public async Task <IActionResult> Get([FromRoute] GetStoreProductQuery query) => await ExecuteCommand(query);