示例#1
0
    public async Task NothingWasAdded_SaveChangesAsync_WasNotCalled()
    {
        //Arrange
        var context = new TestableDbProvider <string>(TestParameters.KsqlDBUrl);

        //Act
        var response = await context.SaveChangesAsync();

        //Assert
        response.Should().BeNull();
    }
示例#2
0
    public async Task AddAndSaveChangesAsync()
    {
        //Arrange
        var context = new TestableDbProvider <string>(TestParameters.KsqlDBUrl);

        var entity = new Tweet();

        context.KSqlDbRestApiClientMock.Setup(c => c.ToInsertStatement(entity, null)).Returns(new KSqlDbStatement("Insert Into"));

        //Act
        context.Add(entity);
        await context.SaveChangesAsync();

        //Assert
        context.KSqlDbRestApiClientMock.Verify(c => c.ToInsertStatement(entity, null), Times.Once);
        context.KSqlDbRestApiClientMock.Verify(c => c.ExecuteStatementAsync(It.IsAny <KSqlDbStatement>(), It.IsAny <CancellationToken>()), Times.Once);
    }