Intellitest / Pex tries to create IEqualityComparers for readonly Dictionary private field in object

I created an empty class library project containing only this class.

public class DictionaryDemo
{
    private readonly Dictionary<string, int> dictionary = new Dictionary<string, int>();

    public void Add(string key, int value)
    {
        this.dictionary.Add(key, value);
    }
}

From this class, I generated a test project with Intellitest. Besides making a few formatting changes to the order for publication here, I have not edited this test project. This contains only the following Intellitest test.

[PexClass(typeof(DictionaryDemo)), TestClass]
public partial class DictionaryDemoTest
{
    [PexMethod]
    public void AddTest([PexAssumeUnderTest] DictionaryDemo target, string key, int value)
    {
        target.Add(key, value);
    }
}

When I run the Intellitest method, I get the following results.

enter image description hereenter image description hereenter image description here

In fact, the tests created by themselves seem reasonable. I am not sure if low coverage indicates that more tests need to be created to cover the complexity of the dictionary, or if this is due to problems below.

. , Intellitest . , Intellitest dictionary dictionary. , [PexExplorableFromConstructor(typeof(DictionaryDemo))], ( ) , , , , DictionaryDemo, .

, , , .

, , ? Intellitest? Intellitest dictionary, . , ? , , ?


,

PexCreatable... PexExplorable... , [PexCreatableByConstructor(typeof(DictionaryDemo), MaySetRemainingFieldsByReflection = false)], , , .

factory DictionaryDemo .

[PexExplorableFromConstructor(typeof(Dictionary<string, int>))], .

VS 2015 VS 2017. RC.

+4
1

, , , .

, , , IntelliTest, .

:

public class DefaultEqualityComparer<T> : IEqualityComparer<T>
{
  readonly EqualityComparer<T> _comparer = System.Collections.Generic.EqualityComparer<T>.Default;

  public bool Equals(T x, T y) => _comparer.Equals(x, y);

  public int GetHashCode(T obj) => _comparer.GetHashCode(obj);
}

PexAssemblyInfo.cs :

[assembly: PexUseType(typeof(DefaultEqualityComparer<int>))]

. , , , - , .

0

Source: https://habr.com/ru/post/1667208/


All Articles