public AzureProductProvider(AzureOptions azureOptions, IAzureClient azureClient, IProductRepository repository, IConverter<string, Product> stringConverter, IConverter<Product, ProductEntity> entityConverter) { _azureOptions = azureOptions; _azureClient = azureClient; _repository = repository; _stringConverter = stringConverter; _entityConverter = entityConverter; }
public AzureCategoryProvider(AzureOptions azureOptions, IAzureClient azureClient, ICategoryRepository repository, IConverter<Category, string> stringConverter, IConverter<Category, CategoryEntity> entityConverter) { _azureOptions = azureOptions; _azureClient = azureClient; _repository = repository; _stringConverter = stringConverter; _entityConverter = entityConverter; }
public async Task Get_Should_Pass_AzureOptions_ProductContainer_And_ProductId_To_AzureClient_GetBlobFromContainer() { // Arrange AzureOptions azureOptions = new AzureOptions { ProductsContainerName = "containerName" }; Guid productId = Guid.NewGuid(); IAzureClient client = CreateClient(azureOptions.ProductsContainerName, productId.ToString()); IAzureProductProvider provider = CreateProvider(azureOptions, client); // Act await provider.GetProduct(productId); // Assert Mock.Get(client).Verify(c => c.GetBlobFromContainer(azureOptions.ProductsContainerName, productId.ToString()), Times.Once); }
public async Task Get_Should_Pass_Content_Returned_By_AzureClient_GetBlobFromContainer_To_Converter_ConvertBack() { // Arrange const string content = "content"; AzureOptions azureOptions = new AzureOptions { ProductsContainerName = "containerName" }; IAzureClient client = CreateClient(content); var converter = new Mock<IConverter<string, Product>>(); converter.Setup(c => c.ConvertBack(It.IsAny<Product>())).Returns(content); IAzureProductProvider provider = CreateProvider(azureOptions, client, stringConverter: converter.Object); // Act await provider.GetProduct(Guid.NewGuid()); // Assert converter.Verify(c => c.Convert(content), Times.Once); }
private static IAzureProductProvider CreateProvider(AzureOptions azureOptions = null, IAzureClient azureClient = null, IProductRepository repository = null, IConverter<string, Product> stringConverter = null, IConverter<Product, ProductEntity> entityConverter = null) { return new AzureProductProvider( azureOptions ?? new AzureOptions(), azureClient ?? CreateClient(null), repository ?? Mock.Of<IProductRepository>(), stringConverter ?? CreateStringConverter(), entityConverter ?? CreateEntityConverter()); }
public async Task Set_Should_Pass_AzureOptions_ProductContainer_ProductId_And_Product_ProductId_To_AzureClient_PutBlobToContainer() { // Arrange AzureOptions azureOptions = new AzureOptions { ProductsContainerName = "containerName" }; Product product = new Fixture().Create<Product>(); IAzureClient client = CreateClient(azureOptions.ProductsContainerName, product.ProductId.ToString()); IAzureProductProvider provider = CreateProvider(azureOptions, client); // Act await provider.SaveProduct(product); // Arrange Mock.Get(client).Verify(c => c.PutBlobToContainer(azureOptions.ProductsContainerName, product.ProductId.ToString(), It.IsAny<string>()), Times.Once); }