Bonjour.
Je souhaiterais tester une methode privée. Au dela du débat pour ou contre le test de methode privée, est-ce que vous pourriez m'aider?

J'ai actuellement le code ci dessous:


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
 
public class Asset
    {
        /// <summary>
        /// Calculates the PnLs for the different scenarios given as historical data
        /// </summary>
        /// <returns>An array with the different PnLs for the scenarios</returns>
        public double[] ScenarioPnL()
        {
            double[] _scenarios = this.GenerateScenarios();
            double[] _scenarioPnL = new double[_scenarios.Length];
 
            for (int _i = 0; _i < _scenarioPnL.Length; _i++)
            {
                _scenarioPnL[_i] =  this.CurrentValue;
            }
            return _scenarioPnL;
        }
 
        private double[] GenerateScenarios()
        {
            if (!this.CheckInput())
            {
                return null;
            }
 
            //1 less scenario than there are historical values
            double[] _scenarios = new double[this.HistoricalValues.Length - 1];
 
            for (int _index = 0; _index < _scenarios.Length; _index++)
            {
                _scenarios[_index] =
                        this.CurrentValue *
                        (this.HistoricalValues[_index + 1] / this.HistoricalValues[_index]);
            }
            return _scenarios;
        }
 
        // checks the validity of input
        private bool CheckInput()
        {
            if (this.Name == null)
            {
                throw new ArgumentException("Name of the asset is null or invalid ");
            }
 
            if (Double.IsNaN(this.CurrentValue))
            {
                throw new ArgumentException("Current value is invalid ");
            }
 
            foreach (double _historicalValue in this.HistoricalValues)
            {
                if (Double.IsNaN(_historicalValue))
                {
                    throw new ArgumentException(" The historical value: "
                                                + _historicalValue + " is invalid in HistoricalValues");
                }
            }
            return true;
        }
 
        //public Asset(string name, double currentValue,double w, double[] hist)
        //{
        //    Name = name;
        //    CurrentValue = currentValue;
        //    Weight = w;
        //    HistoricalValues = hist;
        //}
 
        /// <summary>
        /// Gets or sets Name of the asse
        /// </summary>
        public string Name { get; set; }
 
        /// <summary>
        /// Gets or sets Current value of the asset
        /// </summary>
        public double CurrentValue { get; set; }
 
        /// <summary>
        /// Gets or sets This is the weight of the asset in the portfolio
        /// </summary>
        public double Weight { get; set; }
 
        /// <summary>
        /// Gets or sets Historical value of the asset
        /// </summary>
        public double[] HistoricalValues { get; set; }
.

Je souhaite tester les methodes "CheckInput" et "GenerateScenarios". En generant les tests avec VS, un Accessor est créé "Asset_Accessor"... Mais je ne peux pas appeler les methodes privées sur lui...

Une idée de ce que je fais de mal?