예제 #1
0
        public void findDelegateCreator(ModuleDefinition module)
        {
            var callCounter = new CallCounter();

            foreach (var type in module.Types)
            {
                if (type.Namespace != "" || !DotNetUtils.derivesFromDelegate(type))
                {
                    continue;
                }
                var cctor = DotNetUtils.getMethod(type, ".cctor");
                if (cctor == null)
                {
                    continue;
                }
                foreach (var method in DotNetUtils.getMethodCalls(cctor))
                {
                    callCounter.add(method);
                }
            }

            var mostCalls = callCounter.most();

            if (mostCalls == null)
            {
                return;
            }

            setDelegateCreatorMethod(DotNetUtils.getMethod(module, mostCalls));
        }
        public void FindDelegateCreator(ModuleDefMD module)
        {
            var callCounter = new CallCounter();

            foreach (var type in module.Types)
            {
                if (type.Namespace != "" || !DotNetUtils.DerivesFromDelegate(type))
                {
                    continue;
                }
                var cctor = type.FindStaticConstructor();
                if (cctor == null)
                {
                    continue;
                }
                foreach (var method in DotNetUtils.GetMethodCalls(cctor))
                {
                    callCounter.Add(method);
                }
            }

            var mostCalls = callCounter.Most();

            if (mostCalls == null)
            {
                return;
            }

            SetDelegateCreatorMethod(DotNetUtils.GetMethod(module, mostCalls));
        }
        public ContentStoreInternalTracer(ContentStoreSettings?settings, AbsolutePath rootPath)
            : base($"{FileSystemContentStoreInternal.Component}({rootPath})")
        {
            CallCounters.Add(_createHardLinkCallCounter          = new CallCounter(CreateHardLinkCallName));
            CallCounters.Add(_placeFileCopyCallCounter           = new CallCounter(PlaceFileCopyCallName));
            CallCounters.Add(_reconstructCallCounter             = new CallCounter(ReconstructCallName));
            CallCounters.Add(_evictCallCounter                   = new CallCounter(EvictCallName));
            CallCounters.Add(_purgeCallCounter                   = new CallCounter(PurgeCallName));
            CallCounters.Add(_calibrateCallCounter               = new CallCounter(CalibrateCallName));
            CallCounters.Add(_hashContentFileCallCounter         = new CallCounter(HashContentFileCallName));
            CallCounters.Add(_putFileExistingHardlinkCallCounter = new CallCounter(PutFileExistingHardlinkCallName));
            CallCounters.Add(_putFileNewHardlinkCallCounter      = new CallCounter(PutFileNewHardlinkCallName));
            CallCounters.Add(_putFileNewCopyCallCounter          = new CallCounter(PutFileNewCopyCallName));
            CallCounters.Add(_putContentInternalCallCounter      = new CallCounter(PutContentInternalCallName));
            CallCounters.Add(_applyPermsCallCounter              = new CallCounter(ApplyPermsCallName));

            _counters.Add(_startBytesCount = new Counter(StartByteCountName));
            _counters.Add(_startFilesCount = new Counter(StartFileCountName));
            _counters.Add(_putBytesCount   = new Counter(PutBytesCountName));
            _counters.Add(_putFilesCount   = new Counter(PutFilesCountName));
            _counters.Add(_evictBytesCount = new Counter(EvictBytesCountName));
            _counters.Add(_evictFilesCount = new Counter(EvictFilesCountName));
            _counters.Add(_reconstructCallExceptionCounter = new Counter(ReconstructCallExceptionName));

            _traceDiagnosticEvents          = settings?.TraceFileSystemContentStoreDiagnosticMessages ?? true;
            _longOperationDurationThreshold = settings.GetLongOperationDurationThreshold();
        }
예제 #4
0
        public ContentStoreInternalTracer(bool traceDiagnosticEvents = false)
            : base(FileSystemContentStoreInternal.Component)
        {
            CallCounters.Add(_createHardLinkCallCounter          = new CallCounter(CreateHardLinkCallName));
            CallCounters.Add(_placeFileCopyCallCounter           = new CallCounter(PlaceFileCopyCallName));
            CallCounters.Add(_reconstructCallCounter             = new CallCounter(ReconstructCallName));
            CallCounters.Add(_evictCallCounter                   = new CallCounter(EvictCallName));
            CallCounters.Add(_purgeCallCounter                   = new CallCounter(PurgeCallName));
            CallCounters.Add(_calibrateCallCounter               = new CallCounter(CalibrateCallName));
            CallCounters.Add(_hashContentFileCallCounter         = new CallCounter(HashContentFileCallName));
            CallCounters.Add(_putFileExistingHardlinkCallCounter = new CallCounter(PutFileExistingHardlinkCallName));
            CallCounters.Add(_putFileNewHardlinkCallCounter      = new CallCounter(PutFileNewHardlinkCallName));
            CallCounters.Add(_putFileNewCopyCallCounter          = new CallCounter(PutFileNewCopyCallName));
            CallCounters.Add(_putContentInternalCallCounter      = new CallCounter(PutContentInternalCallName));
            CallCounters.Add(_applyPermsCallCounter              = new CallCounter(ApplyPermsCallName));

            _counters.Add(_startBytesCount = new Counter(StartByteCountName));
            _counters.Add(_startFilesCount = new Counter(StartFileCountName));
            _counters.Add(_putBytesCount   = new Counter(PutBytesCountName));
            _counters.Add(_putFilesCount   = new Counter(PutFilesCountName));
            _counters.Add(_evictBytesCount = new Counter(EvictBytesCountName));
            _counters.Add(_evictFilesCount = new Counter(EvictFilesCountName));
            _counters.Add(_reconstructCallExceptionCounter = new Counter(ReconstructCallExceptionName));

            _traceDiagnosticEvents = traceDiagnosticEvents;
        }
예제 #5
0
		public void find() {
			var additionalTypes = new string[] {
				"System.IntPtr",
//				"System.Reflection.Assembly",		//TODO: Not in unknown DNR version with jitter support
			};
			var checkedMethods = new Dictionary<IMethod, bool>(MethodEqualityComparer.CompareDeclaringTypes);
			var callCounter = new CallCounter();
			int typesLeft = 30;
			foreach (var type in module.GetTypes()) {
				var cctor = type.FindStaticConstructor();
				if (cctor == null || cctor.Body == null)
					continue;
				if (typesLeft-- <= 0)
					break;

				foreach (var method in DotNetUtils.getCalledMethods(module, cctor)) {
					if (!checkedMethods.ContainsKey(method)) {
						checkedMethods[method] = false;
						if (method.DeclaringType.BaseType == null || method.DeclaringType.BaseType.FullName != "System.Object")
							continue;
						if (!DotNetUtils.isMethod(method, "System.Void", "()"))
							continue;
						if (!encryptedResource.couldBeResourceDecrypter(method, additionalTypes))
							continue;
						checkedMethods[method] = true;
					}
					else if (!checkedMethods[method])
						continue;
					callCounter.add(method);
				}
			}

			encryptedResource.Method = (MethodDef)callCounter.most();
		}
예제 #6
0
        public void CallCountAccumulates()
        {
            var counter = new CallCounter("name");
            counter.Completed(0);
            counter.Completed(0);

            counter.Calls.Should().Be(2);
        }
예제 #7
0
 private void IncreaseCallCounter(string method)
 {
     if (!CallCounter.ContainsKey(method))
     {
         CallCounter[method] = 0;
     }
     ++CallCounter[method];
 }
예제 #8
0
 public async Task TestTimerPeriod()
 {
     var counter = new CallCounter();
     using(new Timer(TimerCallback, counter, 100, 100))
     {
         await Task.Delay(350);
     }
     Assert.That(counter.Count, Is.EqualTo(3));
 }
예제 #9
0
        public DistributedContentTracer()
            : base(Component)
        {
            Counters.Add(_remoteBytesCounter           = new Counter(RemoteBytesCopiedCountName));
            Counters.Add(_remoteFilesCopiedCounter     = new Counter(RemoteCopyFileSuccessCountName));
            Counters.Add(_remoteFilesFailedCopyCounter = new Counter(RemoteCopyFileFailCountName));

            CallCounters.Add(_remoteCopyCallCounter = new CallCounter(RemoteCopyFileCallName));
        }
예제 #10
0
        public void CallDurationAccumulates()
        {
            var counter = new CallCounter("name");
            counter.Completed(1);
            counter.Duration.Ticks.Should().Be(1);

            counter.Completed(TimeSpan.FromMilliseconds(1).Ticks);
            counter.Duration.Ticks.Should().Be(TimeSpan.FromMilliseconds(1).Ticks + 1);
            ((long)counter.Duration.TotalMilliseconds).Should().Be(1);
        }
예제 #11
0
 public async Task TestCancelTimer()
 {
     var counter = new CallCounter();
     using(var timer = new Timer(TimerCallback, counter, 100, 100))
     {
         timer.Cancel();
         await Task.Delay(200);
     }
     Assert.That(counter.Count, Is.EqualTo(0));
 }
예제 #12
0
        public async Task TestTimerPeriod()
        {
            var counter = new CallCounter();

            using (new Timer(TimerCallback, counter, 100, 100))
            {
                await Task.Delay(350);
            }
            Assert.That(counter.Count, Is.EqualTo(3));
        }
        public void AsyncMaxAttemptsFitExceptionTest()
        {
            var beforeRetryCount = 0;
            var callActionCount  = new CallCounter();
            var callStrategy     = new MaxAttemptsRetriableAsyncCallStrategy(5, 1);

            Assert.ThrowsAsync <AttemptsExceededException>(() =>
                                                           callStrategy.CallAsync(() => IOExceptionActionAsync(callActionCount), e => e is IOException, () => beforeRetryCount++));
            Assert.That(beforeRetryCount, Is.EqualTo(4));
            Assert.That(callActionCount.Count, Is.EqualTo(5));
        }
        public void MaxAttemptsNotFitExceptionTest()
        {
            var beforeRetryCount = 0;
            var callActionCount  = new CallCounter();
            var callStrategy     = new MaxAttemptsRetriableCallStrategy(5, 1);

            Assert.Throws <IOException>(() =>
                                        callStrategy.Call(() => IOExceptionAction(callActionCount), e => e is StackOverflowException, () => beforeRetryCount++));
            Assert.That(beforeRetryCount, Is.EqualTo(0));
            Assert.That(callActionCount.Count, Is.EqualTo(1));
        }
예제 #15
0
        public async Task TestCancelTimer()
        {
            var counter = new CallCounter();

            using (var timer = new Timer(TimerCallback, counter, 100, 100))
            {
                timer.Cancel();
                await Task.Delay(200);
            }
            Assert.That(counter.Count, Is.EqualTo(0));
        }
예제 #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisContentLocationStoreTracer"/> class.
        /// </summary>
        public RedisContentLocationStoreTracer(string name)
            : base(name)
        {
            Contract.Requires(name != null);

            CallCounters.Add(_updateBulkCallCounter = new CallCounter(UpdateBulkCallName));
            CallCounters.Add(_getBulkCallCounter    = new CallCounter(GetBulkCallName));
            CallCounters.Add(_trimBulkCallCounter   = new CallCounter(TrimBulkCallName));
            CallCounters.Add(_trimOrGetLastAccessTimeCallCounter = new CallCounter(TrimOrGetLastAccessTimeCallName));
            CallCounters.Add(_trimBulkLocalCallCounter           = new CallCounter(TrimBulkLocalCallName));
            CallCounters.Add(_touchBulkCallCounter = new CallCounter(TouchBulkCallName));
        }
예제 #17
0
        public void find()
        {
            var additionalTypes = new string[] {
                "System.IntPtr",
//				"System.Reflection.Assembly",		//TODO: Not in unknown DNR version with jitter support
            };
            var checkedMethods = new Dictionary <MethodReferenceAndDeclaringTypeKey, bool>();
            var callCounter    = new CallCounter();
            int typesLeft      = 30;

            foreach (var type in module.GetTypes())
            {
                var cctor = DotNetUtils.getMethod(type, ".cctor");
                if (cctor == null || cctor.Body == null)
                {
                    continue;
                }
                if (typesLeft-- <= 0)
                {
                    break;
                }

                foreach (var method in DotNetUtils.getCalledMethods(module, cctor))
                {
                    var key = new MethodReferenceAndDeclaringTypeKey(method);
                    if (!checkedMethods.ContainsKey(key))
                    {
                        checkedMethods[key] = false;
                        if (method.DeclaringType.BaseType == null || method.DeclaringType.BaseType.FullName != "System.Object")
                        {
                            continue;
                        }
                        if (!DotNetUtils.isMethod(method, "System.Void", "()"))
                        {
                            continue;
                        }
                        if (!encryptedResource.couldBeResourceDecrypter(method, additionalTypes))
                        {
                            continue;
                        }
                        checkedMethods[key] = true;
                    }
                    else if (!checkedMethods[key])
                    {
                        continue;
                    }
                    callCounter.add(method);
                }
            }

            encryptedResource.Method = (MethodDefinition)callCounter.most();
        }
예제 #18
0
        public ContentSessionTracer(string name)
            : base(name)
        {
            CallCounters.Add(_getStatsCallCounter   = new CallCounter(GetStatsCallName));
            CallCounters.Add(_pinCallCounter        = new CallCounter(PinCallName));
            CallCounters.Add(_pinBulkCallCounter    = new CallCounter(PinBulkCallName));
            CallCounters.Add(_openStreamCallCounter = new CallCounter(OpenStreamCallName));
            CallCounters.Add(_placeFileCallCounter  = new CallCounter(PlaceFileCallName));
            CallCounters.Add(_putStreamCallCounter  = new CallCounter(PutStreamCallName));
            CallCounters.Add(_putFileCallCounter    = new CallCounter(PutFileCallName));

            Counters.Add(_pinBulkFileCountCounter = new Counter(PinBulkFileCountCounterName));
        }
예제 #19
0
        public void Setup()
        {
            this.callCounter = new CallCounter();

            var container = new UnityContainer();

            container.AddNewExtension <Interception>();
            container.AddNewExtension <TransientPolicyBuildUpExtension>();
            container.RegisterInstance <CallCounter>(this.callCounter);
            var serviceLocator = new UnityServiceLocator(container);

            this.policyInjector = new PolicyInjector(serviceLocator);
        }
예제 #20
0
        public async Task CountdownTimer_Start_StartsCountdown()
        {
            // Arrange
            var timer       = CreateCountdownTimer();
            var callCounter = new CallCounter();

            // Act
            timer.Start(50, callCounter.Invoke);
            await Process(callCounter);

            // Assert
            callCounter.Count.Should().Be(1);
        }
예제 #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DistributedCacheSessionTracer" /> class.
        /// </summary>
        public DistributedCacheSessionTracer(ILogger logger, string name)
            : base(name)
        {
            CallCounters.Add(_getSelectorsCallCounter         = new CallCounter(GetSelectorsCallName));
            CallCounters.Add(_addSelectorsCallCounter         = new CallCounter(AddSelectorsCallName));
            CallCounters.Add(_invalidateCacheEntryCallCounter = new CallCounter(InvalidateCacheEntryCallName));
            CallCounters.Add(_getContentHashListCallCounter   = new CallCounter(GetContentHashListCallName));
            CallCounters.Add(_addContentHashListCallCounter   = new CallCounter(AddContentHashListCallName));

            Counters.Add(_getContentHashListFetchedDistributed = new Counter(GetContentHashListFetchedDistributedName));
            Counters.Add(_getContentHashListFetchedBacking     = new Counter(GetContentHashListFetchedBackingName));
            Counters.Add(_getSelectorsFetchedDistributed       = new Counter(GetSelectorsFetchedDistributedName));
            Counters.Add(_getSelectorsFetchedBacking           = new Counter(GetSelectorsFetchedBackingName));
        }
예제 #22
0
        public void AlwaysCallbackTest()
        {
            CallCounter counter = new CallCounter();
            Deferred<None> d = new Deferred<None>();

            d.Always(p =>
                counter.Always++
            );

            d.Resolve();
            d.Reject();

            Assert.AreEqual(2, counter.Always);
        }
예제 #23
0
 private static async Task Process(CallCounter callCounter)
 {
     for (var i = 0; i < 20; i++)
     {
         if (callCounter.Count == 0)
         {
             await Task.Delay(50);
         }
         else
         {
             break;
         }
     }
 }
예제 #24
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="SQLiteMemoizationStoreTracer"/> class.
        /// </summary>
        /// <param name="logger">Logger</param>
        /// <param name="name">Tracer Name</param>
        public SQLiteMemoizationStoreTracer(ILogger logger, string name)
            : base(logger, name)
        {
            Counters.Add(_masterDbCorruptionCount       = new Counter("MasterDbCorruptionCount"));
            Counters.Add(_backupDbCorruptionCount       = new Counter("BackupDbCorruptionCount"));
            Counters.Add(_sqliteMarkerCreatedCount      = new Counter("SQLiteMarkerCreated"));
            Counters.Add(_sqliteMarkerCreateFailedCount = new Counter("SQLiteMarkerCreateFailed"));
            Counters.Add(_sqliteMarkerDeletedCount      = new Counter("SQLiteMarkerDeleted"));
            Counters.Add(_sqliteMarkerDeleteFailedCount = new Counter("SQLiteMarkerDeleteFailed"));
            Counters.Add(_sqliteMarkerLeftBehindCount   = new Counter("SQLiteMarkerLeftBehind"));
            Counters.Add(_sqliteIntegrityCheckSucceeded = new Counter("SQLiteIntegrityCheckSucceeded"));
            Counters.Add(_sqliteIntegrityCheckFailed    = new Counter("SQLiteIntegrityCheckFailed"));

            CallCounters.Add(_sqliteIntegrityCheckCallCounter = new CallCounter(SQLiteIntegrityCheckCallName));

            _sqliteDatabaseSize = -1;
        }
예제 #25
0
        public async Task CountdownTimer_AbortStart_StartsNewCountdown()
        {
            const int millisecondStartDelay = 100;

            // Arrange
            var timer       = CreateCountdownTimer();
            var callCounter = new CallCounter();

            timer.Start(millisecondStartDelay, callCounter.Invoke);

            // Act
            timer.Abort();
            timer.Start(millisecondStartDelay, callCounter.Invoke);
            await Process(callCounter);

            // Assert
            callCounter.Count.Should().Be(1);
        }
예제 #26
0
        void init()
        {
            var callCounter = new CallCounter();
            int count       = 0;

            foreach (var type in module.GetTypes())
            {
                if (count >= 40)
                {
                    break;
                }
                foreach (var method in type.Methods)
                {
                    if (method.Name != ".ctor" && method.Name != ".cctor" && module.EntryPoint != method)
                    {
                        continue;
                    }
                    foreach (var calledMethod in DotNetUtils.getCalledMethods(module, method))
                    {
                        if (!calledMethod.IsStatic || calledMethod.Body == null)
                        {
                            continue;
                        }
                        if (!DotNetUtils.isMethod(calledMethod, "System.Void", "()"))
                        {
                            continue;
                        }
                        if (isEmptyClass(calledMethod))
                        {
                            callCounter.add(calledMethod);
                            count++;
                        }
                    }
                }
            }

            int numCalls;
            var theMethod = (MethodDef)callCounter.most(out numCalls);

            if (numCalls >= 10)
            {
                emptyMethod = theMethod;
            }
        }
예제 #27
0
        public void DeferTest()
        {
            CallCounter counter = new CallCounter();

            Deferred.Defer<None>(d =>
                d.Resolve()
            ).Done(p =>
                counter.Done++
            ).Next<None>(d => {
                counter.Next++;
                d.Resolve();
            }).Next<None>(d => {
                counter.Next++;
                d.Reject();
            });

            Assert.AreEqual(1, counter.Done);
            Assert.AreEqual(2, counter.Next);
        }
예제 #28
0
        public void FailCallbackTest()
        {
            CallCounter counter = new CallCounter();
            Deferred<None> d = new Deferred<None>();

            d.Done(p =>
                counter.Done++
            ).Fail(p =>
                counter.Fail++
            ).Progress(p =>
                counter.Progress++
            );

            d.Reject();

            Assert.AreEqual(0, counter.Done);
            Assert.AreEqual(1, counter.Fail);
            Assert.AreEqual(0, counter.Progress);
        }
예제 #29
0
        public MemoizationStoreTracer(string name)
            : base(name)
        {
            Contract.Requires(name != null);

            CallCounters.Add(_getStatsCallCounter                      = new CallCounter(GetStatsCallName));
            CallCounters.Add(_getSelectorsCallCounter                  = new CallCounter(GetSelectorsCallName));
            CallCounters.Add(_getContentHashListCallCounter            = new CallCounter(GetContentHashListCallName));
            CallCounters.Add(_addOrGetContentHashListCallCounter       = new CallCounter(AddOrGetContentHashListCallName));
            CallCounters.Add(_incorporateStrongFingerprintsCallCounter = new CallCounter(IncorporateStrongFingerprintsCallName));

            Counters.Add(_startContentHashListsCount          = new Counter(StartContentHashListsCountName));
            Counters.Add(_getContentHashListMissCounter       = new Counter(GetContentHashListMissCountName));
            Counters.Add(_getContentHashListHitCounter        = new Counter(GetContentHashListHitCountName));
            Counters.Add(_getContentHashListErrorCounter      = new Counter(GetContentHashListErrorCountName));
            Counters.Add(_addOrGetContentHashListAddCounter   = new Counter(AddOrGetContentHashListAddCountName));
            Counters.Add(_addOrGetContentHashListGetCounter   = new Counter(AddOrGetContentHashListGetCountName));
            Counters.Add(_addOrGetContentHashListErrorCounter = new Counter(AddOrGetContentHashListErrorCountName));
            Counters.Add(_getSelectorsEmptyCounter            = new Counter(GetSelectorsEmptyCountName));
        }
예제 #30
0
        public async Task CountdownTimer_StartTwice_AbortsOldTimer()
        {
            const int millisecondStartDelay = 10;

            // Arrange
            var timer        = CreateCountdownTimer();
            var callCounter1 = new CallCounter();
            var callCounter2 = new CallCounter();

            // Act
            timer.Start(millisecondStartDelay, callCounter1.Invoke);
            timer.Start(millisecondStartDelay, callCounter2.Invoke);
            await Task.Delay(250);

            await Process(callCounter2);

            // Assert
            callCounter2.Count.Should().Be(1);
            callCounter1.Count.Should().Be(0);
        }
예제 #31
0
        public async Task GetCredentialProvidersExecutedOnlyOnce()
        {
            var counter = new CallCounter();
            var service = new CredentialService(new AsyncLazy <IEnumerable <ICredentialProvider> >(() => counter.GetProviders()), nonInteractive: true, handlesDefaultCredentials: true);

            var uri1 = new Uri("http://uri1");

            // Act
            var result1 = await service.GetCredentialsAsync(
                uri1,
                proxy : null,
                type : CredentialRequestType.Unauthorized,
                message : null,
                cancellationToken : CancellationToken.None);

            var result2 = await service.GetCredentialsAsync(
                uri1,
                proxy : null,
                type : CredentialRequestType.Unauthorized,
                message : null,
                cancellationToken : CancellationToken.None);

            Assert.Equal(1, counter.CallCount);
        }
예제 #32
0
        public void GetProgressTest()
        {
            CallCounter counter = new CallCounter();
            Deferred<System.String> d = new Deferred<System.String>();

            d.Progress(p => {
                Assert.AreEqual(0.5f, p.ProgressValue);
                counter.Progress++;
            });

            d.Notify(0.5f);
            Assert.AreEqual(1, counter.Progress);
        }
예제 #33
0
        public void WhenFailTest()
        {
            CallCounter counter = new CallCounter();

            Deferred.When(
                Deferred.Defer<None>(d => { counter.Coroutine++; d.Resolve(); }),
                Deferred.Defer<None>(d => { counter.Coroutine++; d.Resolve(); }),
                Deferred.Defer<None>(d => { counter.Coroutine++; d.Reject(); }),
                Deferred.Defer<None>(d => { counter.Coroutine++; d.Reject(); }),
                Deferred.Defer<None>(d => { counter.Coroutine++; d.Resolve(); })
            ).Fail(p => {
                counter.Fail++;
            });

            Assert.AreEqual(5, counter.Coroutine);
            Assert.AreEqual(1, counter.Fail);
        }
예제 #34
0
 public uint CallCount(string method)
 => CallCounter.TryGetValue(method, out var v) ? v : 0;
예제 #35
0
        public void NextCallBackTest()
        {
            CallCounter counter = new CallCounter();
            Deferred<None> d = new Deferred<None>();

            d.Done(p =>
                counter.Done++
            ).Next<None>(df => {
                Assert.AreEqual(1, counter.Done);
                counter.Next++;
                df.Reject();
            }).Fail(p =>
                counter.Fail++
            ).Next<None>(df =>
                counter.Next++
            );

            d.Resolve();
            Assert.AreEqual(1, counter.Done);
            Assert.AreEqual(1, counter.Fail);
            Assert.AreEqual(1, counter.Next);
        }
예제 #36
0
        public void GetResultTest()
        {
            CallCounter counter = new CallCounter();
            Deferred<System.String> d = new Deferred<System.String>();

            d.Done(p => {
                Assert.AreEqual("UniDeffered", p.GetResult<System.String>());
                counter.Done++;
            });

            d.Resolve("UniDeffered");
            Assert.AreEqual(1, counter.Done);
        }
 private bool IOExceptionAction(CallCounter counter)
 {
     counter.Count++;
     throw new IOException();
 }
 private async Task <bool> IOExceptionActionAsync(CallCounter counter)
 {
     counter.Count++;
     throw new IOException();
 }
예제 #39
0
 public ContentStoreTracer(string name)
     : base(name)
 {
     _callCounters.Add(_removeFromTrackerCallCounter = new CallCounter(_removeFromTrackerName));
 }
예제 #40
0
        public void GetErrorTest()
        {
            CallCounter counter = new CallCounter();
            Deferred<System.String> d = new Deferred<System.String>();

            d.Fail(p => {
                Assert.AreEqual("UniDeffered", p.Error);
                counter.Fail++;
            });

            d.Reject("UniDeffered");
            Assert.AreEqual(1, counter.Fail);
        }