コード例 #1
0
		public void GetCustomerWinAtUnusualRate_WhenRepositoryDataIsNull_ReturnNull()
		{
			// Arrange
			var stubUnsettledRepository = MockRepository.GenerateStub<IUnsettledRepository>();
			stubUnsettledRepository.Stub(x => x.GetData("")).IgnoreArguments().Return(null);

			// Act
			var sut = new UnsettledBetService(stubUnsettledRepository, null);
			var result = sut.GetCustomerWinAtUnusualRate();

			// Assert
			Assert.IsNull(result);
		}
コード例 #2
0
		public void GetCustomerBets_WhenRepositoryDataIsNotNull_ReturnList()
		{
			// Arrange
			var stubData = new List<IUnsettledBet>
			{
				new UnsettledBet()
			};
			var stubUnsettledRepository = MockRepository.GenerateStub<IUnsettledRepository>();
			stubUnsettledRepository.Stub(x => x.GetData("")).IgnoreArguments().Return(stubData);

			// Act
			var sut = new UnsettledBetService(stubUnsettledRepository, null);
			var result = sut.GetCustomerBets();

			//Assert
			Assert.IsNotNull(result);
		}
コード例 #3
0
		public void GetCustomerWinAtUnusualRate_WhenOneCustomerWinsAtUnusualRate_ReturnCustomerId3()
		{
			// Arrange
			var stubData = new List<IUnsettledBet>
			{
				new UnsettledBet { CustomerId = 1, Stake = 5m, ToWin = 7m},
				new UnsettledBet { CustomerId = 2, Stake = 5m, ToWin = 50m},
				new UnsettledBet { CustomerId = 3, Stake = 5m, ToWin = 100m}
			};

			var stubUnsettledRepository = MockRepository.GenerateStub<IUnsettledRepository>();
			stubUnsettledRepository.Stub(x => x.GetData("")).IgnoreArguments().Return(stubData);

			// Act
			var sut = new UnsettledBetService(stubUnsettledRepository, null);
			var result = sut.GetCustomerWinAtUnusualRate();

			// Assert
			Assert.AreEqual(3, result.Where(x => x.CustomerId == 3).Select(x => x.CustomerId).First());
		}
コード例 #4
0
		public void GetCustomerWinAtUnusualRate_WhenTwoCustomersWinsAtUnusualRate_ReturnCustomer2and3()
		{
			// Arrange
			var stubData = new List<IUnsettledBet>
			{
				new UnsettledBet { CustomerId = 1, Stake = 5m, ToWin = 20m},
				new UnsettledBet { CustomerId = 2, Stake = 5m, ToWin = 50m},
				new UnsettledBet { CustomerId = 3, Stake = 5m, ToWin = 100m}
			};

			var stubUnsettledRepository = MockRepository.GenerateStub<IUnsettledRepository>();
			stubUnsettledRepository.Stub(x => x.GetData("")).IgnoreArguments().Return(stubData);

			// Act
			var sut = new UnsettledBetService(stubUnsettledRepository, null);
			var result = sut.GetCustomerWinAtUnusualRate().ToList();

			// Assert
			var expected = new[] { 2, 3 };
			var actual = result.Where(x => x.CustomerId == 2 || x.CustomerId == 3).Select(i => i.CustomerId).Distinct().ToArray();

			CollectionAssert.AreEqual(expected, actual);
		}
コード例 #5
0
		public void GetToWinAmountGreaterThan1000_WhenToWinAmountIsLessThan1000_ReturnNoCustomers()
		{
			// Arrange
			var stubUnsettledData = new List<IUnsettledBet>
			{
				new UnsettledBet { CustomerId = 1, Stake = 5m, ToWin = 999.99m},
				new UnsettledBet { CustomerId = 2, Stake = 100m, ToWin = 0},
				new UnsettledBet { CustomerId = 3, Stake = 301m, ToWin = 59.5m}
			};

			var stubUnsettledRepository = MockRepository.GenerateStub<IUnsettledRepository>();
			stubUnsettledRepository.Stub(x => x.GetData("")).IgnoreArguments().Return(stubUnsettledData);

			// Act
			var sut = new UnsettledBetService(stubUnsettledRepository, null);
			var result = sut.GetToWinAmountGreaterThan1000();

			// Assert
			Assert.AreEqual(0, result.Count());
		}
コード例 #6
0
		public void GetToWinAmountGreaterThan1000_WhenRepositoryDataIsNull_ReturnNull()
		{
			// Arrange
			var stubUnsettledRepository = MockRepository.GenerateStub<IUnsettledRepository>();
			stubUnsettledRepository.Stub(x => x.GetData("")).IgnoreArguments().Return(null);

			// Act
			var sut = new UnsettledBetService(stubUnsettledRepository, null);
			var result = sut.GetToWinAmountGreaterThan1000();

			// Assert
			Assert.IsNull(result);
		}
コード例 #7
0
		public void GetStakeIs30TimesHigherThanAverage_WhenCustomerStakeIs30Times_ReturnOneCustomer()
		{
			// Arrange
			var stubUnsettledData = new List<IUnsettledBet>
			{
				new UnsettledBet { CustomerId = 1, Stake = 5m, ToWin = 7m},
				new UnsettledBet { CustomerId = 2, Stake = 100m, ToWin = 200m},
				new UnsettledBet { CustomerId = 3, Stake = 301m, ToWin = 500m}
			};

			var stubSettledData = new List<ISettledBet>
			{
				new SettledBet {CustomerId = 1, Stake = 5},
				new SettledBet {CustomerId = 2, Stake = 10},
				new SettledBet {CustomerId = 3, Stake = 15},
			};

			var stubUnsettledRepository = MockRepository.GenerateStub<IUnsettledRepository>();
			stubUnsettledRepository.Stub(x => x.GetData("")).IgnoreArguments().Return(stubUnsettledData);

			var stubSettledRepository = MockRepository.GenerateStub<ISettledRepository>();
			stubSettledRepository.Stub(x => x.GetData("")).IgnoreArguments().Return(stubSettledData);

			// Act
			var sut = new UnsettledBetService(stubUnsettledRepository, stubSettledRepository);
			var result = sut.GetStakeIs30TimesHigherThanAverage();

			// Assert
			Assert.AreEqual(1, result.Count());
		}