示例#1
0
        private async Task <StringSet> ServeRequest(StringGenerationRequest request)
        {
            var strartTime = DateTime.Now;
            var result     = await mediator.Send(request);

            var timediff = DateTime.Now - strartTime;

            result.RequestDurationInSeconds = timediff.TotalSeconds;
            return(result);
        }
        public StringGenerationHandlerTest()
        {
            var alphabet         = "abc";
            var length           = 1;
            var count            = 1;
            var stringFactoryMoq = new Mock <IStringGenerator>();

            stringFactoryMoq.Setup(m => m.GenerateString(alphabet, length)).Returns(() => new string(alphabet.First(), length));

            var stringGenerServiceMoq = new Mock <IGeneratorService>();

            stringGenerServiceMoq.Setup(m => m.GenerateSetOfStrings(alphabet, length, count, stringFactoryMoq.Object)).Returns(() => new string[] { "a" });

            request          = new StringGenerationRequest();
            handler          = new StringGenerationHandler(stringGenerServiceMoq.Object, stringFactoryMoq.Object);
            request.Alphabet = alphabet;
            request.Count    = count;
            request.Length   = length;
        }
示例#3
0
 public async Task <StringSet> GenerateFromQuery([FromQuery] StringGenerationRequest request)
 {
     return(await ServeRequest(request));
 }