public async Task QueryAllNotFoundIfEmpty()
        {
            string name = "does-not-matter";

            model.AllEntitesAsync().Returns((IEnumerable <ConfigEntity>)null);
            var context = new QueryContext(name, QueryTypes.ValueRequest, model);

            var result = await AllQueries.QueryConfigEntityAsync(context);

            Assert.False(result.IsSuccess);
            Assert.Null(result.Result);
            Assert.Equal(ResultType.NotFound, result.ResultType);
        }
        public async Task QuerySingleHappyPath()
        {
            string name   = "config-name";
            var    entity = new ConfigEntity();

            model.GetEntityByNameAsync(name).Returns(entity);

            var context = new QueryContext(name, QueryTypes.ValueRequest, model);
            var result  = await AllQueries.QueryConfigEntityAsync(context);

            Assert.Same(entity, result.Result);
            Assert.True(result.IsSuccess);
        }
        public async Task QuerySingleEntityAsyncReturnsNotFoundIfconfigNameDoesNotExist()
        {
            string name = "config-name";

            model.GetEntityByNameAsync(name).Returns((ConfigEntity)null);
            var context = new QueryContext(name, QueryTypes.ValueRequest, model);

            var result = await AllQueries.QueryConfigEntityAsync(context);

            Assert.False(result.IsSuccess);
            Assert.Null(result.Result);
            Assert.Equal(ResultType.NotFound, result.ResultType);
        }
 public async Task QuerySingleEntityWithWrongQueryTypeThrowsArgumentException()
 {
     var context = new QueryContext("does-not-matter", QueryTypes.AllValues, model);
     await Assert.ThrowsAsync <ArgumentException>(async() => await AllQueries.QueryConfigEntityAsync(context));
 }
        public async Task NullContextThrows()
        {
            await Assert.ThrowsAsync <ArgumentException>(async() => await AllQueries.QueryConfigEntityAsync(null));

            await Assert.ThrowsAsync <ArgumentException>(async() => await AllQueries.QueryAllConfigEntityValuesAsync(null));
        }