// Post api/spy public IActionResult Post(SpyRequest request) { var spyModel = _repository.Get().SingleOrDefault(s => s.Name == request.Spy); if (spyModel == null) { return(BadRequest("Spy not found")); } int codeElement; int[] spyArray = spyModel.CodeName.ToCharArray() .Where(cn => Int32.TryParse(cn.ToString(), out codeElement)) .Select(cn => int.Parse(cn.ToString())).ToArray(); if (spyArray.Count() == 0) { return(BadRequest("Invalid code name")); } foreach (var element in spyArray) { int index = Array.IndexOf(request.Message, element); if (index == -1) { return(Ok(false)); } request.Message = request.Message.Skip(index + 1).ToArray(); } return(Ok(true)); }
protected override void Given() { IoC.Container = null; new ServiceLayerConfiguration(GetType().Assembly, GetType().Assembly, typeof(Agatha.Castle.Container)) .RegisterRequestHandlerInterceptor<TestInterceptor>() .Initialize(); request = new SpyRequest(); }
protected override void Given() { erroneousRequest = new InterceptedSpyRequest(); subsequentRequest = new SpyRequest(); anotherSubsequentRequest = new SpyRequest(); subsequentRequests = new[] { subsequentRequest, anotherSubsequentRequest }; new ServiceLayerAndClientConfiguration(typeof(ThrowingRequestHandler).Assembly, GetType().Assembly, new Agatha.Castle.Container()) .RegisterRequestHandlerInterceptor<TestInterceptor>() .Initialize(); }
protected override void Given() { IoC.Container = null; new ServiceLayerConfiguration(GetType().Assembly, GetType().Assembly, typeof(Agatha.Unity.Container)) .RegisterRequestHandlerInterceptor<FailingBeforeHandlingRequestInterceptor>() .RegisterRequestHandlerInterceptor<SubSequentInterceptor>() .Initialize(); request = new SpyRequest(); }