Exemplo n.º 1
0
        public void InsertUrlScheduledCallTest()
        {
            // 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 string Url = "http://www.example.com";
            const string Data = "TestData";

            var scheduledCall = new UrlScheduledCall
                                    {
                                        IntegrationServiceGuid = integrationServiceGuid,
                                        ProcessName = ProcessName,
                                        ItemId = ItemId,
                                        CallCount = CallCount,
                                        Status = Status,
                                        Url = Url,
                                        Data = Data
                                    };

            IntegrationServiceUrlScheduledCallDto dto = null;
            var processDal = Mock.Create<IProcessDal>();
            Mock.Arrange(() => processDal.InsertIntegrationServiceScheduledCall(Arg.IsAny<IntegrationServiceUrlScheduledCallDto>())).DoInstead<IntegrationServiceUrlScheduledCallDto>(
                x =>
                    {
                        x.Id = Id;
                        dto = x;
                    });

            var scheduler = new ServiceCallScheduler { ProcessDal = processDal };

            // Act.
            scheduler.InsertScheduledCall(scheduledCall);

            // Assert.
            Mock.Assert(() => processDal.InsertIntegrationServiceScheduledCall(Arg.IsAny<IntegrationServiceUrlScheduledCallDto>()), 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(Url, dto.Url);
            Assert.AreEqual(Data, dto.Data);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Builds the dto.
 /// </summary>
 /// <param name="scheduledCall">The scheduled call.</param>
 /// <returns>IntegrationServiceUrlScheduledCallDto.</returns>
 private static IntegrationServiceUrlScheduledCallDto BuildDto(UrlScheduledCall scheduledCall)
 {
     return new IntegrationServiceUrlScheduledCallDto
                {
                    Id = scheduledCall.Id,
                    IntegrationServiceGuid = scheduledCall.IntegrationServiceGuid,
                    ProcessName = scheduledCall.ProcessName,
                    ItemId = scheduledCall.ItemId,
                    CallCount = scheduledCall.CallCount,
                    Status = scheduledCall.Status,
                    Url = scheduledCall.Url,
                    Data = scheduledCall.Data,
                    HttpMethod = scheduledCall.HttpMethod
                };
 }
Exemplo n.º 3
0
 /// <summary>
 /// Updates the scheduled call.
 /// </summary>
 /// <param name="scheduledCall">The scheduled call.</param>
 private void UpdateScheduledCall(UrlScheduledCall scheduledCall)
 {
     var dto = BuildDto(scheduledCall);
     ProcessDal.UpdateIntegrationServiceScheduledCall(dto);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Inserts the scheduled call.
 /// </summary>
 /// <param name="scheduledCall">The scheduled call.</param>
 private void InsertScheduledCall(UrlScheduledCall scheduledCall)
 {
     var dto = BuildDto(scheduledCall);
     ProcessDal.InsertIntegrationServiceScheduledCall(dto);
     scheduledCall.Id = dto.Id;
 }
Exemplo n.º 5
0
        /// <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");

            if (_callLocation != UrlServiceCallLocation.Server)
                throw new InvalidOperationException("Service call cannot be executed on server.");

            var request = GetRequestInternal(item);
            var scheduledCall = new UrlScheduledCall
                                {
                                    IntegrationServiceGuid = Guid,
                                    ProcessName = item.ProcessName,
                                    ItemId = item.Id,
                                    CallCount = 0,
                                    Status = ServiceCallStatus.Scheduled,
                                    Url = request.Url,
                                    Data = request.GetQueryString(),
                                    HttpMethod = _httpMethod
                                };

            CallScheduler.InsertScheduledCall(scheduledCall);
        }