public async Task TestCrudOperationsAsync() { // Create one dummy var dummy1 = await _persistence.CreateAsync(null, _dummy1); Assert.NotNull(dummy1); Assert.NotNull(dummy1.Id); Assert.Equal(_dummy1.Key, dummy1.Key); Assert.Equal(_dummy1.Content, dummy1.Content); // Create another dummy var dummy2 = await _persistence.CreateAsync(null, _dummy2); Assert.NotNull(dummy2); Assert.NotNull(dummy2.Id); Assert.Equal(_dummy2.Key, dummy2.Key); Assert.Equal(_dummy2.Content, dummy2.Content); //// Get all dummies //var dummies = await _get.GetAllAsync(null); //Assert.NotNull(dummies); //Assert.Equal(2, dummies.Count()); // Update the dummy dummy1.Content = "Updated Content 1"; var dummy = await _persistence.UpdateAsync(null, dummy1); Assert.NotNull(dummy); Assert.Equal(dummy1.Id, dummy.Id); Assert.Equal(dummy1.Key, dummy.Key); Assert.Equal(dummy1.Content, dummy.Content); // Update partially the dummy dummy = await _persistence.UpdatePartiallyAsync(null, dummy1.Id, AnyValueMap.FromTuples( "content", "Partially Updated Content 1" )); Assert.NotNull(dummy); Assert.Equal(dummy1.Id, dummy.Id); Assert.Equal(dummy1.Key, dummy.Key); Assert.Equal("Partially Updated Content 1", dummy.Content); // Delete the dummy await _persistence.DeleteByIdAsync(null, dummy1.Id); // Try to get deleted dummy dummy = await _persistence.GetOneByIdAsync(null, dummy1.Id); Assert.Null(dummy); }
public async Task TestCrudOperationsAsync() { // Create one dummy var dummy1 = await _persistence.CreateAsync(null, _dummy1); Assert.NotNull(dummy1); Assert.NotNull(dummy1.Id); Assert.Equal(_dummy1.Key, dummy1.Key); Assert.Equal(_dummy1.Content, dummy1.Content); // Create another dummy var dummy2 = await _persistence.CreateAsync(null, _dummy2); Assert.NotNull(dummy2); Assert.NotNull(dummy2.Id); Assert.Equal(_dummy2.Key, dummy2.Key); Assert.Equal(_dummy2.Content, dummy2.Content); // Update the dummy dummy1.Content = "Updated Content 1"; var dummy = await _persistence.UpdateAsync(null, dummy1); Assert.NotNull(dummy); Assert.Equal(dummy1.Id, dummy.Id); Assert.Equal(dummy1.Key, dummy.Key); Assert.Equal(dummy1.Content, dummy.Content); // Get count dummies var count = await _persistence.GetCountAsync(null, null); Assert.Equal(2, count); // Delete the dummy await _persistence.DeleteByIdAsync(null, dummy1.Id); // Try to get deleted dummy dummy = await _persistence.GetOneByIdAsync(null, dummy1.Id); Assert.Null(dummy); }
public async Task TestCrudOperationsAsync() { //// Create one dummy var dummy1 = await _persistence.CreateAsync(null, _dummy1); Assert.NotNull(dummy1); Assert.NotNull(dummy1.Id); Assert.NotNull(dummy1.SubDummy); Assert.Equal(_dummy1.Key, dummy1.Key); Assert.Equal(_dummy1.Content, dummy1.Content); Assert.Equal(_dummy1.CreateTimeUtc, dummy1.CreateTimeUtc, TimeSpan.FromMilliseconds(1000)); Assert.Equal(_dummy1.SubDummy.Type, dummy1.SubDummy.Type); Assert.Equal(_dummy1.SubDummy.ArrayOfDouble, dummy1.SubDummy.ArrayOfDouble); // Create another dummy var dummy2 = await _persistence.CreateAsync(null, _dummy2); Assert.NotNull(dummy2); Assert.NotNull(dummy2.Id); Assert.NotNull(dummy2.SubDummy); Assert.Equal(_dummy2.Key, dummy2.Key); Assert.Equal(_dummy2.Content, dummy2.Content); Assert.Equal(_dummy2.CreateTimeUtc, dummy2.CreateTimeUtc, TimeSpan.FromMilliseconds(1000)); Assert.Equal(_dummy2.SubDummy.Type, dummy2.SubDummy.Type); Assert.Equal(_dummy2.SubDummy.ArrayOfDouble, dummy2.SubDummy.ArrayOfDouble); var page = await _persistence.GetPageByFilterAsync(null, null, null); Assert.NotNull(page); Assert.Equal(2, page.Data.Count); page = await _persistence.GetPageByFilterAsync(null, FilterParams.FromTuples("key", _dummy2.Key), null); Assert.NotNull(page); Assert.Single(page.Data); // Update the dummy dummy1.Content = "Updated Content 1"; var result = await _persistence.UpdateAsync(null, dummy1); Assert.NotNull(result); Assert.NotNull(result.SubDummy); Assert.Equal(dummy1.Id, result.Id); Assert.Equal(dummy1.Key, result.Key); Assert.Equal(dummy1.Content, result.Content); Assert.Equal(dummy1.CreateTimeUtc, result.CreateTimeUtc, TimeSpan.FromMilliseconds(1000)); Assert.Equal(dummy1.SubDummy.Type, result.SubDummy.Type); Assert.Equal(dummy1.SubDummy.ArrayOfDouble, result.SubDummy.ArrayOfDouble); // Set the dummy dummy1.Content = "Updated Content 2"; result = await _persistence.SetAsync(null, dummy1); Assert.NotNull(result); Assert.NotNull(result.SubDummy); Assert.Equal(dummy1.Id, result.Id); Assert.Equal(dummy1.Key, result.Key); Assert.Equal(dummy1.Content, result.Content); Assert.Equal(dummy1.CreateTimeUtc, result.CreateTimeUtc, TimeSpan.FromMilliseconds(1000)); Assert.Equal(dummy1.SubDummy.Type, result.SubDummy.Type); Assert.Equal(dummy1.SubDummy.ArrayOfDouble, result.SubDummy.ArrayOfDouble); // Partially update the dummy result = await _persistence.UpdatePartially(null, dummy1.Id, AnyValueMap.FromTuples("content", "Partially Updated Content 1")); Assert.NotNull(result); Assert.Equal(dummy1.Id, result.Id); Assert.Equal(dummy1.Key, result.Key); Assert.Equal("Partially Updated Content 1", result.Content); // Get the dummy by Id result = await _persistence.GetOneByIdAsync(null, dummy1.Id); Assert.NotNull(result); Assert.Equal(dummy1.Id, result.Id); Assert.Equal(dummy1.Key, result.Key); // Delete the dummy result = await _persistence.DeleteByIdAsync(null, dummy1.Id); Assert.NotNull(result); Assert.Equal(dummy1.Id, result.Id); Assert.Equal(dummy1.Key, result.Key); // Get the deleted dummy result = await _persistence.GetOneByIdAsync(null, dummy1.Id); Assert.Null(result); var count = await _persistence.GetCountByFilterAsync(null, null); Assert.Equal(1, count); }