public void CanGetWithSync() { var apiEntity1 = new ApiSample { Id = Guid.NewGuid() }; var apiEntity2 = new ApiSample { Id = Guid.NewGuid() }; var sampleController = new SampleController(this.service); var apiSync = sampleController.GetAsync(-1).Result; Assert.AreEqual(0, apiSync.LastSync); Assert.AreEqual(0, apiSync.Data.Length); Assert.AreEqual(0, apiSync.DeletedData.Length); this.service.WriteAsync(apiEntity1).Wait(); apiSync = sampleController.GetAsync(apiSync.LastSync).Result; Assert.AreEqual(1, apiSync.LastSync); Assert.AreEqual(1, apiSync.Data.Length); Assert.AreEqual(apiEntity1.Id, apiSync.Data[0].Id); Assert.AreEqual(0, apiSync.DeletedData.Length); this.service.WriteAsync(apiEntity2).Wait(); this.service.RemoveAsync(apiEntity1).Wait(); apiSync = sampleController.GetAsync(apiSync.LastSync).Result; Assert.AreEqual(3, apiSync.LastSync); Assert.AreEqual(1, apiSync.Data.Length); Assert.AreEqual(apiEntity2.Id, apiSync.Data[0].Id); Assert.AreEqual(1, apiSync.DeletedData.Length); Assert.AreEqual(apiEntity1.Id, apiSync.DeletedData[0]); }
public void CanRemoveEntities() { var apiEntity1 = new ApiSample { Id = Guid.NewGuid(), SomeData = "testData" }; var apiEntity2 = new ApiSample { Id = Guid.NewGuid(), SomeData = "testData" }; var apiEntity3 = new ApiSample { Id = Guid.NewGuid(), SomeData = "testData" }; service.Write(apiEntity1); service.Remove(apiEntity1); var readedEntities = service.Read(x => !x.IsDeleted); Assert.AreEqual(0, readedEntities.Length); service.Write(new[] { apiEntity2, apiEntity3 }); service.Remove(new[] { apiEntity2, apiEntity3 }); readedEntities = service.Read(x => !x.IsDeleted); Assert.AreEqual(0, readedEntities.Length); }
public void CanReadSyncedDataWithFilter() { ApiSample[] apiEntities; Guid[] deletedIds; var apiEntity1 = new ApiSample { Id = Guid.NewGuid(), SomeData = "1" }; service.Write(apiEntity1); var apiEntity2 = new ApiSample { Id = Guid.NewGuid(), SomeData = "2" }; service.Write(apiEntity2); var sync = service.ReadSyncedData(0, out apiEntities, out deletedIds, x => x.SomeData == "2"); Assert.AreEqual(1, apiEntities.Length); Assert.AreEqual(2, sync); }
public void CanRemoveEntities() { var apiEntity1 = new ApiSample { Id = Guid.NewGuid(), SomeData = "testData" }; var apiEntity2 = new ApiSample { Id = Guid.NewGuid(), SomeData = "testData" }; var apiEntity3 = new ApiSample { Id = Guid.NewGuid(), SomeData = "testData" }; this.service.WriteAsync(apiEntity1).Wait(); this.service.RemoveAsync(apiEntity1).Wait(); var readedEntities = this.service.ReadAsync(x => !x.IsDeleted).Result; Assert.AreEqual(0, readedEntities.Count); this.service.WriteAsync(new[] { apiEntity2, apiEntity3 }).Wait(); this.service.RemoveAsync(new[] { apiEntity2, apiEntity3 }).Wait(); readedEntities = this.service.ReadAsync(x => !x.IsDeleted).Result; Assert.AreEqual(0, readedEntities.Count); }
public async Task CanRemoveEntitiesAsync() { var apiEntity1 = new ApiSample { Id = Guid.NewGuid(), SomeData = "testData" }; var apiEntity2 = new ApiSample { Id = Guid.NewGuid(), SomeData = "testData" }; var apiEntity3 = new ApiSample { Id = Guid.NewGuid(), SomeData = "testData" }; await service.WriteAsync(apiEntity1); await service.RemoveAsync(apiEntity1); var readedEntities = await service.ReadAsync(x => !x.IsDeleted); Assert.AreEqual(0, readedEntities.Length); await service.WriteAsync(new[] { apiEntity2, apiEntity3 }); await service.RemoveAsync(new[] { apiEntity2, apiEntity3 }); readedEntities = await service.ReadAsync(x => !x.IsDeleted); Assert.AreEqual(0, readedEntities.Length); }
public void ExistsIsCorrect() { var apiEntity = new ApiSample { Id = Guid.NewGuid(), SomeData = "test" }; this.service.WriteAsync(apiEntity).Wait(); Assert.IsTrue(this.service.ExistsAsync(apiEntity.Id).Result); Assert.IsFalse(this.service.ExistsAsync(Guid.NewGuid()).Result); }
public void ExistsIsCorrect() { var apiEntity = new ApiSample { Id = Guid.NewGuid(), SomeData = "test" }; service.Write(apiEntity); Assert.IsTrue(service.Exists(apiEntity.Id)); Assert.IsFalse(service.Exists(Guid.NewGuid())); }
public void CanGetById() { var apiEntity = new ApiSample { Id = Guid.NewGuid() }; this.service.WriteAsync(apiEntity).Wait(); var sampleController = new SampleController(this.service); var resultApiEntity = sampleController.GetAsync(apiEntity.Id).Result; Assert.IsTrue(ObjectsComparer.AreEqual(apiEntity, resultApiEntity)); }
public void CanGetById() { var apiEntity = new ApiSample { Id = Guid.NewGuid() }; service.Write(apiEntity); var sampleController = new SampleController(service); var resultApiEntity = sampleController.Get(apiEntity.Id); Assert.IsTrue(ObjectsComparer.AreEqual(apiEntity, resultApiEntity)); }
public void CanWriteAndRead() { var apiEntity = new ApiSample { Id = Guid.NewGuid(), SomeData = "test" }; this.service.WriteAsync(apiEntity).Wait(); var readedApiEntity = this.service.ReadAsync(apiEntity.Id).Result; Assert.IsTrue(ObjectsComparer.AreEqual(apiEntity, readedApiEntity)); }
public void CanWriteAndRead() { var apiEntity = new ApiSample { Id = Guid.NewGuid(), SomeData = "test" }; service.Write(apiEntity); var readedApiEntity = service.Read(apiEntity.Id); Assert.IsTrue(ObjectsComparer.AreEqual(apiEntity, readedApiEntity)); }
public async Task ExistsIsCorrectAsync() { var apiEntity = new ApiSample { Id = Guid.NewGuid(), SomeData = "test" }; await service.WriteAsync(apiEntity); Assert.IsTrue(await service.ExistsAsync(apiEntity.Id)); Assert.IsFalse(await service.ExistsAsync(Guid.NewGuid())); }
public async Task CanWriteAndReadAsync() { var apiEntity = new ApiSample { Id = Guid.NewGuid(), SomeData = "test" }; await service.WriteAsync(apiEntity); var readedApiEntity = await service.ReadAsync(apiEntity.Id); Assert.IsTrue(ObjectsComparer.AreEqual(apiEntity, readedApiEntity)); }
public void CanPostApiEntity() { var apiEntity = new ApiSample { Id = Guid.NewGuid() }; var sampleController = new SampleController(service); sampleController.Post(apiEntity); var readedEtity = service.Read(apiEntity.Id); Assert.IsTrue(ObjectsComparer.AreEqual(apiEntity, readedEtity)); }
public void CanPostApiEntity() { var apiEntity = new ApiSample { Id = Guid.NewGuid() }; var sampleController = new SampleController(this.service); sampleController.PostAsync(apiEntity).Wait(); var readedEtity = this.service.ReadAsync(apiEntity.Id).Result; Assert.IsTrue(ObjectsComparer.AreEqual(apiEntity, readedEtity)); }
public void TryReadIsCorrect() { var apiEntity = new ApiSample { Id = Guid.NewGuid(), SomeData = "test" }; service.Write(apiEntity); ApiSample resultApiEntity; var readResult = service.TryRead(apiEntity.Id, out resultApiEntity); Assert.IsTrue(readResult); Assert.IsTrue(ObjectsComparer.AreEqual(apiEntity, resultApiEntity)); readResult = service.TryRead(Guid.NewGuid(), out resultApiEntity); Assert.IsFalse(readResult); Assert.AreEqual(default(ApiSample), resultApiEntity); }
public async Task CanReadSyncedDataWithFilterAsync() { var apiEntity1 = new ApiSample { Id = Guid.NewGuid(), SomeData = "1" }; await service.WriteAsync(apiEntity1); var apiEntity2 = new ApiSample { Id = Guid.NewGuid(), SomeData = "2" }; await service.WriteAsync(apiEntity2); var syncResult = await service.ReadSyncedDataAsync(0, x => x.SomeData == "2"); Assert.AreEqual(1, syncResult.NewData.Length); Assert.AreEqual(2, syncResult.LastSync); }
public async Task CanReadSyncedDataAsync() { var syncResult = await service.ReadSyncedDataAsync(0); Assert.AreEqual(0, syncResult.LastSync); var apiEntity1 = new ApiSample { Id = Guid.NewGuid() }; await service.WriteAsync(apiEntity1); var apiEntity2 = new ApiSample { Id = Guid.NewGuid() }; await service.WriteAsync(apiEntity2); syncResult = await service.ReadSyncedDataAsync(syncResult.LastSync); var apiEntities = syncResult.NewData; Assert.AreEqual(2, apiEntities.Length); Assert.AreEqual(2, syncResult.LastSync); var previousSync = syncResult.LastSync; syncResult = await service.ReadSyncedDataAsync(syncResult.LastSync); Assert.AreEqual(previousSync, syncResult.LastSync); await service.RemoveAsync(apiEntity2); syncResult = await service.ReadSyncedDataAsync(syncResult.LastSync); var deletedIds = syncResult.DeletedIds; Assert.AreEqual(1, deletedIds.Length); Assert.AreEqual(3, syncResult.LastSync); }
public void CanReadSyncedData() { ApiSample[] apiEntities; Guid[] deletedIds; var sync = service.ReadSyncedData(0, out apiEntities, out deletedIds); Assert.AreEqual(0, sync); var apiEntity1 = new ApiSample { Id = Guid.NewGuid() }; service.Write(apiEntity1); var apiEntity2 = new ApiSample { Id = Guid.NewGuid() }; service.Write(apiEntity2); sync = service.ReadSyncedData(sync, out apiEntities, out deletedIds); Assert.AreEqual(2, apiEntities.Length); Assert.AreEqual(2, sync); var previousSync = sync; sync = service.ReadSyncedData(sync, out apiEntities, out deletedIds); Assert.AreEqual(previousSync, sync); service.Remove(apiEntity2); sync = service.ReadSyncedData(sync, out apiEntities, out deletedIds); Assert.AreEqual(1, deletedIds.Length); Assert.AreEqual(3, sync); }
public void CanReadSyncedDataWithFilter() { var apiEntity1 = new ApiSample { Id = Guid.NewGuid(), SomeData = "1" }; this.service.WriteAsync(apiEntity1).Wait(); var apiEntity2 = new ApiSample { Id = Guid.NewGuid(), SomeData = "2" }; this.service.WriteAsync(apiEntity2).Wait(); var apiSync = this.service.ReadSyncedDataAsync(0, x => x.SomeData == "2").Result; Assert.AreEqual(1, apiSync.Data.Length); Assert.AreEqual(2, apiSync.LastSync); }
public async Task TryReadIsCorrectAsync() { var apiEntity = new ApiSample { Id = Guid.NewGuid(), SomeData = "test" }; await service.WriteAsync(apiEntity); var readResult = await service.TryReadAsync(apiEntity.Id); var resultApiEntity = readResult.Item2; Assert.IsTrue(readResult.Item1); Assert.IsTrue(ObjectsComparer.AreEqual(apiEntity, resultApiEntity)); readResult = await service.TryReadAsync(Guid.NewGuid()); resultApiEntity = readResult.Item2; Assert.IsFalse(readResult.Item1); Assert.AreEqual(default(ApiSample), resultApiEntity); }
public void CanReadSyncedData() { var apiSync = this.service.ReadSyncedDataAsync(0).Result; Assert.AreEqual(0, apiSync.LastSync); var apiEntity1 = new ApiSample { Id = Guid.NewGuid() }; this.service.WriteAsync(apiEntity1).Wait(); var apiEntity2 = new ApiSample { Id = Guid.NewGuid() }; this.service.WriteAsync(apiEntity2).Wait(); apiSync = this.service.ReadSyncedDataAsync(apiSync.LastSync).Result; Assert.AreEqual(2, apiSync.Data.Length); Assert.AreEqual(2, apiSync.LastSync); var previousSync = apiSync.LastSync; apiSync = this.service.ReadSyncedDataAsync(apiSync.LastSync).Result; Assert.AreEqual(previousSync, apiSync.LastSync); this.service.RemoveAsync(apiEntity2).Wait(); apiSync = this.service.ReadSyncedDataAsync(apiSync.LastSync).Result; Assert.AreEqual(1, apiSync.DeletedData.Length); Assert.AreEqual(3, apiSync.LastSync); }
public void Post(ApiSample apiSample) { service.Write(apiSample); }
public async Task PostAsync(ApiSample apiSample) { await this.service.WriteAsync(apiSample).ConfigureAwait(false); }