Ejemplo n.º 1
0
        public void TestUpdateOneObjectStateWithClientVersionGreatThanServerVersion_FacebookCampaign()
        {
            //Initialize by precommit
            ProxySync.ObjectState       facebookCampaignObjectState;
            ProxySync.PreCommitResponse precommitResponse = SyncDataServiceHelper.DoPreCommitInitialize_FacebookCampaign(out facebookCampaignObjectState);
            Assert.IsNotNull(precommitResponse, "The PreCommitResponse object should be NOT NULL!!");

            //Insert Facebook Account entity
            TblFacebookAccount facebookAccountEntity = SyncDataServiceHelper.NextFacebookAccountEntity();

            facebookAccountEntity.Id = facebookCampaignObjectState.ParentId;
            SyncDataServiceHelper.RegisterCreatedFacebookAccountEntityForCleanup(facebookAccountEntity);
            SyncDataServiceHelper.InsertFacebookAccountIntoDB(facebookAccountEntity);

            TblFacebookCampaign facebookCampaignEntity;

            SyncDataServiceHelper.DoesExistFacebookCampaignEntityInDB(facebookCampaignObjectState.ObjectId, out facebookCampaignEntity);

            var inputDictionary = new Dictionary <long, ProxySync.ObjectState[]>();

            facebookCampaignObjectState.LocalVersion++;
            inputDictionary.Add(facebookCampaignEntity.LocalParentId, new ProxySync.ObjectState[] { facebookCampaignObjectState });

            ProxyDTO.SEMBaseDTO[] response = null;
            WCFHelper.Using <SyncDataServiceClient>(new SyncDataServiceClient(), client =>
            {
                response = client.Update(inputDictionary);
            });
            Assert.AreEqual(1, response.Length, "The length of response should be 1!!");
            Assert.AreEqual(facebookCampaignObjectState.LocalVersion - 1, response[0].Version, "The response version should be equal to localversion-1!!");
        }
Ejemplo n.º 2
0
        public void TestNewDataCommitOneSyncDataObject_FacebookCampaign()
        {
            //Initialize by precommit
            ProxySync.ObjectState       facebookCampaignObjectState;
            ProxySync.PreCommitResponse precommitResponse = SyncDataServiceHelper.DoPreCommitInitialize_FacebookCampaign(out facebookCampaignObjectState);
            Assert.IsNotNull(precommitResponse, "The PreCommitResponse object should be NOT NULL!!");

            //Insert Facebook Account entity
            TblFacebookAccount facebookAccountEntity = SyncDataServiceHelper.NextFacebookAccountEntity();

            facebookAccountEntity.Id = facebookCampaignObjectState.ParentId;
            SyncDataServiceHelper.RegisterCreatedFacebookAccountEntityForCleanup(facebookAccountEntity);
            SyncDataServiceHelper.InsertFacebookAccountIntoDB(facebookAccountEntity);

            //Generate randomized syncdata object
            ProxyDTO.Facebook.FacebookCampaignDTO facebookCampaignDTO = SyncDataServiceHelper.NextFacebookCampaignDTO();
            facebookCampaignDTO.ParentId = facebookAccountEntity.Id;

            //string JsonSerializedFacebookCampaignDTO = ServiceStack.Text.JsonSerializer.SerializeToString(facebookCampaignDTO, typeof(ProxyDTO.Facebook.FacebookCampaignDTO));
            ProxySync.SyncData facebookCampaignSyncData = SyncDataServiceHelper.NextSyncData();

            //Setting property of syncdata object
            facebookCampaignSyncData.ObjectDTO         = facebookCampaignDTO;
            facebookCampaignSyncData.ObjectId          = facebookCampaignObjectState.ObjectId;
            facebookCampaignSyncData.ParentId          = facebookCampaignObjectState.ParentId;
            facebookCampaignSyncData.LocalId           = precommitResponse.GrainId;
            facebookCampaignSyncData.EngineType        = (int)SearchEngineType.Facebook;
            facebookCampaignSyncData.ObjectDetailType  = (int)SEMObjectDetailType.FacebookCampaign;
            facebookCampaignSyncData.Operation         = 0;
            facebookCampaignSyncData.TimeStamp         = precommitResponse.PreCommitToken;
            facebookCampaignSyncData.GrainId           = facebookCampaignSyncData.LocalId;
            facebookCampaignSyncData.HostingCampaignId = -1;
            facebookCampaignSyncData.HostingId         = -1;
            facebookCampaignSyncData.HostingParentId   = -1;

            //Insert sequenceNumber into db
            TblSequenceNumber sequenceNumberEntity = SyncDataServiceHelper.NextSequenceNumberEntity();

            sequenceNumberEntity.EngineType = (int)facebookCampaignSyncData.EngineType;
            SyncDataServiceHelper.RegisterCreatedSequenceNumberEntityForCleanup(sequenceNumberEntity);
            SyncDataServiceHelper.InsertSequenceNumberIntoDB(sequenceNumberEntity);

            ProxySync.CommitResponse[] response = null;
            WCFHelper.Using <SyncDataServiceClient>(new SyncDataServiceClient(), client =>
            {
                response = client.NewDataCommit(new ProxySync.SyncData[] { facebookCampaignSyncData });
            });
            Assert.IsNotNull(response, "The response object should not be NULL!!");
            Assert.AreEqual(sequenceNumberEntity.Id + 1, response[0].HostingId, "The response object's hosting id should be equal to [tblSequenceNumber].[Id]+1");
            Assert.IsTrue(SyncDataServiceHelper.DoesExistSequenceNumberEntityInDB(
                              new TblSequenceNumber
            {
                Id         = sequenceNumberEntity.Id + 1,
                EngineType = sequenceNumberEntity.EngineType
            }));

            TblFacebookCampaign actualFacebookCampaignEntity;

            Assert.IsTrue(SyncDataServiceHelper.DoesExistFacebookCampaignEntityInDB(facebookCampaignDTO.Id, out actualFacebookCampaignEntity), "There should be one facebook campaign enty in db!!");
            SyncDataServiceHelper.CompareFacebookCampaignDTOAndEntityObject(facebookCampaignDTO, actualFacebookCampaignEntity, response[0].HostingId, response[0].HostingParentId, 1);
        }