chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
Hi
This is a demo of problem that I have with faking ObservableCollection.
I've tried couple of way without sucess.

The production code:
public interface Parent
    {
        InternalProperty MainNternalProperty { get; set; }
    }

 public interface InternalProperty
    {
        ObservableCollection<Parent> Derives { get; }
    }

 public class Derived : Parent
    {
        private InternalProperty _mainNternalProperty;

        public InternalProperty MainNternalProperty
        {
            get { return _mainNternalProperty; }
            set
            {
                _mainNternalProperty = value;
                value.Derives.Add(this);

            }
        }
    }

I want to be sure that the Add method was called. so the test is: 
  [TestClass]
    public class ObservTests
    {
        private Derived _derived;

        [TestMethod]
        public void ObservTest()
        {
            // Arrange
            _derived = Isolate.Fake.Instance<Derived>(Members.CallOriginal);

            InternalProperty nternalProperty = Isolate.Fake.Instance<InternalProperty>();
            Isolate.WhenCalled(() => nternalProperty.Derives).WillReturn(Isolate.Fake.Instance<ObservableCollection<Parent>>());

            // Act
            _derived.MainNternalProperty = nternalProperty;

            // Assert
            Isolate.WhenCalled(() => nternalProperty.Derives.Add(_derived));

        }
    }



this is the minimal code I can give that can reproduce the problem...
Thanks
asked by adiel.sharabi (3.4k points)

7 Answers

0 votes
Hi Adiel,

It looks we have a bug when faking ObservableCollection :evil:
We'll let you know once it is fixed.
answered by ohad (35.4k points)
0 votes
Hi
thanks for that.
BTW the notification doesn't seems to work...
Adiel
answered by adiel.sharabi (3.4k points)
0 votes
Hi
thanks for that.
BTW the notification doesn't seems to work...
Adiel
answered by adiel.sharabi (3.4k points)
0 votes
Anything new?
Thanks
answered by adiel.sharabi (3.4k points)
0 votes
Hi Adiel,

Sorry not yet,
The source of the problem is that ObservableCollection inherits from Collection which is defined in mscorlib so calls on ObservableCollection result calling methods on mscorlib which is not supported fully by the Isolator.
answered by ohad (35.4k points)
0 votes
Changes?
It's useful collection...
answered by adiel.sharabi (3.4k points)
0 votes
Sorry there's no change in this issue :(
answered by ohad (35.4k points)
...