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
        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);
        }