상속: System.Web.Services.WebService
 public static object RemoteCallback(object dummy)
 {
     BinaryTcpServerChannel serverChannel = new BinaryTcpServerChannel("localhost", PortNumber);
     TestService serviceProvider = new TestService();
     serverChannel.RegisterService(ServiceName, serviceProvider);
     return null;
 }
        public void EstablishContext()
        {
            _service = new TestService();
            _service2 = new TestService2();

            _serviceCoordinator = new ServiceCoordinator(new ThreadPoolFiber(), x => { }, x => { }, x => { }, 1.Minutes());
            _serviceCoordinator.CreateService("test",
                                              n =>
                                              new ServiceController<TestService>("test", null,
                                                                                 AddressRegistry.GetOutboundCoordinatorChannel(),
                                                                                 x => x.Start(),
                                                                                 x => x.Stop(),
                                                                                 x => x.Pause(),
                                                                                 x => x.Continue(),
                                                                                 (x, c) => _service));
            _serviceCoordinator.CreateService("test2",
                                              n =>
                                              new ServiceController<TestService>("test2", null,
                                                                                 AddressRegistry.GetOutboundCoordinatorChannel(),
                                                                                 x => x.Start(),
                                                                                 x => x.Stop(),
                                                                                 x => x.Pause(),
                                                                                 x =>
                                                                                 x.Continue(),
                                                                                 (x, c) =>
                                                                                 _service2));
            _serviceCoordinator.Start();

            _service.Running.WaitUntilCompleted(10.Seconds());
            _service2.Running.WaitUntilCompleted(10.Seconds());
        }
        public void EstablishContext()
        {
            _service = new TestService();
            _service2 = new TestService2();

            _serviceCoordinator = new ServiceCoordinator(new PoolFiber(), x => { }, x => { }, x => { }, 1.Minutes());
            _serviceCoordinator.CreateService("test",
                                              (inbox,coordinator) =>
                                              new LocalServiceController<TestService>("test", inbox, coordinator,
                                                                                 x => x.Start(),
                                                                                 x => x.Stop(),
                                                                                 x => x.Pause(),
                                                                                 x => x.Continue(),
                                                                                 (x, c) => _service));
            _serviceCoordinator.CreateService("test2",
                                              (inbox, coordinator) =>
                                              new LocalServiceController<TestService>("test2", inbox, coordinator,
                                                                                 x => x.Start(),
                                                                                 x => x.Stop(),
                                                                                 x => x.Pause(),
                                                                                 x =>
                                                                                 x.Continue(),
                                                                                 (x, c) =>
                                                                                 _service2));
            _serviceCoordinator.Start();

            _service.Running.WaitUntilCompleted(10.Seconds());
            _service2.Running.WaitUntilCompleted(10.Seconds());
        }
예제 #4
0
        public void EstablishContext()
        {
            _service = new TestService();
            _service2 = new TestService2();

            _beforeStartingServicesInvoked = false;
            _afterStartingServicesInvoked = false;
            _afterStoppingServicesInvoked = false;

            _serviceCoordinator = new ServiceCoordinator(x => { _beforeStartingServicesInvoked = true; }, x => { _afterStartingServicesInvoked = true; }, x => { _afterStoppingServicesInvoked = true; });
            IList<Func<IServiceController>> services = new List<Func<IServiceController>>
                                                       {
                                                           () => new ServiceController<TestService>
                                                                 {
                                                                     Name = "test",
                                                                     BuildService = s => _service,
                                                                     StartAction = x => x.Start(),
                                                                     StopAction = x => x.Stop(),
                                                                     ContinueAction = x => x.Continue(),
                                                                     PauseAction = x => x.Pause()
                                                                 },
                                                           () => new ServiceController<TestService2>
                                                                 {
                                                                     Name = "test2",
                                                                     BuildService = s => _service2,
                                                                     StartAction = x => x.Start(),
                                                                     StopAction = x => x.Stop(),
                                                                     ContinueAction = x => x.Continue(),
                                                                     PauseAction = x => x.Pause()
                                                                 }
                                                       };

            _serviceCoordinator.RegisterServices(services);
        }
예제 #5
0
        public int TestCounter()
        {
            var testSvc = new TestService();
            var model = testSvc.ClickCounter();

            return model.ClickCount;
        }
        public void Create_TypeActivatesTypesWithServices()
        {
            // Arrange
            var activator = new DefaultControllerActivator(new DefaultTypeActivatorCache());
            var serviceProvider = new Mock<IServiceProvider>(MockBehavior.Strict);
            var testService = new TestService();
            serviceProvider.Setup(s => s.GetService(typeof(TestService)))
                           .Returns(testService)
                           .Verifiable();
                           
            var httpContext = new DefaultHttpContext
            {
                RequestServices = serviceProvider.Object
            };
            var actionContext = new ActionContext(httpContext,
                                                  new RouteData(),
                                                  new ActionDescriptor());
            // Act
            var instance = activator.Create(actionContext, typeof(TypeDerivingFromControllerWithServices));

            // Assert
            var controller = Assert.IsType<TypeDerivingFromControllerWithServices>(instance);
            Assert.Same(testService, controller.TestService);
            serviceProvider.Verify();
        }
 public static object RemoteCallback(object dummy)
 {
     BinaryIpcServerChannel serverChannel = new BinaryIpcServerChannel(PortName);
     TestService serviceProvider = new TestService();
     serverChannel.RegisterService(ServiceName, serviceProvider);
     return null;
 }
        public void EstablishContext()
        {
            using (var startEvent = new ManualResetEvent(false))
            {
                _srv = new TestService();

                _channelAdaptor = new ChannelAdapter();
                _hostChannel = WellknownAddresses.GetServiceCoordinatorHost(_channelAdaptor);

                using (_channelAdaptor.Connect(config => config.AddConsumerOf<ServiceStarted>().UsingConsumer(msg => startEvent.Set())))
                {

                    ServiceConfigurator<TestService> c = new ServiceConfigurator<TestService>();
                    c.WhenStarted(s => s.Start());
                    c.WhenStopped(s => s.Stop());
                    c.WhenPaused(s => { _wasPaused = true; });
                    c.WhenContinued(s => { _wasContinued = true; });
                    c.HowToBuildService(name => _srv);

                    _serviceController = c.Create(WellknownAddresses.GetServiceCoordinatorProxy());
                    _serviceController.Start();

                    startEvent.WaitOne(5.Seconds());

                    _serviceController.State.ShouldEqual(ServiceState.Started);
                }
            }
        }
예제 #9
0
        public void ProcessRequestCalledTwiceWithSameHostShouldWork()
        {
            var host = new DataServiceHostSimulator {AbsoluteRequestUri = new Uri("http://example.com/Customers(1)"), AbsoluteServiceUri = new Uri("http://example.com/"), RequestHttpMethod = "GET", ResponseStream = new MemoryStream(), ProcessExceptionCallBack = (args) => { }};
            var svc = new TestService();
            svc.AttachHost(host);
            svc.ProcessRequest();
            host.ResponseStatusCode.Should().Be(200);
            host.ResponseStream.Position = 0;
            var customerResponse = new StreamReader(host.ResponseStream).ReadToEnd();
            customerResponse.Should().Contain("Customer");
            customerResponse.Should().Contain("Redmond Way");
            customerResponse.Should().Contain("*****@*****.**");

            host.ResponseStream = new MemoryStream();
            host.AbsoluteRequestUri = new Uri("http://example.com/Customers(1)/Address");
            // re-attach the host before calling ProcessRequest
            svc.AttachHost(host);
            svc.ProcessRequest();
            host.ResponseStatusCode.Should().Be(200);
            host.ResponseStream.Position = 0;
            var addressResponse = new StreamReader(host.ResponseStream).ReadToEnd();
            addressResponse.Should().Contain("Redmond Way");
            addressResponse.Should().NotContain("*****@*****.**");
            addressResponse.Should().NotMatch(customerResponse);
        }
        public void EstablishContext()
        {
            _service = new TestService();
            _service2 = new TestService2();

            _serviceCoordinator = new ServiceCoordinator(x => { }, x => { }, x => { });
            IList<Func<IServiceController>> services = new List<Func<IServiceController>>
                                                       {
                                                           () =>
                                                           new ServiceController<TestService>("test")
                                                           {
                                                               BuildService = s=> _service,
                                                               StartAction = x => x.Start(),
                                                               StopAction = x => x.Stop(),
                                                               ContinueAction = x => x.Continue(),
                                                               PauseAction = x => x.Pause()
                                                           },
                                                           () =>
                                                           new ServiceController<TestService2>("test2")
                                                           {
                                                               BuildService = s=> _service2,
                                                               StartAction = x => x.Start(),
                                                               StopAction = x => x.Stop(),
                                                               ContinueAction = x => x.Continue(),
                                                               PauseAction = x => x.Pause()
                                                           }
                                                       };

            _serviceCoordinator.RegisterServices(services);
            _serviceCoordinator.Start();

            Thread.Sleep(2.Seconds());
        }
예제 #11
0
 public void TestCameraProvider()
 {
     var provider = new TestService();
     var importService = new ImportService(provider, new FileSystemService(), new LogService(), new DateTimeService());
     var deviceManagerClass = new DeviceManagerClass();
     var deviceInfo = deviceManagerClass.DeviceInfos.Cast<DeviceInfo>().FirstOrDefault(p => string.Equals(p.DeviceID, provider.GetSettings().DeviceId, StringComparison.OrdinalIgnoreCase));
     var device = deviceInfo.Connect();
     importService.Import(new CameraPhotoProvider(device), null, null);
 }
예제 #12
0
        public void RoutingByPacketType()
        {
            var service = new TestService();

            var routed = service.Route(
                new TestPacket());

            Assert.IsTrue(routed);
        }
 public void VariableArguments()
 {
     TestService service = new TestService();
     IRpcMethodDescriptor method = service.GetDescriptor().FindMethodByName("VarMethod");
     object[] args = new object[] { 1, 2, 3, 4 };
     object[] invokeArgs = JsonRpcServices.TransposeVariableArguments(method, args);
     Assert.AreEqual(1, invokeArgs.Length);
     Assert.AreEqual(args, invokeArgs[0]);
 }
        public void SetUp()
        {
            _baseUrl = string.Format("http://{0}:8082", Environment.MachineName);

            _testService = new TestService(_baseUrl);

            _jsonRestClient = new RestClient(new JsonSerializer());
            _xmlRestClient = new RestClient(new XmlSerializer());
        }
예제 #15
0
파일: TestMethod.cs 프로젝트: db48x/KeeFox
 public void VariableArguments()
 {
     TestService service = new TestService();
     Method method = service.GetClass().FindMethodByName("VarMethod");
     object[] args = new object[] { 1, 2, 3, 4 };
     object[] invokeArgs = method.TransposeVariableArguments(args);
     Assert.AreEqual(1, invokeArgs.Length);
     Assert.AreEqual(args, invokeArgs[0]);
 }
예제 #16
0
        static void Main(string[] args)
        {
            // TODO : config
            NLog.Config.SimpleConfigurator.ConfigureForConsoleLogging(NLog.LogLevel.Debug);
            
           // var r = DataBinder.Bind("#{bar.foo} sadf dee #{rre}", new Session());
           // Console.WriteLine(r);

            var aa = new List<int>() { 1, 2, 3, 4 };
            var bb = new List<int>() { 1, 2, 3, 4 };

            Console.WriteLine(aa.Equals(bb));

            var config = Config.defaults;

            config.clusterPeers.Add(new Tuple<String, int>("localhost", 9915));

            FooPacket f = new FooPacket();
            TestService a = new TestService();
            Server s = new Server(config);

            s.AttachService<TestService>();
            s.Start();

            f.pid = "asdf";

            var bp = new BarPacket();
            bp.resp = "QWER";
            s.Enqueue(new Server.RecvPacketEvent(new Session(), bp));

            s.AddPreProcessor(delegate (Session session, Packet packet)             {
                //var bar = (BarPacket)packet;

                Console.WriteLine("prep1");

                //bar.resp = "wwQQ";
            }, 1);
            s.AddPreProcessor(delegate(Session session, Packet packet)
            {
                //var bar = (BarPacket)packet;

                Console.WriteLine("prep2");

                //bar.resp = "wwQQ";
            }, 0);

            Console.CancelKeyPress += delegate (object sender, ConsoleCancelEventArgs e)
            {
                s.Kill();
            };

            while (true)
            {
                System.Threading.Thread.Sleep(100);
            }
        }
예제 #17
0
 public void TestAutoService()
 {
     var provider = new TestService();
     var service = new AutoImportService(
         new ImportService(provider, new FileSystemService(), new LogService(), new DateTimeService()),
         provider,
         new CameraService(),
         new LogService());
     service.Start();
     Thread.Sleep(10000);
 }
 public void FixedAndVariableArguments()
 {
     TestService service = new TestService();
     IRpcMethodDescriptor method = service.GetDescriptor().FindMethodByName("FixedVarMethod");
     object[] args = new object[] { 1, 2, 3, 4 };
     args = JsonRpcServices.TransposeVariableArguments(method, args);
     Assert.AreEqual(3, args.Length);
     Assert.AreEqual(1, args[0]);
     Assert.AreEqual(2, args[1]);
     Assert.AreEqual(new object[] { 3, 4 }, args[2]);
 }
예제 #19
0
파일: TestMethod.cs 프로젝트: db48x/KeeFox
 public void FixedAndVariableArguments()
 {
     TestService service = new TestService();
     Method method = service.GetClass().FindMethodByName("FixedVarMethod");
     object[] args = new object[] { 1, 2, 3, 4 };
     args = method.TransposeVariableArguments(args);
     Assert.AreEqual(3, args.Length);
     Assert.AreEqual(1, args[0]);
     Assert.AreEqual(2, args[1]);
     Assert.AreEqual(new object[] { 3, 4 }, args[2]);
 }
예제 #20
0
        public void NotRouted()
        {
            var service = new TestService();

            var routed = service.Route(
                new Packet()
                {
                    channel = "never.exist.channel"
                });

            Assert.IsFalse(routed);
        }
예제 #21
0
        public void RoutingByChannel()
        {
            var service = new TestService();

            var routed = service.Route(
                new Packet()
                {
                    channel = "a.b.c.d"
                });

            Assert.IsTrue(routed);
        }
 public void DoOperation_OnSuccessfulOperation_BlocksExecutionAndReturnsResult_Test() 
 {
     var service = new TestService();
     
     var startTime = DateTime.Now;
     var operationStatus = service.DoOperation();
     var endTime = DateTime.Now;
     
     Assert.IsTrue(endTime - startTime >= TestOperation.OperationDuration);
     Assert.AreEqual(OperationState.CompletedSucessfully, operationStatus.Info.State);
     Assert.AreEqual(TestOperation.TEST_OPERATION_RESULT, operationStatus.Result);
 }
예제 #23
0
        public void SetUp()
        {
            _host = new ServiceHost();

            _service = new TestService();

            _host.AddService(_service);

            _host.StartServiceHost();
            _host.OpenServices();

            _invoker = new BlockingThreadInvoker();
        }
예제 #24
0
        public void ServiceSwitchTest()
        {
            TestService first = new TestService();
            TestService second = new TestService();

            Assert.AreNotSame(first, second, "This test requires two different instances of ITestService");

            Service<ITestService>.Register(first);
            Assert.AreSame(first, Service<ITestService>.Instance, "First service instance expected");

            Service<ITestService>.Register(second);
            Assert.AreSame(second, Service<ITestService>.Instance, "Service was not switched");
        }
예제 #25
0
        public void ApplicationServicesAvailableFromTestServer()
        {
            var testService = new TestService();
            var builder = new WebHostBuilder()
                .Configure(app => { })
                .ConfigureServices(services =>
                {
                    services.AddSingleton(testService);
                });
            var server = new TestServer(builder);

            Assert.Equal(testService, server.Host.Services.GetRequiredService<TestService>());
        }
예제 #26
0
파일: TestMethod.cs 프로젝트: db48x/KeeFox
 public void FailedMethodYieldsInvocationException()
 {
     try
     {
         TestService service = new TestService();
         service.GetClass().GetMethodByName("BadMethod").Invoke(service, null, null);
         Assert.Fail("Expecting an exception.");
     }
     catch (TargetMethodException e)
     {
         Assert.IsTrue(e.InnerException.GetType() == typeof(ApplicationException), "Unexpected inner exception ({0}).", e.InnerException.GetType().FullName);
     }
 }
예제 #27
0
        public void EstablishContext()
        {
            _srv = new TestService();

            ServiceConfigurator<TestService> c = new ServiceConfigurator<TestService>();
            c.WhenStarted(s => s.Start());
            c.WhenStopped(s => s.Stop());
            c.WhenPaused(s => { _wasPaused = true; });
            c.WhenContinued(s => { _wasContinued = true; });
            c.HowToBuildService((name)=> _srv);
            _serviceController = c.Create();
            _serviceController.Start();
        }
예제 #28
0
        public void SetGetSingleTest()
        {
            var target = new Joint();
            var inst = new TestService();

            target.Add<TestService>(inst);

            Assert.IsTrue(target.Has<TestService>());
            Assert.AreSame(inst, target.The<TestService>());
            Assert.AreSame(inst, target.Get<TestService>());

            Assert.IsTrue(target.Has<ITestService>());
            Assert.AreSame(inst, target.The<ITestService>());
        }
예제 #29
0
 public void ResponseStatusCodeIsNotSetOnHostAfterProcessRequestWith404Error()
 {
     HandleExceptionArgs exceptionArgs = null;
     var host = new DataServiceHostSimulator { AbsoluteRequestUri = new Uri("http://example.com/invalid"), AbsoluteServiceUri = new Uri("http://example.com/"), RequestHttpMethod = "GET", ResponseStream = new MemoryStream(), ProcessExceptionCallBack = (args) => { exceptionArgs = args; } };
     var svc = new TestService();
     svc.AttachHost(host);
     svc.ProcessRequest();
     //// Astoria Server fails to set IDSH.ResponseStatusCode for custom hosts in an error scenario
     //// The behavior has been this way from V2 of WCF Data Services and on, when this is changed
     //// it will be a breaking change
     host.ResponseStatusCode.Should().Be(0);
     host.ResponseStream.Position = 0;
     var customerResponse = new StreamReader(host.ResponseStream).ReadToEnd();
     customerResponse.Should().Contain("Resource not found for the segment 'invalid'.");
     exceptionArgs.ResponseStatusCode.Should().Be(404);
 }
예제 #30
0
        public void SetupEnvironment(string serviceUrl, string nsUrl, NameComponent[] name,
                                     string endian) {
            // register the channel
            int port = 0;
            IDictionary dict = new Hashtable();
            dict["port"] = port;
            dict["endian"] = endian;
            m_channel = new IiopChannel(dict);
            ChannelServices.RegisterChannel(m_channel, false);

            m_testService = (TestService)RemotingServices.Connect(typeof(TestService), serviceUrl);
            m_testServiceIorUrl = (TestService)
                omg.org.CORBA.OrbServices.GetSingleton().string_to_object(serviceUrl);

            m_testServiceFromNs = TryGetServiceFromNs(nsUrl, name);
        }
 public TypeDerivingFromControllerWithServices(TestService service)
 {
     TestService = service;
 }
예제 #32
0
 public TestResultController(ILogger <TestPassingController> logger)
 {
     _logger      = logger;
     _testService = new TestService();
 }
예제 #33
0
 public TestCase[] DiscoverTests(TestDiscoveryTask[] testDiscoveryTasks, string runSettingsPath)
 {
     return(TestService.DiscoverTests(testDiscoveryTasks, runSettingsPath));
 }
 public CatalogController(TestService service, ILogger <CatalogController> log)
 {
     _log     = log;
     _service = service;
 }
예제 #35
0
 public TestHandlerWithServices(TestService service) => Service = service;
 public void Setup()
 {
     _mock           = new Mock <IDatabaseLayer>();
     _testRepository = new TestRepository(_mock);
     _testService    = new TestService(_testRepository);
 }
 public TestController(TestService testService, ILogger <TestController> logger)
 {
     _testService = testService;
     _logger      = logger;
 }
예제 #38
0
        static void Main(string[] args)
        {
            DbClient client              = new DbClient(new MongoClient());
            var      citizenService      = new CitizenService(Client);
            var      municipalityService = new MunicipalityService(Client);
            var      locationService     = new LocationService(Client, municipalityService);
            var      testCenterService   = new TestCenterService(Client);
            var      testService         = new TestService(Client);

            bool run = true;

            while (run)
            {
                Console.WriteLine("[A] Add new Citizen");
                Console.WriteLine("[B] Add new TestCenter and TestCenterManagement");
                Console.WriteLine("[C] Add new Test");
                Console.WriteLine("[D] Add Test to all Citizens");
                Console.WriteLine("[E] Add new Location");
                Console.WriteLine("[F] Add Locations to all Citizens");
                Console.WriteLine("[G] Seed data");
                Console.WriteLine("[H] View active cases for Municipalities");
                Console.WriteLine("[I] View active cases by Sex");
                Console.WriteLine("[J] View active cases by Age");
                Console.WriteLine("[K] View possible cases by Location three days prior");
                Console.WriteLine("[X] Quit");
                Console.WriteLine("INPUT: ");

                var userInput = Console.ReadKey();

                switch (userInput.KeyChar)
                {
                case 'A':
                {
                    Console.Write("Firstname: ");
                    string firstname = Console.ReadLine();
                    Console.Write("Lastname: ");
                    string lastname = Console.ReadLine();
                    Console.Write("SSN (XXXXXX-XXXX): ");
                    string ssn = Console.ReadLine();
                    Console.Write("Age: ");
                    string age = Console.ReadLine();
                    Console.Write("Sex: ");
                    string sex = Console.ReadLine();
                    Console.Write("Municipality: ");
                    string municipalityName = Console.ReadLine();

                    int municipalityId = municipalityService.GetId(municipalityName);

                    var newCitizen = new Citizen
                    {
                        Firstname       = firstname,
                        Lastname        = lastname,
                        SSN             = ssn,
                        Age             = int.Parse(age),
                        Sex             = sex,
                        Tests           = new List <Test>(),
                        Location_id     = new List <int>(),
                        Municipality_id = municipalityId
                    };

                    citizenService.AddCitizen(newCitizen);
                }
                break;

                case 'B':
                {
                    Console.Write("Municipality: ");
                    string municipalityName = Console.ReadLine();
                    Console.Write("Hours: ");
                    int hours = int.Parse(Console.ReadLine());
                    Console.Write("Phonenumber: ");
                    int phonenumber = int.Parse(Console.ReadLine());
                    Console.Write("Email: ");
                    string email = Console.ReadLine();

                    testCenterService.AddTestCenter(municipalityName, hours, phonenumber, email);
                }
                break;

                case 'C':
                {
                    Console.Write("Citizen-ID: ");
                    int citizenId = int.Parse(Console.ReadLine());
                    Console.Write("TestCenter-ID: ");
                    int testCenterId = int.Parse(Console.ReadLine());

                    if (Client.TestCenters.Find(t => t.TestCenterId == testCenterId).Any())
                    {
                        Console.WriteLine("No TestCenter with ID {0} exists.", testCenterId);
                        break;
                    }
                    else if (Client.Citizens.Find(c => c.CitizenId == citizenId).Any())
                    {
                        Console.WriteLine("No Citizen with ID {0} exists.", citizenId);
                        break;
                    }

                    testService.TestCitizen(citizenId, testCenterId);
                }
                break;

                case 'D':
                {
                    testService.TestAllCitizens();
                    Console.WriteLine("All citizens tested.");
                }
                break;

                case 'E':
                {
                    Console.Write("Citizen-ID: ");
                    int citizenId = int.Parse(Console.ReadLine());
                    Console.Write("Address: ");
                    string address = Console.ReadLine();
                    Console.Write("Zip: ");
                    int zip = int.Parse(Console.ReadLine());
                    Console.Write("Municipality name: ");
                    string municipalityName = Console.ReadLine();

                    locationService.AddLocation(citizenId, address, zip, municipalityName);
                }
                break;

                case 'F':
                {
                    locationService.AddLocationToAllCitizen();
                    Console.WriteLine("All Citizen have now locations");
                }
                break;

                case 'G':
                {
                    Console.WriteLine("Sure you want to seed? Seeding will reset all Citizens and Municipalities[Y/N]");
                    string userKey = Console.ReadLine();

                    if (userKey.Contains('Y'))
                    {
                        Seed();
                        Console.WriteLine("Seeding done!");
                    }
                    else
                    {
                        Console.WriteLine("Seeding canceled.");
                    }
                }
                break;

                case 'H':
                {
                    testCenterService.ActiveCovidCasesPerMunicipality();
                }
                break;

                case 'I':
                {
                    testCenterService.ActiveCovidCasesSex();
                }
                break;

                case 'J':
                {
                    Console.Write("Min age: ");
                    int minAge = int.Parse(Console.ReadLine());
                    Console.Write("Max age: ");
                    int maxAge = int.Parse(Console.ReadLine());
                    int cases  = testCenterService.ActiveCovidCasesAge(minAge, maxAge);
                    Console.WriteLine("Total number of cases: {0}", cases);
                }
                break;

                case 'K':
                {
                    Console.Write("Infected citizen's ID: ");
                    int            citizenId = int.Parse(Console.ReadLine());
                    List <Citizen> citizens  = citizenService.CitizensAtSameLocation(citizenId);
                    Console.WriteLine("Citizens which has been the at the same location as an infected: ");
                    foreach (var citizen in citizens)
                    {
                        Console.WriteLine("-------------------------------------------------------");
                        Console.WriteLine($"ID: {citizen.CitizenId}");
                        Console.WriteLine($"Name: {citizen.Firstname} {citizen.Lastname}");
                        Console.WriteLine($"SSN : {citizen.SSN}");
                        Console.WriteLine("-------------------------------------------------------");
                    }
                }
                break;

                case 'X':
                    run = false;
                    break;
                }

                Console.WriteLine("\nPress any key.");
                Console.ReadKey();
                Console.Clear();
            }
        }
예제 #39
0
파일: Form1.cs 프로젝트: ewin66/wholePivas
        private void button6_Click(object sender, EventArgs e)
        {
            TestService t = new TestService();

            button6.Text = t.testHelloW();
        }
예제 #40
0
 public HomeController(TestService testSvc)
 {
     this._testSvc = testSvc;
 }
예제 #41
0
 public PublikacijeController(TestService testService)
 {
     m_TestService = testService;
 }
예제 #42
0
 public QuestionController(QuestionService questions, QuestionRouterService router, TestService tests)
 {
     this.router    = router;
     this.questions = questions;
     this.tests     = tests;
 }
예제 #43
0
 public CommentController(ILogger <HomeController> logger)
 {
     _logger      = logger;
     _testService = new TestService();
 }
예제 #44
0
 public TestController(TestService testService)
 {
     TestService = testService;
 }
예제 #45
0
 public ServiceController(TestService testService)
 {
     _testService = testService;
 }
예제 #46
0
 public TestService_IsEven()
 {
     _testService = new  TestService();
 }
예제 #47
0
 public TestController(TestService testService)
 {
     this._testService = testService;
 }
        // This function will get triggered/executed when a new message is written
        // on an Azure Queue called queue.
        public static void ProcessQueueMessage([QueueTrigger("queue")] string message, TextWriter log)
        {
            var service = new TestService();

            log.WriteLine(message);
        }
예제 #49
0
        protected override async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                await ExecuteOnceAsync(cancellationToken);

                await Task.Delay(Convert.ToInt32(ConfigProvider.Time), cancellationToken);

                //await Task.Delay(TimeSpan.FromMinutes(1), cancellationToken);



                for (int i = 0; i < 20; i++)
                {
                    Thread.Sleep(1000);
                    LogUtility.Info(i.ToString());
                    Console.WriteLine(i.ToString());
                }

                try
                {
                    TestArg arg = new TestArg();
                    arg.Id = "1";

                    TestService test = new TestService();

                    //todo
                    List <TestResultModel> result = test.GetTestSqlData(arg);
                    LogUtility.Message(JsonConvert.SerializeObject(result), "Info");
                }
                catch (Exception ex)
                {
                    LogUtility.Message(ex.ToString(), "Error");
                }



                ////單執行會變成多執行續
                //var tasks = new List<Task>();
                //tasks.Add(Task.Factory.StartNew(() => {

                //    for (int i = 0; i < 20; i++)
                //    {
                //        Thread.Sleep(1000);
                //        LogUtility.Info(i.ToString());
                //        Console.WriteLine(i.ToString());
                //    }

                //    try
                //    {
                //        TestArg arg = new TestArg();
                //        arg.Id = "1";

                //        TestService test = new TestService();

                //        //todo
                //        List<TestResultModel> result = test.GetTestSqlData(arg);
                //        LogUtility.Message(JsonConvert.SerializeObject(result), "Info");
                //    }
                //    catch (Exception ex)
                //    {
                //        LogUtility.Message(ex.ToString(), "Error");
                //    }

                //}, cancellationToken));

                //寫在裡面會變成單執行續
                //var finalTask = Task.Factory.ContinueWhenAll(tasks.ToArray(), wordCountTasks=> { });
                //finalTask.Wait();
            }
        }
예제 #50
0
 public TestingController(TestService service)
 {
     Service = service;
 }
예제 #51
0
        public ActionResult AboutTrainer(string employeeTC, string urlName, int?pageIndex)
        {
            if (employeeTC.IsEmpty())
            {
                return(NotFound());
            }
            if (!pageIndex.HasValue &&
                urlName.In(
                    SimplePages.Urls.TrainerOrgResponses,
                    SimplePages.Urls.TrainerResponses,
                    SimplePages.Urls.TrainerTests,
                    SimplePages.Urls.TrainerAdvices,
                    SimplePages.Urls.TrainerWorks,
                    SimplePages.Urls.TrainerVideos))
            {
                return(RedirectToAction(() => AboutTrainer(employeeTC, urlName, 1)));
            }
            var index = pageIndex.GetValueOrDefault() - 1;

            var model = new AboutTrainerVM();

            model.UrlName  = urlName;
            model.Page     = GetAboutTrainer();
            employeeTC     = employeeTC.ToUpper();
            model.Employee = EmployeeVMService.GetEmployee(employeeTC);
            if (model.Employee == null || !model.Employee.Employee.IsTrainer)
            {
                return(Redirect(SimplePages.FullUrls.Trainers));
            }
            var orgResponses = OrgResponseService.GetAll().IsActive()
                               .Where(r => ("," + r.Employee_TC + ",").Contains("," + employeeTC + ","))
                               .OrderByDescending(o => o.UpdateDate);
            var responses = ResponseService.GetAllForEmployee(employeeTC)
                            .OrderByDescending(x => x.Course.IsActive)
                            .ThenByDescending(o => o.Rating).ThenByDescending(x => x.UpdateDate);

            var advices = AdviceService.GetAll().IsActive()
                          .Where(r => r.Employee_TC == employeeTC)
                          .OrderByDescending(o => o.UpdateDate);
            var tests = TestService.GetAll().Where(x => x.Status == TestStatus.Active)
                        .Where(r => r.Author_TC == employeeTC)
                        .OrderByDescending(o => o.Id);
            var videos = VideoService.GetAll().IsActive()
                         .Where(r => r.Employee_TC == employeeTC)
                         .OrderByDescending(o => o.VideoID);
            var userWorks = UserWorkService.GetAll().IsActive()
                            .Where(r => r.Trainer_TC == employeeTC)
                            .OrderByDescending(o => o.UserWorkID);

            model.HasOrgResponses = orgResponses.Any();
            model.HasResponses    = responses.Any();
            model.HasAdvices      = advices.Any();
            model.HasTests        = tests.Any();
            model.HasVideos       = videos.Any();
            model.HasPortfolio    = Images.GetGallaryFiles(model.Employee.Employee, "Portfolio").Any();
            model.HasWorks        = userWorks.Any();

            if (model.IsTrainerResponses)
            {
                model.Responses = responses.ToPagedList(index, 20);
            }

            if (model.IsTrainerOrgResponses)
            {
                model.OrgResponses = orgResponses.ToPagedList(index, 10);;
            }

            if (model.IsAdvices)
            {
                model.Advices = advices.ToPagedList(index, 10);
            }
            if (model.IsTests)
            {
                model.Tests = tests.ToPagedList(index, 10);
            }
            if (model.IsVideos)
            {
                model.Videos = videos.ToList();
            }
            if (model.IsWorks)
            {
                model.UserWorks = userWorks.ToPagedList(index, 10);
            }
            if (model.IsAboutTrainer)
            {
                model.Certifications = EmployeeCertificationService.GetAll(
                    x => x.EmployeeFK_TC == employeeTC && x.Certification.IsActive)
                                       .OrderBy(x => x.SortOrder)
                                       .Select(x => x.Certification).ToList();
            }
            return(View(model));
        }
예제 #52
0
 public TestView(TestService testService)
 {
     Service = testService;
 }
예제 #53
0
 public ValuesController()
 {
     testService = new TestService();
 }
예제 #54
0
 public UserController(TestService TestService)
 {
     _TestService = TestService;
 }
예제 #55
0
        public async Task Dependencies_Explicit()
        {
            // Verify that a service will wait for service dependencies for each
            // supported URI scheme set explicitly.

            var service    = new TestService();
            var stopWatch  = new Stopwatch();
            var startDelay = 2.0;
            var port0      = NetHelper.GetUnusedTcpPort(IPAddress.Loopback);
            var port1      = NetHelper.GetUnusedTcpPort(IPAddress.Loopback);
            var port2      = NetHelper.GetUnusedTcpPort(IPAddress.Loopback);

            service.Dependencies.Uris.Add(new Uri($"http://127.0.0.1:{port0}"));
            service.Dependencies.Uris.Add(new Uri($"https://127.0.0.1:{port1}"));
            service.Dependencies.Uris.Add(new Uri($"tcp://127.0.0.1:{port2}"));

            stopWatch.Start();

            var runTask = service.RunAsync();

            // Start each simulated service dependency one at a time after waiting
            // [startDelay] seconds for each and then verify that the service waited
            // at least [3*startDelay] to start.
            //
            // Note that it doesn't matter that we're emulating all of the services
            // as an [HttpListener] because the service is only verifying that it
            // can establish a socket connection; its not actually submitting any
            // requests.

            var listener0 = new HttpListener();
            var listener1 = new HttpListener();
            var listener2 = new HttpListener();

            await Task.Delay(TimeSpan.FromSeconds(startDelay));

            listener0.Prefixes.Add($"http://127.0.0.1:{port0}/");
            listener0.Start();

            await Task.Delay(TimeSpan.FromSeconds(startDelay));

            listener1.Prefixes.Add($"http://127.0.0.1:{port1}/");
            listener1.Start();

            await Task.Delay(TimeSpan.FromSeconds(startDelay));

            listener2.Prefixes.Add($"http://127.0.0.1:{port2}/");
            listener2.Start();

            try
            {
                await service.Running.WaitAsync();

                Assert.True(stopWatch.Elapsed >= TimeSpan.FromSeconds(startDelay * 3));

                Assert.Equal(0, await runTask);
            }
            finally
            {
                listener0.Stop();
                listener1.Stop();
                listener2.Stop();
            }
        }
예제 #56
0
 public TestDescriptionController(ILogger <TestDescriptionController> logger)
 {
     _logger      = logger;
     _testService = new TestService();
     _userService = new UserService();
 }
예제 #57
0
        public async Task Dependencies_BadEnvironmentVar()
        {
            // Verify that a service will wait for service dependencies for each
            // supported URI scheme set via an environment variable while
            // ignorning an invalid URI and unsupported URI scheme.

            var port0 = NetHelper.GetUnusedTcpPort(IPAddress.Loopback);
            var port1 = NetHelper.GetUnusedTcpPort(IPAddress.Loopback);
            var port2 = NetHelper.GetUnusedTcpPort(IPAddress.Loopback);

            Environment.SetEnvironmentVariable("NEON_SERVICE_DEPENDENCIES_URIS", $"http://127.0.0.1:{port0}; https://127.0.0.1:{port1}/; tcp://127.0.0.1:{port2}/; mailto://notsupported:80; BAD-URI");

            var service    = new TestService();
            var stopWatch  = new Stopwatch();
            var startDelay = 2.0;

            Assert.Equal($"http://127.0.0.1:{port0}/", service.Dependencies.Uris[0].ToString());
            Assert.Equal($"https://127.0.0.1:{port1}/", service.Dependencies.Uris[1].ToString());
            Assert.Equal($"tcp://127.0.0.1:{port2}/", service.Dependencies.Uris[2].ToString());

            stopWatch.Start();

            var runTask = service.RunAsync();

            // Start each simulated service dependency one at a time after waiting
            // [startDelay] seconds for each and then verify that the service waited
            // at least [3*startDelay] to start.
            //
            // Note that it doesn't matter that we're emulating all of the services
            // as an [HttpListener] because the service is only verifying that it
            // can establish a socket connection; its not actually submitting any
            // requests.

            var listener0 = new HttpListener();
            var listener1 = new HttpListener();
            var listener2 = new HttpListener();

            await Task.Delay(TimeSpan.FromSeconds(startDelay));

            listener0.Prefixes.Add($"http://127.0.0.1:{port0}/");
            listener0.Start();

            await Task.Delay(TimeSpan.FromSeconds(startDelay));

            listener1.Prefixes.Add($"http://127.0.0.1:{port1}/");
            listener1.Start();

            await Task.Delay(TimeSpan.FromSeconds(startDelay));

            listener2.Prefixes.Add($"http://127.0.0.1:{port2}/");
            listener2.Start();

            try
            {
                await service.Running.WaitAsync();

                Assert.True(stopWatch.Elapsed >= TimeSpan.FromSeconds(startDelay * 3));

                Assert.Equal(0, await runTask);
            }
            finally
            {
                listener0.Stop();
                listener1.Stop();
                listener2.Stop();
            }
        }
 public TestController()
 {
     testservice = new TestService();
     qsservice   = new QuestionService();
 }
예제 #59
0
 public void Configure(IApplicationBuilder app)
 {
     app.Use(async(context, next) => await TestService.ProcessRequest(context, next));
 }
예제 #60
0
 public ParameterBuilderTest()
 {
     this.service = new TestService();
 }