Beispiel #1
0
		public void Dispose()
		{
			// Reset
			var dbContext = new UserStoreContext();
			var sql = string.Format("TRUNCATE TABLE {0}", EF.GetTableName(typeof(SteamUserInfo), dbContext));
			dbContext.Database.ExecuteSqlCommand(sql);
		}
Beispiel #2
0
		public async Task CircuitBreakerTrip()
		{
			var service = new SteamUserService();

			await service.Trip(key);

			var dbContext = new UserStoreContext();
			var user = dbContext.Users.Find(key);

			Assert.Equal(CircuitBreakerState.Triped, user.State);
		}
Beispiel #3
0
		public OpenTest()
		{
			var dbContext = new UserStoreContext();

			// Reset
			var sql = string.Format("TRUNCATE TABLE {0}", EF.GetTableName(typeof(SteamUserInfo), dbContext));
			dbContext.Database.ExecuteSqlCommand(sql);

			// Setup
			dbContext.Users.Add(new SteamUserInfo() { Id = key, FailureCount = 0, State = CircuitBreakerState.Closed });
			dbContext.SaveChanges();
		}
Beispiel #4
0
		public async Task CircuitBreakerOpen()
		{
			var service = new SteamUserService();

			for (int i = 0; i < service.Threshold; i++)
			{
				await service.Trip(key);
			}

			var dbContext = new UserStoreContext();
			var user = dbContext.Users.Find(key);

			Assert.Equal(CircuitBreakerState.Open, user.State);
		}