[TestCase(false)] // passing binding model public void Add_WhenCalled_ReturnsViewModelOfAddedCustomer(bool bindingModelIsNull) { //Arrange _unitOfWork.Setup(x => x.RepositoryFor <Entities.Customer>().Insert(It.IsAny <Entities.Customer>())).Returns <Entities.Customer>(x => x); //Act ViewModels.Customer func() => _customersManager.Add(bindingModelIsNull ? null : new BindingModels.Customer() { CustomerId = "GREAL", CompanyName = "Great Lakes Food Market", ContactName = "Howard Snyder", ContactTile = "Marketing Manager", Phone = "(503) 555-7555", Address = "2732 Baker Blvd.", PostalCode = "97403", Country = "USA" }); //Assert if (bindingModelIsNull) { Assert.That(() => func(), Throws.TypeOf <ArgumentNullException>()); } else { Assert.IsNotNull(func()); } }
public IHttpActionResult Post([FromBody] BindingModels.Customer customerBindingModel) { var result = _customersManager.Add(customerBindingModel); return(Ok(result)); }
public void Add(Customer customer) { _logger.LogInformation("call Add method"); _customersManager.Add(customer); }