本文整理汇总了C#中TestService类的典型用法代码示例。如果您正苦于以下问题:C# TestService类的具体用法?C# TestService怎么用?C# TestService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestService类属于命名空间,在下文中一共展示了TestService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ProcessRequestCalledTwiceWithSameHostShouldWork
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("[email protected]");
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("[email protected]");
addressResponse.Should().NotMatch(customerResponse);
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:25,代码来源:HostScenarioTests.cs
示例2: EstablishContext
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());
}
开发者ID:SaintGimp,项目名称:Topshelf,代码行数:31,代码来源:ServiceCoordinator_Singles_Specs.cs
示例3: EstablishContext
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());
}
开发者ID:abombss,项目名称:Topshelf,代码行数:33,代码来源:ServiceCoordinator_Singles_Specs.cs
示例4: EstablishContext
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);
}
开发者ID:hakeemsm,项目名称:Topshelf,代码行数:34,代码来源:ServiceCoordinator_Specs.cs
示例5: RemoteCallback
public static object RemoteCallback(object dummy)
{
BinaryTcpServerChannel serverChannel = new BinaryTcpServerChannel("localhost", PortNumber);
TestService serviceProvider = new TestService();
serverChannel.RegisterService(ServiceName, serviceProvider);
return null;
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:7,代码来源:BinaryTcpChannelTest.cs
示例6: RemoteCallback
public static object RemoteCallback(object dummy)
{
BinaryIpcServerChannel serverChannel = new BinaryIpcServerChannel(PortName);
TestService serviceProvider = new TestService();
serverChannel.RegisterService(ServiceName, serviceProvider);
return null;
}
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:7,代码来源:BinaryIpcChannelTest.cs
示例7: Create_TypeActivatesTypesWithServices
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();
}
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:25,代码来源:DefaultControllerActivatorTest.cs
示例8: EstablishContext
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);
}
}
}
开发者ID:ramonsmits,项目名称:Topshelf,代码行数:28,代码来源:ServiceController_Specs.cs
示例9: TestCounter
public int TestCounter()
{
var testSvc = new TestService();
var model = testSvc.ClickCounter();
return model.ClickCount;
}
开发者ID:theresamop,项目名称:TestMVCApp,代码行数:7,代码来源:TestController.cs
示例10: EstablishContext
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());
}
开发者ID:raelyard,项目名称:Topshelf,代码行数:29,代码来源:ServiceCoordinator_Singles_Specs.cs
示例11: TestCameraProvider
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);
}
开发者ID:aTEuCT,项目名称:PhotoManager,代码行数:9,代码来源:IntegrationTest.cs
示例12: VariableArguments
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]);
}
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:9,代码来源:TestJsonRpcService.cs
示例13: RoutingByPacketType
public void RoutingByPacketType()
{
var service = new TestService();
var routed = service.Route(
new TestPacket());
Assert.IsTrue(routed);
}
开发者ID:pjc0247,项目名称:Merona.cs,代码行数:9,代码来源:Service.Route.cs
示例14: SetUp
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());
}
开发者ID:oriches,项目名称:Simple.Rest.For.Windows.Store,代码行数:9,代码来源:RestClient_PostTests.cs
示例15: VariableArguments
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]);
}
开发者ID:db48x,项目名称:KeeFox,代码行数:9,代码来源:TestMethod.cs
示例16: Main
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);
}
}
开发者ID:pjc0247,项目名称:Merona.cs,代码行数:56,代码来源:Program.cs
示例17: TestAutoService
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);
}
开发者ID:aTEuCT,项目名称:PhotoManager,代码行数:11,代码来源:IntegrationTest.cs
示例18: FixedAndVariableArguments
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]);
}
开发者ID:db48x,项目名称:KeeFox,代码行数:11,代码来源:TestMethod.cs
示例19: FixedAndVariableArguments
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]);
}
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:11,代码来源:TestJsonRpcService.cs
示例20: DoOperation_OnSuccessfulOperation_BlocksExecutionAndReturnsResult_Test
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);
}
开发者ID:ZivSystems,项目名称:WcfFramework,代码行数:12,代码来源:ServiceBase_TestFixture.cs
注:本文中的TestService类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论