コード例 #1
0
        public async Task FindProduct_returns_null_if_product_not_exists(
            string supplierName, string productCode)
        {
            Container container = GetCosmosContainer();
            var       sut       = new CosmosProductRepository(container);

            Product?actual = await sut.FindProduct(supplierName, productCode);

            actual.Should().BeNull();
        }
コード例 #2
0
        public async Task CreateOrReplaceProduct_correctly_creates_new_product(Product product)
        {
            Container container = GetCosmosContainer();
            var       sut       = new CosmosProductRepository(container);

            await sut.CreateOrReplaceProduct(product);

            Product?actual = await sut.FindProduct(product.SupplierName, product.ProductCode);

            actual.Should().BeEquivalentTo(product);
        }
コード例 #3
0
        public async Task FindProduct_correctly_returns_entity(Product product)
        {
            Container container = GetCosmosContainer();
            await container.CreateItemAsync(product);

            var sut = new CosmosProductRepository(container);

            Product?actual = await sut.FindProduct(product.SupplierName, product.ProductCode);

            actual.Should().BeEquivalentTo(product);
        }
コード例 #4
0
        public async Task CreateOrReplaceProduct_correctly_updates_existing_product(
            Product source, string productName, Pricing pricing)
        {
            Container container = GetCosmosContainer();
            await container.CreateItemAsync(source);

            var sut     = new CosmosProductRepository(container);
            var product = new Product(source.SupplierName, source.ProductCode, productName, pricing);

            await sut.CreateOrReplaceProduct(product);

            Product?actual = await sut.FindProduct(source.SupplierName, source.ProductCode);

            actual.Should().BeEquivalentTo(product);
        }