public void CanCreateMockContext() { var mockContext = new StorageContextMockFactory().CreateStorageContextMock(); var context = mockContext.Object; Assert.NotNull(context); }
public void RegisterClean_Should_AddRecordInEntityMap() { var mockContext = new StorageContextMockFactory().CreateStorageContextMock(); var context = mockContext.Object; var musician = new Musician("John Doe", "Anonymous", "*****@*****.**"); Assert.DoesNotContain(musician, context.Entities); context.RegisterClean(musician); Assert.Contains(musician, context.Entities); }
public void RegisterNew_WhenObjectIsInRemovedEntities_ShouldThrowException() { var mockContext = new StorageContextMockFactory().CreateStorageContextMock(); var context = mockContext.Object; var musician = new Musician("John Doe", "Anonymous", "*****@*****.**"); Assert.DoesNotContain(musician, context.Entities); context.RegisterRemoved(musician); Assert.Contains(musician, context.Entities); Assert.Throws <InvalidOperationException>(() => context.RegisterNew(musician)); }
public async Task Get_Should_RetrieveEntityFromEntityMap() { var mockContext = new StorageContextMockFactory().CreateStorageContextMock(); var context = mockContext.Object; var musician = new Musician("John Doe", "Anonymous", "*****@*****.**"); context.RegisterNew(musician); var loadedMusician = await context.GetAsync <Musician>(musician.PartitionKey, musician.RowKey, CancellationToken.None); Assert.Equal(musician, loadedMusician, new TableEntityEqualityComparer <Musician>()); }
public async Task SaveChangesAsync_ShouldCallDeleteRemoedEntitiesAsync() { var mockContext = new StorageContextMockFactory().CreateStorageContextMock(); var context = mockContext.Object; await context.SaveChangesAsync(); mockContext.Protected().Verify("DeleteRemovedEntitiesAsync", Times.Once(), ItExpr.IsAny <CancellationToken>(), ItExpr.IsAny <TableRequestOptions>(), ItExpr.IsAny <OperationContext>()); }
public void RegisterMultipleDifferentEntitiesWithSameKeys_Should_AddRecordsInEntityMap() { var mockContext = new StorageContextMockFactory().CreateStorageContextMock(); var context = mockContext.Object; var musician = new Musician("John Doe", "Anonymous", "*****@*****.**"); var bandTeacher = new BandTeacher("John Doe", "Anonymous", "*****@*****.**"); Assert.DoesNotContain(musician, context.Entities); Assert.DoesNotContain(bandTeacher, context.Entities); context.RegisterNew(musician); context.RegisterNew(bandTeacher); Assert.Contains(musician, context.Entities); Assert.Contains(bandTeacher, context.Entities); }