public void CanGetDistributorByCode() { string code = "9945554"; // There are two options: // 1. Assume the Distributor should exists // 2. Create the necessary data before (this may lead to inconsistent results) // Is better to use directly the Development Database because of table creation and DB integration issues. Distributor d = repository.GetByCode(code); Assert.IsNotNull(d, string.Format("Distributor was not found by code {0}", code)); Assert.AreEqual(d.Code, code); }
public void CanGetByCode() { MockRepository mock = new MockRepository(); IDistributorRepository mockedRepos = mock.CreateMock <IDistributorRepository>(); Distributor expDistributor = new Distributor(); expDistributor.Address = "pepe street."; expDistributor.Code = "1234"; expDistributor.Discount = 15; expDistributor.Email = "*****@*****.**"; expDistributor.Name = "testing Distributor"; Expect.Call(mockedRepos.GetByCode("1234")).Return(expDistributor); mock.ReplayAll(); DistributorController dc = new DistributorController(mockedRepos); Distributor d = dc.GetByCode("1234"); Assert.IsNotNull(d); }
public Distributor GetByCode(string code) { return(repository.GetByCode(code)); }