public void RunTest_CacheEntityCollectionIsEmpty()
        {
            crmService.Switch = DataSwitch.CollectionWithNoRecordsReturned;
            var service = new OutboundSynchronisationService(logger, outboundSynchronisationService, jwtService, requestPayloadCreator, configurationService);

            service.Run();
            Assert.IsTrue(true);
        }
        public void RunTest_CacheEntityCollectionContainsAllNecessaryRecords()
        {
            crmService.Switch = DataSwitch.ReturnsData;
            crmService.PrepareData();

            var context               = crmService.Context;
            var cacheEntities         = context.Data["tc_entitycache"];
            var expectedCacheEntities = cacheEntities;

            var service = new OutboundSynchronisationService(logger, outboundSynchronisationService, jwtService, requestPayloadCreator, configurationService);

            service.Run();

            Assert.AreEqual(expectedCacheEntities, cacheEntities);
        }
示例#3
0
        public void TestInitialize()
        {
            logger     = A.Fake <ILogger>();
            jwtService = A.Fake <IJwtService>();
            outboundSynchDataService         = A.Fake <IOutboundSynchronisationDataService>();
            createRequestPayloadCreator      = A.Fake <IRequestPayloadCreator>();
            updateRequestPayloadCreator      = A.Fake <IRequestPayloadCreator>();
            outboundSyncConfigurationService = A.Fake <IOutboundSyncConfigurationService>();
            entityModelDeserializer          = A.Fake <IEntityModelDeserializer>();

            A.CallTo(() => outboundSyncConfigurationService.BatchSize).Returns(batchSize);
            A.CallTo(() => outboundSyncConfigurationService.EntityName).Returns(entityName);
            A.CallTo(() => outboundSynchDataService.GetSecretKey()).Returns(secretKey);
            A.CallTo(() => outboundSynchDataService.GetRetries()).Returns(retries);
            A.CallTo(() => outboundSyncConfigurationService.CreateServiceUrl).Returns(createServiceUrl);
            A.CallTo(() => outboundSyncConfigurationService.UpdateServiceUrl).Returns(updateServiceUrl);
            A.CallTo(() => entityModelDeserializer.Deserialize(A <string> ._)).Returns(
                new Crm.Common.IntegrationLayer.Model.EntityModel
            {
                Fields = new List <Crm.Common.IntegrationLayer.Model.Field>
                {
                    new Crm.Common.IntegrationLayer.Model.Field
                    {
                        Name  = Tc.Crm.Common.Constants.Attributes.Customer.FirstName,
                        Type  = Crm.Common.IntegrationLayer.Model.FieldType.String,
                        Value = "Name"
                    }
                }
            });

            outboundSynchService = new OutboundSynchronisationService(
                logger,
                outboundSynchDataService,
                jwtService,
                createRequestPayloadCreator,
                updateRequestPayloadCreator,
                outboundSyncConfigurationService,
                entityModelDeserializer);
        }