public async Task Given_Values_When_UpsertVisitItemEntityAsync_Invoked_Then_It_Should_Return_Result(string shortUrl, HttpStatusCode statusCode) { var record = new VisitItemEntity() { ShortUrl = shortUrl }; var item = new Mock <ItemResponse <VisitItemEntity> >(); item.SetupGet(p => p.Resource).Returns(record); item.SetupGet(p => p.StatusCode).Returns(statusCode); var container = new Mock <Container>(); container.Setup(p => p.UpsertItemAsync <VisitItemEntity>(It.IsAny <VisitItemEntity>(), It.IsAny <PartitionKey?>(), It.IsAny <ItemRequestOptions>(), It.IsAny <CancellationToken>())) .ReturnsAsync(item.Object); var helper = new Mock <ICosmosDbContainerHelper>(); helper.Setup(p => p.GetContainerAsync()).ReturnsAsync(container.Object); var command = new CosmosDbCommand(helper.Object); var result = await command.UpsertItemEntityAsync <VisitItemEntity>(record).ConfigureAwait(false); result.Should().Be((int)statusCode); }
public void Given_Null_When_UpsertUrlItemEntityAsync_Invoked_Then_It_Should_Throw_Exception() { var helper = new Mock <ICosmosDbContainerHelper>(); var command = new CosmosDbCommand(helper.Object); Func <Task> func = async() => await command.UpsertItemEntityAsync <FakeItemEntity>(null).ConfigureAwait(false); func.Should().Throw <ArgumentNullException>(); }