コード例 #1
0
    public void ProcessInstance_Returns_False_On_Poco()
    {
        // Arrange
        var sut          = new BuilderObjectHandler();
        var instance     = new MyPocoClass();
        var command      = new ObjectHandlerRequest(instance, typeof(MyPocoClass), 0, typeof(MyPocoClass), false);
        var callbackMock = new Mock <ICsharpExpressionDumperCallback>();

        // Act
        var actual = sut.ProcessInstance(command, callbackMock.Object);

        // Assert
        actual.Should().BeFalse();
    }
コード例 #2
0
    public void Can_Generate_Code_With_CustomObjectHandler()
    {
        // Arrange
        var sut          = new BuilderObjectHandler();
        var instance     = new MyBuilder().WithName("Test").AddValues("1", "2", "3");
        var command      = new ObjectHandlerRequest(instance, typeof(MyBuilder), 0, typeof(MyBuilder), false);
        var callbackMock = new Mock <ICsharpExpressionDumperCallback>();

        callbackMock.Setup(x => x.IsPropertyValid(It.IsAny <ObjectHandlerRequest>(), It.IsAny <PropertyInfo>())).Returns(true);

        // Act
        var actual = sut.ProcessInstance(command, callbackMock.Object);

        // Assert
        actual.Should().BeTrue();
    }
コード例 #3
0
    public void ProcessInstance_Returns_False_On_Null_Type()
    {
        // Arrange
        var    sut          = new BuilderObjectHandler();
        object?instance     = null;
        var    command      = new ObjectHandlerRequest(instance, null, 0, null, false);
        var    callbackMock = new Mock <ICsharpExpressionDumperCallback>();

        callbackMock.Setup(x => x.IsPropertyValid(It.IsAny <ObjectHandlerRequest>(), It.IsAny <PropertyInfo>())).Returns(true);

        // Act
        var actual = sut.ProcessInstance(command, callbackMock.Object);

        // Assert
        actual.Should().BeFalse();
    }