/// <summary> /// Builds the dto. /// </summary> /// <param name="scheduledCall">The scheduled call.</param> /// <returns>IntegrationServiceWebMethodScheduledCallDto.</returns> private static IntegrationServiceWebMethodScheduledCallDto BuildDto(WebMethodScheduledCall scheduledCall) { return new IntegrationServiceWebMethodScheduledCallDto { Id = scheduledCall.Id, IntegrationServiceGuid = scheduledCall.IntegrationServiceGuid, ProcessName = scheduledCall.ProcessName, ItemId = scheduledCall.ItemId, CallCount = scheduledCall.CallCount, Status = scheduledCall.Status, ServiceDescriptionId = scheduledCall.ServiceDescriptionId, ContractTypeName = scheduledCall.ContractTypeName, MethodName = scheduledCall.MethodName, Data = scheduledCall.Data, Options = scheduledCall.Options }; }
/// <summary> /// Updates the scheduled call. /// </summary> /// <param name="scheduledCall">The scheduled call.</param> private void UpdateScheduledCall(WebMethodScheduledCall scheduledCall) { var dto = BuildDto(scheduledCall); ProcessDal.UpdateIntegrationServiceScheduledCall(dto); }
public void InsertWebMethodScheduledCallTest() { // Arrange. const int Id = 123; var integrationServiceGuid = new Guid("{8EBDB6D9-42EF-437A-ABEE-2FA6987358C2}"); const string ProcessName = "TestProcess"; const int ItemId = 111; const int CallCount = 3; const ServiceCallStatus Status = ServiceCallStatus.Successful; const int ServiceDescriptionId = 222; const string ContractTypeName = "TestContract"; const string MethodName = "TestMethod"; const string Data = "TestData"; var scheduledCall = new WebMethodScheduledCall { IntegrationServiceGuid = integrationServiceGuid, ProcessName = ProcessName, ItemId = ItemId, CallCount = CallCount, Status = Status, ServiceDescriptionId = ServiceDescriptionId, ContractTypeName = ContractTypeName, MethodName = MethodName, Data = Data }; IntegrationServiceWebMethodScheduledCallDto dto = null; var processDal = Mock.Create<IProcessDal>(); Mock.Arrange(() => processDal.InsertIntegrationServiceScheduledCall(Arg.IsAny<IntegrationServiceWebMethodScheduledCallDto>())).DoInstead<IntegrationServiceWebMethodScheduledCallDto>( x => { x.Id = Id; dto = x; }); var scheduler = new ServiceCallScheduler { ProcessDal = processDal }; // Act. scheduler.InsertScheduledCall(scheduledCall); // Assert. Mock.Assert(() => processDal.InsertIntegrationServiceScheduledCall(Arg.IsAny<IntegrationServiceWebMethodScheduledCallDto>()), Occurs.Once()); Assert.AreEqual(Id, scheduledCall.Id); Assert.IsNotNull(dto); Assert.AreEqual(integrationServiceGuid, dto.IntegrationServiceGuid); Assert.AreEqual(ProcessName, dto.ProcessName); Assert.AreEqual(ItemId, dto.ItemId); Assert.AreEqual(CallCount, dto.CallCount); Assert.AreEqual(Status, dto.Status); Assert.AreEqual(ServiceDescriptionId, dto.ServiceDescriptionId); Assert.AreEqual(ContractTypeName, dto.ContractTypeName); Assert.AreEqual(MethodName, dto.MethodName); Assert.AreEqual(Data, dto.Data); }
/// <summary> /// Inserts the scheduled call. /// </summary> /// <param name="scheduledCall">The scheduled call.</param> private void InsertScheduledCall(WebMethodScheduledCall scheduledCall) { var dto = BuildDto(scheduledCall); ProcessDal.InsertIntegrationServiceScheduledCall(dto); scheduledCall.Id = dto.Id; }
/// <summary> /// Enqueues a service call. /// </summary> /// <param name="item"> /// The source item. /// </param> public void EnqueueServiceCall(IEditableRoot item) { if (item == null) throw new ArgumentNullException("item"); using (new ThreadLocalBypassPropertyCheckContext()) { var request = CreateRequest(item); var scheduledCall = new WebMethodScheduledCall { IntegrationServiceGuid = Guid, ProcessName = item.ProcessName, ItemId = item.Id, CallCount = 0, Status = ServiceCallStatus.Scheduled, ServiceDescriptionId = ServiceDescriptionId, ContractTypeName = MethodProxy.ContractType.AssemblyQualifiedName, MethodName = MethodProxy.Method.Name, Data = RequestSerializer.SerializeRequest(request.Message), Options = RequestSerializer.SerializeOptions(request.Options) }; CallScheduler.InsertScheduledCall(scheduledCall); } }