public async Task Correct_Entity_Is_Inserted_When_Called() { // Arrange var expected = new OutcomeEntity { FileType = "docx", FileStatus = "rebuilt", RowKey = "1234567", PartitionKey = "durablefileprocessing" }; OutcomeEntity actualEntity = null; _mockCloudTable.Setup(s => s.ExecuteAsync(It.IsAny <TableOperation>())).Callback <TableOperation>((op) => { actualEntity = (OutcomeEntity)op.Entity; }); var cacheManager = new TableStorageCacheManager(_mockCacheClient.Object, _mockConfigurationSettings.Object); // Act await cacheManager.InsertEntityAsync(expected); // Assert Assert.That(actualEntity.FileType, Is.EqualTo(expected.FileType)); Assert.That(actualEntity.FileStatus, Is.EqualTo(expected.FileStatus)); Assert.That(actualEntity.RowKey, Is.EqualTo(expected.RowKey)); Assert.That(actualEntity.PartitionKey, Is.EqualTo(expected.PartitionKey)); }
public async Task Null_Is_Returned_When_Entity_IsNot_Found() { // Arrange _mockCloudTable.Setup(s => s.ExecuteAsync(It.IsAny <TableOperation>())).ReturnsAsync((TableResult)null); var cacheManager = new TableStorageCacheManager(_mockCacheClient.Object, _mockConfigurationSettings.Object); // Act var result = await cacheManager.GetEntityAsync("partitionKey", "rowKey"); // Assert Assert.That(result, Is.Null); }
public async Task Result_Is_Returned_When_Entity_Is_Found() { // Arrange var expected = new OutcomeEntity { FileType = "docx", FileStatus = "rebuilt", RowKey = "1234567" }; _mockCloudTable.Setup(s => s.ExecuteAsync(It.IsAny <TableOperation>())).ReturnsAsync(new TableResult { Result = expected }); var cacheManager = new TableStorageCacheManager(_mockCacheClient.Object, _mockConfigurationSettings.Object); // Act var result = await cacheManager.GetEntityAsync("partitionKey", "rowKey"); // Assert Assert.That(result.FileType, Is.EqualTo(expected.FileType)); Assert.That(result.FileStatus, Is.EqualTo(expected.FileStatus)); Assert.That(result.RowKey, Is.EqualTo(expected.RowKey)); }