Ejemplo n.º 1
0
        public void Dispose_OneInstance()
        {
            var tagger     = _factory.Create <IClassifier>();
            var disposable = tagger.As <IDisposable>();
            var result     = new CountedClassifier(_propertyCollection, _key, () => tagger.Object);

            disposable.Setup(x => x.Dispose()).Verifiable();
            result.Dispose();
            disposable.Verify();
        }
Ejemplo n.º 2
0
        public void Dispose_ManyInstance()
        {
            var tagger              = _factory.Create <IClassifier>();
            var disposable          = tagger.As <IDisposable>();
            Func <IClassifier> func = () => tagger.Object;
            var result1             = new CountedClassifier(_propertyCollection, _key, func.ToFSharpFunc());
            var result2             = new CountedClassifier(_propertyCollection, _key, func.ToFSharpFunc());

            result1.Dispose();
            disposable.Setup(x => x.Dispose()).Verifiable();
            result2.Dispose();
            disposable.Verify();
        }
Ejemplo n.º 3
0
        public void Create_DoCreate()
        {
            var didRun = false;
            var result = new CountedClassifier(
                _propertyCollection,
                _key,
                () =>
            {
                didRun = true;
                return(_factory.Create <IClassifier>().Object);
            });

            Assert.True(didRun);
        }
Ejemplo n.º 4
0
        public void Create_GetFromCache()
        {
            var runCount            = 0;
            Func <IClassifier> func =
                () =>
            {
                runCount++;
                return(_factory.Create <IClassifier>().Object);
            };
            var result1 = new CountedClassifier(_propertyCollection, _key, func);
            var result2 = new CountedClassifier(_propertyCollection, _key, func);

            Assert.Equal(1, runCount);
            Assert.Same(result1.Classifier, result2.Classifier);
        }