本文整理汇总了C#中TestService类的典型用法代码示例。如果您正苦于以下问题:C# TestService类的具体用法?C# TestService怎么用?C# TestService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestService类属于命名空间,在下文中一共展示了TestService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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());
}
示例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());
}
示例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);
}
示例5: RemoteCallback
public static object RemoteCallback(object dummy)
{
BinaryTcpServerChannel serverChannel = new BinaryTcpServerChannel("localhost", PortNumber);
TestService serviceProvider = new TestService();
serverChannel.RegisterService(ServiceName, serviceProvider);
return null;
}
示例6: RemoteCallback
public static object RemoteCallback(object dummy)
{
BinaryIpcServerChannel serverChannel = new BinaryIpcServerChannel(PortName);
TestService serviceProvider = new TestService();
serverChannel.RegisterService(ServiceName, serviceProvider);
return null;
}
示例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();
}
示例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);
}
}
}
示例9: TestCounter
public int TestCounter()
{
var testSvc = new TestService();
var model = testSvc.ClickCounter();
return model.ClickCount;
}
示例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());
}
示例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);
}
示例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]);
}
示例13: RoutingByPacketType
public void RoutingByPacketType()
{
var service = new TestService();
var routed = service.Route(
new TestPacket());
Assert.IsTrue(routed);
}
示例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());
}
示例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]);
}