Switch Instruction

Switch Instruction

I have a public method that i test, and my ncover not entry inside the switch instruction and I be sure that my exec pass over there.

Why? I dont know how i can test that instruction.

Thanks


RE: Switch Instruction

We'll need to see your switch statement and the tests that are testing it to be able to tell you why it's not being covered. Feel free to post them here or mail them to support@ncover.com if they're confidential.


RE: Switch Instruction

This is the method that i´m testing.

public void ObtenerTipoTrLiquidacion2(string cuentaVoucher, string cuentaVoucherVehiculo, string mercadoVoucher, bool marcaBatch, string tipoVoucher, FormaPasivas metodoEnvioPasivas) { IExtendedCuentaFx cuenta;

        if (!string.IsNullOrEmpty(cuentaVoucher))
            cuenta = FXSession.Current.Server.GetOneCuentaFx(cuentaVoucher);
        else
            cuenta = FXSession.Current.Server.GetOneCuentaFx(cuentaVoucherVehiculo);


        this.TipoLiquidacion = TrTipoLiquidacion.INDETERMINADO;
        this.SistemaOrigen = "0";
        this.SucursalDestino = "0";

        string sucursal = "0";
        if (!string.IsNullOrEmpty(cuenta.Numero) && cuenta.Numero.Length >= 4)
            sucursal = cuenta.Numero.Substring(1, 3);


        if (cuenta.Tipo == TipoCuenta.MIN)
        {

//Here is the point where comes the ncover. //And i´m sure that may test pass over here switch (cuenta.CuentaInterna) { case TipoCuentaInterna.CC: { if (cuenta.CentroDeCostos == iciCambios) { this.TipoLiquidacion = TrTipoLiquidacion.LIQ_INTERNA; this.SucursalOrigen = iciCambios; this.SucursalDestino = iciCambios; } else { this.TipoLiquidacion = TrTipoLiquidacion.LIQ_INTERNA_CAMBIOS;

                            if (tipoVoucher == TiposTransaccion.DEPFX.ToString())
                            {
                                this.SucursalOrigen = cuenta.CentroDeCostos;
                                this.SucursalDestino = iciCambios;
                            }
                            else
                            {
                                this.SucursalDestino = cuenta.CentroDeCostos;
                                this.SucursalOrigen = iciCambios;
                            }
                        }
                    }
                    break;
                case TipoCuentaInterna.FP:
                    {
                        this.TipoLiquidacion = TrTipoLiquidacion.LIQ_FDOS_PROPIOS_SUC;
                        if (tipoVoucher == TiposTransaccion.DEPFX.ToString())
                        {
                            this.SucursalOrigen = sucursal;
                            this.SucursalDestino = iciCambios;
                        }
                        else
                        {
                            this.SucursalDestino = sucursal;
                            this.SucursalOrigen = iciCambios;
                        }
                    }
                    break;
                case TipoCuentaInterna.FT:
                    {
                        this.TipoLiquidacion = TrTipoLiquidacion.LIQ_TRANS_FDOS_3_SUC;
                        if (tipoVoucher == TiposTransaccion.DEPFX.ToString())
                        {
                            this.SucursalOrigen = sucursal;
                            this.SucursalDestino = iciCambios;
                        }
                        else
                        {
                            this.SucursalDestino = sucursal;
                            this.SucursalOrigen = iciCambios;
                        }
                    }                        
            }
            return;
        } 

This is the test Method

[Test] public void LiquidacionCuentaInterna() { TrLiquidacionFx liquid = (TrLiquidacionFx)FXSession.Current.Server.GetNewTrLiquidacion();

        ExtendedCuentaFx cuenta = CommonTest.GetCuenta("CONTAINTER");
        liquid.ObtenerTipoTrLiquidacion2("CONTAINTER", "CONTACORRE", "BCRA", true, "DEPFX", Fx.Interfaces.FormaPasivas.NA);

        Assert.IsTrue(liquid.SucursalDestino == "282");
        Assert.IsTrue(liquid.SucursalOrigen == "282");
        Assert.IsTrue(liquid.TipoLiquidacion == Fx.Interfaces.TrTipoLiquidacion.LIQ_INTERNA);
    }

I have to reduce the code because exceed the limit.


RE: Switch Instruction

Yesterday i download the VS 2010, and today i download the test driven for this whit the addin (ncover), and i test the method and ncover pass over the switch instruction. Thank you for the worry.

Regards, Agustin.


RE: Switch Instruction

I'm glad to hear things are working for you. Please don't hesitate to let us know if there's anything else we can help with.