public void MethodShouldBeCalledOnceWithParameter()
 {
     int count = 0;
     var actionToken = new ActionToken(o => count++, count);
     actionToken.Dispose();
     count.ShouldEqual(1);
     actionToken.Dispose();
     count.ShouldEqual(1);
 }
 public void MethodShouldBeCalledOnce()
 {
     int count = 0;
     var actionToken = new ActionToken(() => count++);
     actionToken.Dispose();
     count.ShouldEqual(1);
     actionToken.Dispose();
     count.ShouldEqual(1);
 }
        public void CreateMemberGenericObserveTest()
        {
            bool isInvoked = false;
            IDisposable result = null;
            var listenerMock = new EventListenerMock();
            var source = new BindingSourceModel();
            const string path = "path";
            var property = AttachedBindingMember.CreateMember<BindingSourceModel, string>(path, (info, o) => null,
                (info, o, v) => { },
                (info, o, arg3) =>
                {
                    isInvoked = true;
                    info.ShouldNotBeNull();
                    o.ShouldEqual(source);
                    arg3.ShouldEqual(listenerMock);
                    return result;
                });

            property.TryObserve(source, listenerMock).ShouldBeNull();
            isInvoked.ShouldBeTrue();

            isInvoked = false;
            result = new ActionToken(() => { });
            property.TryObserve(source, listenerMock).ShouldEqual(result);
            isInvoked.ShouldBeTrue();
        }