コード例 #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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public void GetScheduledCallsTest()
        {
            // Arrange.
            const int UrlCallId = 111;
            var urlCallCreationDate = new DateTime(2013, 6, 11);
            var urlCallServiceGuid = new Guid("{8EBDB6D9-42EF-437A-ABEE-2FA6987358C2}");
            const string UrlCallProcessName = "UrlCallProcess";
            const int UrlCallItemId = 123;
            const int UrlCallCount = 2;
            const ServiceCallStatus UrlCallStatus = ServiceCallStatus.Scheduled;
            const string UrlCallUrl = "http://www.example.com";
            const string UrlCallData = "UrlData";

            const int WebMethodCallId = 222;
            var webMethodCallCreationDate = new DateTime(2013, 6, 12);
            var webMethodCallServiceGuid = new Guid("{41157FF5-0339-430E-90D2-204A1E813ACA}");
            const string WebMethodCallProcessName = "TestProcess";
            const int WebMethodCallItemId = 456;
            const int WebMethodCallCount = 5;
            const ServiceCallStatus WebMethodCallStatus = ServiceCallStatus.Successful;
            const int WebMethodCallServiceDescriptionId = 333;
            const string WebMethodCallContractTypeName = "TestContract";
            const string WebMethodCallMethodName = "TestMethod";
            const string WebMethodCallData = "WebMethodData";

            var dtos = new List<IntegrationServiceScheduledCallDto>
                           {
                               new IntegrationServiceUrlScheduledCallDto
                                   {
                                       Id = UrlCallId,
                                       CreationDate = urlCallCreationDate,
                                       IntegrationServiceGuid = urlCallServiceGuid,
                                       ProcessName = UrlCallProcessName,
                                       ItemId = UrlCallItemId,
                                       CallCount = UrlCallCount,
                                       Status = UrlCallStatus,
                                       Url = UrlCallUrl,
                                       Data = UrlCallData
                                   },
                               new IntegrationServiceWebMethodScheduledCallDto
                                   {
                                       Id = WebMethodCallId,
                                       CreationDate = webMethodCallCreationDate,
                                       IntegrationServiceGuid = webMethodCallServiceGuid,
                                       ProcessName = WebMethodCallProcessName,
                                       ItemId = WebMethodCallItemId,
                                       CallCount = WebMethodCallCount,
                                       Status = WebMethodCallStatus,
                                       ServiceDescriptionId = WebMethodCallServiceDescriptionId,
                                       ContractTypeName = WebMethodCallContractTypeName,
                                       MethodName = WebMethodCallMethodName,
                                       Data = WebMethodCallData
                                   }
                           };

            var processDal = Mock.Create<IProcessDal>();
            Mock.Arrange(() => processDal.GetIntegrationServiceScheduledCalls()).Returns(dtos);

            var scheduler = new ServiceCallScheduler { ProcessDal = processDal };

            // Act.
            var scheduledCalls = scheduler.GetScheduledCalls();

            // Assert.
            Assert.AreEqual(2, scheduledCalls.Count);

            var urlCall = scheduledCalls.ElementAt(0) as UrlScheduledCall;

            Assert.IsNotNull(urlCall);
            Assert.AreEqual(UrlCallId, urlCall.Id);
            Assert.AreEqual(urlCallCreationDate, urlCall.CreationDate);
            Assert.AreEqual(urlCallServiceGuid, urlCall.IntegrationServiceGuid);
            Assert.AreEqual(UrlCallProcessName, urlCall.ProcessName);
            Assert.AreEqual(UrlCallItemId, urlCall.ItemId);
            Assert.AreEqual(UrlCallCount, urlCall.CallCount);
            Assert.AreEqual(UrlCallStatus, urlCall.Status);
            Assert.AreEqual(UrlCallUrl, urlCall.Url);
            Assert.AreEqual(UrlCallData, urlCall.Data);

            var webMethodCall = scheduledCalls.ElementAt(1) as WebMethodScheduledCall;

            Assert.IsNotNull(webMethodCall);
            Assert.AreEqual(WebMethodCallId, webMethodCall.Id);
            Assert.AreEqual(webMethodCallCreationDate, webMethodCall.CreationDate);
            Assert.AreEqual(webMethodCallServiceGuid, webMethodCall.IntegrationServiceGuid);
            Assert.AreEqual(WebMethodCallProcessName, webMethodCall.ProcessName);
            Assert.AreEqual(WebMethodCallItemId, webMethodCall.ItemId);
            Assert.AreEqual(WebMethodCallCount, webMethodCall.CallCount);
            Assert.AreEqual(WebMethodCallStatus, webMethodCall.Status);
            Assert.AreEqual(WebMethodCallServiceDescriptionId, webMethodCall.ServiceDescriptionId);
            Assert.AreEqual(WebMethodCallContractTypeName, webMethodCall.ContractTypeName);
            Assert.AreEqual(WebMethodCallMethodName, webMethodCall.MethodName);
            Assert.AreEqual(WebMethodCallData, webMethodCall.Data);
        }
コード例 #4
0
        public void DeleteScheduledCallTest()
        {
            // Arrange.
            const int Id = 123;

            var processDal = Mock.Create<IProcessDal>();
            var scheduler = new ServiceCallScheduler { ProcessDal = processDal };
 
            // Act.
            scheduler.DeleteScheduledCall(Id);

            // Assert.
            Mock.Assert(() => processDal.DeleteIntegrationServiceScheduledCall(Id), Occurs.Once());
        }