示例#1
0
        public ProxySync.SyncData NextSyncData()
        {
            ProxySync.SyncData syncData = new ProxySync.SyncData();

            syncData.EngineType        = (int)NextSearchEngineType();
            syncData.GrainId           = RandomData.NextGuid();
            syncData.HostingCampaignId = (Int64)RandomData.NextUInt32();
            syncData.HostingId         = (Int64)RandomData.NextUInt32();
            syncData.LocalId           = RandomData.NextGuid();
            syncData.ObjectDetailType  = (int)NextSEMObjectDetailType();
            syncData.ObjectId          = (Int64)RandomData.NextUInt32();
            syncData.Operation         = (int)NextOperationType();
            syncData.ParentId          = (Int64)RandomData.NextUInt32();
            syncData.TimeStamp         = RandomData.NextDateTime(new TimeSpan(1, 0, 0, 0)).Ticks;
            syncData.TimeTick          = syncData.TimeStamp;

            return(syncData);
        }
示例#2
0
 public ProxySync.SyncData NextSyncData(string JsonSerializedData)
 {
     ProxySync.SyncData syncData = NextSyncData();
     syncData.Data = JsonSerializedData;
     return(syncData);
 }
        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);
        }