Ejemplo n.º 1
0
    public void CommandDelegate_Throws_On_Unsupported_DatabaseOperation(DatabaseOperation operation)
    {
        // Arrange
        var sut    = new TestEntityDatabaseCommandEntityProvider();
        var entity = new TestEntityBuilder(new TestEntity("", "", ""));

        // Act
        sut.Invoking(x => x.CommandDelegate.Invoke(entity, operation))
        .Should().Throw <ArgumentOutOfRangeException>()
        .And.ParamName.Should().Be("operation");
    }
Ejemplo n.º 2
0
    public void CommandDelegate_Returns_Correct_Command(DatabaseOperation operation, string expectedCommandText)
    {
        // Arrange
        var sut    = new TestEntityDatabaseCommandEntityProvider();
        var entity = new TestEntityBuilder(new TestEntity("", "", ""));

        // Act
        var actual = sut.CommandDelegate.Invoke(entity, operation);

        // Assert
        actual.CommandText.Should().Be(expectedCommandText);
    }
Ejemplo n.º 3
0
    public void AfterReadDelegate_Returns_Correct_ResultEntity(DatabaseOperation operation)
    {
        // Arrange
        var sut        = new TestEntityDatabaseCommandEntityProvider();
        var entity     = new TestEntityBuilder(new TestEntity("", "", ""));
        var readerMock = new Mock <IDataReader>();

        readerMock.SetupGet(x => x.FieldCount).Returns(3);
        readerMock.Setup(x => x.GetName(It.IsAny <int>())).Returns <int>(index =>
                                                                         index switch
        {
            0 => "Code",
            1 => "CodeType",
            2 => "Description",
            _ => string.Empty,
        }
Ejemplo n.º 4
0
    public void ResultEntityDelegate_Returns_Correct_ResultEntity(DatabaseOperation operation)
    {
        // Arrange
        var sut    = new TestEntityDatabaseCommandEntityProvider();
        var entity = new TestEntityBuilder(new TestEntity("", "", ""));

        // Act
        sut.ResultEntityDelegate.Should().NotBeNull();
        if (sut.ResultEntityDelegate != null)
        {
            var actual = sut.ResultEntityDelegate.Invoke(entity, operation);

            // Assert
            actual.Should().Be(entity);
        }
    }