public Task Upsert(Invoice invoice) { var invoiceState = invoice.Deflate(); invoiceState.TenantId = _currentTenantProvider.Get(); return(_dbContext.Invoices.UpsertItemAsync(invoiceState, new PartitionKey(_currentTenantProvider.Get()))); }
public Task Upsert(Customer customer) { var customerState = customer.Deflate(); customerState.TenantId = _currentTenantProvider.Get(); return(_dbContext.Customers.UpsertItemAsync(customerState, new PartitionKey(_currentTenantProvider.Get()))); }
public async Task GIVEN_invoice_with_id_WHEN_Get_THEN_returns_invoice() { var expectedInvoiceState = _fixture.Build <InvoiceState>() .With(_ => _.TenantId, _currentTenantProvider.Get()) .Create(); A.CallTo(() => _dbContext.Invoices).Returns(ContainerFactory.FakeContainer(new [] { expectedInvoiceState })); var invoice = await _sut.Get(expectedInvoiceState.Id); var actualInvoiceState = invoice.Deflate(); actualInvoiceState.TenantId = _currentTenantProvider.Get(); AssertEx.Equal(expectedInvoiceState, actualInvoiceState); }
public async Task GIVEN_customer_with_id_WHEN_Get_THEN_returns_customer() { var expectedCustomerState = _fixture.Build <CustomerState>() .With(_ => _.TenantId, _currentTenantProvider.Get()) .Create(); A.CallTo(() => _dbContext.Customers).Returns(ContainerFactory.FakeContainer(new [] { expectedCustomerState })); var customer = await _sut.Get(expectedCustomerState.Id); var actualCustomerState = customer.Deflate(); actualCustomerState.TenantId = _currentTenantProvider.Get(); AssertEx.Equal(expectedCustomerState, actualCustomerState); }
public ValueTask <bool> CustomerExists(Guid id) { var query = _dbContext.Customers .GetItemLinqQueryable <CustomerState>() .Where(_ => _.TenantId == _currentTenantProvider.Get() && _.Id == id); return(_cosmosLinqQuery.GetFeedIterator(query).ToAsyncEnumerable().AnyAsync()); }
public async Task GIVEN_invoice_with_id_WHEN_InvoiceExists_THEN_return_false() { var expectedInvoiceState = _fixture.Build <InvoiceState>() .With(_ => _.TenantId, _currentTenantProvider.Get()) .Create(); A.CallTo(() => _dbContext.Invoices).Returns(ContainerFactory.FakeContainer(new [] { expectedInvoiceState })); var invoiceExists = await _sut.InvoiceExists(expectedInvoiceState.Id); Assert.True(invoiceExists); }