public IEnumerable <ProxySync.PreCommitResponse> TestPreCommitVersionCompare_FacebookAccount(long differentBetweenHostingVersionAndLocalVersion, out ProxySync.ObjectState facebookAccountObjectState) { facebookAccountObjectState = NextObjectState(); facebookAccountObjectState.HostingId = -1; facebookAccountObjectState.ObjectDetailType = (int)SEMObjectDetailType.FacebookAccount; facebookAccountObjectState.IsVersionCompare = true; facebookAccountObjectState.EngineType = (int)SearchEngineType.Facebook; facebookAccountObjectState.LocalId = SyncDataServiceHelper.GenerateLocalId(facebookAccountObjectState); TblFacebookAccount facebookAccountEntity = NextFacebookAccountEntity(); facebookAccountEntity.Id = facebookAccountObjectState.ObjectId; facebookAccountEntity.ParentId = facebookAccountObjectState.ParentId; facebookAccountEntity.Version = facebookAccountObjectState.LocalVersion + differentBetweenHostingVersionAndLocalVersion; RegisterCreatedFacebookAccountEntityForCleanup(facebookAccountEntity); InsertFacebookAccountIntoDB(facebookAccountEntity); ProxySync.PreCommitResponse[] responses = null; ProxySync.ObjectState facebookAccountObejctStateForLambdaExpression = facebookAccountObjectState; WCFHelper.Using <SyncDataServiceClient>(new SyncDataServiceClient(), client => { responses = client.PreCommit(new ProxySync.ObjectState[] { facebookAccountObejctStateForLambdaExpression }); }); return(responses); }
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!!"); }
public TblFacebookAccount NextFacebookAccountEntity() { TblFacebookAccount tblFacebookAccount = new TblFacebookAccount(); tblFacebookAccount.Currency = RandomData.NextUnicodeWord(500); tblFacebookAccount.DailyAccountLimit = RandomData.NextInt32(); tblFacebookAccount.Id = (Int64)RandomData.NextUInt32(); tblFacebookAccount.LastDownloadDate = RandomData.NextDateTime(new TimeSpan(1, 0, 0, 0)); tblFacebookAccount.LastUpdateTime = RandomData.NextDateTime(new TimeSpan(1, 0, 0, 0)); tblFacebookAccount.LocalId = (Int64)RandomData.NextUInt32(); tblFacebookAccount.LocalParentId = (Int64)RandomData.NextUInt32(); tblFacebookAccount.LocalState = RandomData.NextByte(); tblFacebookAccount.LocalStatus = RandomData.NextByte(); tblFacebookAccount.Name = RandomData.NextUnicodeWord(500); tblFacebookAccount.ParentId = (Int64)RandomData.NextUInt32(); tblFacebookAccount.Status = RandomData.NextInt32(); tblFacebookAccount.TimeZone = RandomData.NextInt32(); tblFacebookAccount.Version = (Int64)RandomData.NextInt16(); return(tblFacebookAccount); }
public void RegisterCreatedFacebookAccountEntityForCleanup(TblFacebookAccount facebookAccountEntity) { this.createdFacebookAccountEntitiesForCleanup.Add(facebookAccountEntity); }
public void InsertFacebookAccountIntoDB(TblFacebookAccount facebookAccountEntity) { SEMObjects.TblFacebookAccount.InsertOnSubmit(facebookAccountEntity); SEMObjects.SubmitChanges(); }
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); }