Beispiel #1
0
		public void ShouldExtendWithSimpleMatchers()
		{
			var order = new Order();
			var mock = new Mock<IOrderRepository>();

			Order repo = Match.Create<Order>(r => true);

			mock.Setup(x => x.Save(Orders.Contains(order)))
				 .Throws<ArgumentException>();

			Assert.Throws<ArgumentException>(() => mock.Object.Save(new[] { order }));
		}
Beispiel #2
0
		public void FillingDoesNotRemoveIfNotEnoughInStock()
		{
			//setup - data
			var order = new Order(TALISKER, 50);
			var mock = Mock.Create<IWarehouse>();

			//setup - expectations
			mock.Setup(x => x.HasInventory(It.IsAny<string>(), It.IsInRange(0, 100, Range.Inclusive))).Returns(false);
			mock.Setup(x => x.Remove(It.IsAny<string>(), It.IsAny<int>())).Throws(new InvalidOperationException());

			//exercise
			order.Fill(mock.Object);

			//verify
			Assert.IsFalse(order.IsFilled);
		}
Beispiel #3
0
		public void FillingRemovesInventoryIfInStock()
		{
			//setup - data
			var order = new Order(TALISKER, 50);
			var mock = Mock.Create<IWarehouse>();

			//setup - expectations
			mock.Setup(x => x.HasInventory(TALISKER, 50)).Returns(true);

			//exercise
			order.Fill(mock.Object);

			//verify state
			Assert.IsTrue(order.IsFilled);
			//verify interaction
			mock.VerifyAll();
		}
Beispiel #4
0
			private void DoOrderSelection(Order selectedOrder)
			{
				// Do something when the view selects an order.
				SelectedOrder = selectedOrder;
			}
Beispiel #5
0
		public static IEnumerable<Order> Contains(Order order)
		{
			return Match.Create<IEnumerable<Order>>(orders => orders.Contains(order));
		}
Beispiel #6
0
 public static Order IsLargerThanRE(decimal threshold)
 {
     return(Match.Create <Order>(order => order.MetricTons < threshold, () => Order.IsLargerThanRE(threshold)));
 }
Beispiel #7
0
 public static Order IsLargeRE()
 {
     return(Match.Create <Order>(order => order.MetricTons >= 1000M, () => Order.IsLargeRE()));
 }
Beispiel #8
0
 public static Order IsSmallRE()
 {
     return(Match.Create <Order>(order => order.MetricTons < 1000M, () => Order.IsSmallRE()));
 }