public async Task TestRemoveInstanceId() { IUpdateBlob updateBlob = await _updateBlobFactory.TryLockUpdateBlob("appId"); updateBlob.SetUpdateDomain("1"); updateBlob.AddInstance("instanceId1"); updateBlob.AddInstance("instanceId2"); await updateBlob.FlushAndRelease(); updateBlob = await _updateBlobFactory.TryLockUpdateBlob("appId"); updateBlob.RemoveInstance("instanceId1"); await updateBlob.FlushAndRelease(); await updateBlob.TryLock(); Assert.Equal("1", updateBlob.GetUpdateDomain()); AssertUtils.ContainsSameElementsInAnyOrder(new[] { "instanceId2" }, updateBlob.GetInstanceIds()); await updateBlob.Release(); updateBlob = await _updateBlobFactory.TryLockUpdateBlob("appId"); updateBlob.RemoveInstance("instanceId2"); await updateBlob.FlushAndRelease(); await updateBlob.TryLock(); Assert.True(string.IsNullOrEmpty(updateBlob.GetUpdateDomain())); Assert.Empty(updateBlob.GetInstanceIds()); }
public async Task TestAddingMultipleInstanceIds() { IUpdateBlob updateBlob = await _updateBlobFactory.TryLockUpdateBlob("appId"); updateBlob.SetUpdateDomain("1"); updateBlob.AddInstance("instanceId1"); updateBlob.AddInstance("instanceId2"); await updateBlob.FlushAndRelease(); await updateBlob.TryLock(); Assert.Equal("1", updateBlob.GetUpdateDomain()); AssertUtils.ContainsSameElementsInAnyOrder(new[] { "instanceId1", "instanceId2" }, updateBlob.GetInstanceIds()); }
public async Task TestSetDataWhenBlobIsEmpty() { IUpdateBlob updateBlob = await _updateBlobFactory.TryLockUpdateBlob("appId"); const string instanceId = "instanceId"; const string updateDomain = "1"; updateBlob.SetUpdateDomain(updateDomain); updateBlob.AddInstance(instanceId); await updateBlob.FlushAndRelease(); await updateBlob.TryLock(); Assert.Equal(updateDomain, updateBlob.GetUpdateDomain()); AssertUtils.ContainsSameElementsInAnyOrder(new[] { instanceId }, updateBlob.GetInstanceIds()); }