public void CanAddClientOrder_NullClientOrder_ThrowsException() { // Arrange ClientOrderValidator clientOrderValidator = new ClientOrderValidator(); ClientOrder clientOrder = null; // Act // Assert Assert.ThrowsException <ArgumentNullException>(() => clientOrderValidator.CanAddClientOrder(clientOrder)); }
public void CanAddClientOrder_ClientOrderHasNoOrders_ReturnErrorMessage() { // Arrange ClientOrderValidator clientOrderValidator = new ClientOrderValidator(); ClientOrder clientOrder = new ClientOrder(); clientOrder.ClientId = "GUIDGUID"; clientOrder.DeliveryId = 123; clientOrder.Orders = new List <Order>(); // Act List <KeyValuePair <string, string> > result = clientOrderValidator.CanAddClientOrder(clientOrder); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.Count); Assert.AreEqual("ProductId", result[0].Key); }
public void CanAddClientOrder_ClientOrderHasEmptyClientId_ReturnErrorMessage() { // Arrange ClientOrderValidator clientOrderValidator = new ClientOrderValidator(); ClientOrder clientOrder = new ClientOrder(); clientOrder.DeliveryId = 123; clientOrder.Orders = new List <Order>(); clientOrder.Orders.Add(new Order() { ProductId = 11, Quantity = 123 }); clientOrder.Orders.Add(new Order() { ProductId = 22, Quantity = 321 }); // Act List <KeyValuePair <string, string> > result = clientOrderValidator.CanAddClientOrder(clientOrder); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.Count); Assert.AreEqual("ClientId", result[0].Key); }