コード例 #1
0
ファイル: SpyController.cs プロジェクト: stuartbrant/TechTest
        // 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));
        }
コード例 #2
0
        protected override void Given()
        {
            IoC.Container = null;
            new ServiceLayerConfiguration(GetType().Assembly, GetType().Assembly, typeof(Agatha.Castle.Container))
               .RegisterRequestHandlerInterceptor<TestInterceptor>()
               .Initialize();

            request = new SpyRequest();
        }
コード例 #3
0
 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();
 }
コード例 #4
0
        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();
        }