Пример #1
0
        public void CanActivateDeactivateContact()
        {
            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.GetById(5)).Return(expDistributor);

            Expect.Call(mockedRepos.GetById(5)).Return(expDistributor).Repeat.AtLeastOnce();
            Expect.Call(mockedRepos.Save(expDistributor)).Return(expDistributor);
            mock.ReplayAll();
            DistributorController dc = new DistributorController(mockedRepos);
            Distributor           d  = dc.GetById(5);

            dc.AddContact(5, "Gali", "Emi", "*****@*****.**");

            Contact test = dc.ChangeStatus(5, 0);

            Assert.AreEqual(test.Status, ContactStatus.Disable);

            test = dc.ChangeStatus(5, 0);

            Assert.AreEqual(test.Status, ContactStatus.Active);
        }
Пример #2
0
        public void FullTestCreation()
        {
            MockRepository         mock        = new MockRepository();
            IDistributorRepository mockedRepos = mock.CreateMock <IDistributorRepository>();

            Distributor expDistributor = new Distributor();

            expDistributor.AddContact("Sebastian", "Real", "*****@*****.**");
            expDistributor.AddContact("Emiliano", "Galizio", "*****@*****.**");
            expDistributor.AddContact("Santiago", "Lanus", "*****@*****.**");

            Expect.Call(mockedRepos.GetById(123321)).Return(expDistributor);
            mock.ReplayAll();
            DistributorController dc = new DistributorController(mockedRepos);

            Distributor distributor = dc.GetById(123321);

            Quote q = new Quote();

            foreach (Contact contact in distributor.Contacts)
            {
                q.AddNotification(contact, string.Empty, string.Empty);
            }
            q.AddNotification(null, "Alejandro Bezares", "*****@*****.**");

            Assert.AreEqual(4, q.QuoteNotifications.Count);
        }
        public ActionResult Action(tblDistributor objSubmit)
        {
            if (objSubmit.ID == 0)
            {
                objSubmit.DateCreated = DateTime.Now;
                objSubmit.DateUpdated = DateTime.Now;
                objSubmit.IsDeleted   = false;
                objSubmit.IsShow      = true;
                distributorRepository.Add(objSubmit);
            }
            else
            {
                var obj = distributorRepository.GetById <tblDistributor>(objSubmit.ID);

                UpdateModel(obj);

                objSubmit.DateUpdated = DateTime.Now;

                distributorRepository.Update(obj);
            }

            return(Json(new
            {
                Error = false
            }, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        public void CanEditContact()
        {
            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";
            Contact expC = new Contact("Gali", "Emi", "*****@*****.**");

            expC.Distributor = expDistributor;
            expDistributor.Contacts.Add(expC);

            Contact contact = new Contact("Emi Cambiado", "Gali cambiado", "*****@*****.**");

            contact.Distributor = expDistributor;

            Expect.Call(mockedRepos.GetById(5)).Return(expDistributor).Repeat.AtLeastOnce();
            Expect.Call(mockedRepos.SaveContact(expC)).Return(contact);
            mockedRepos.CommitChange();
            LastCall.On(mockedRepos);
            mock.ReplayAll();
            DistributorController dc = new DistributorController(mockedRepos);

            Contact c = dc.EditContact(5, 0, "Emi Cambiado", "Gali cambiado", "*****@*****.**");

            Assert.AreNotEqual("Emi", c.Name);
            Assert.AreEqual("Gali cambiado", c.LastName);
            Assert.AreNotEqual("*****@*****.**", c.Email);
        }
Пример #5
0
        public void CanGetActives()
        {
            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";
            Contact expC  = new Contact("Gali", "Emi", "*****@*****.**");
            Contact expC2 = new Contact("Gali2", "Emi2", "*****@*****.**");

            expC2.Deactivate();
            expC.Distributor = expDistributor;
            expDistributor.Contacts.Add(expC);
            expDistributor.Contacts.Add(expC2);

            Expect.Call(mockedRepos.GetById(666)).Return(expDistributor);
            mock.ReplayAll();

            DistributorController dc = new DistributorController(mockedRepos);

            IList <Contact> lst = dc.GetById(666).GetActiveContacs();

            Assert.AreEqual(lst.Count, 1);
        }
Пример #6
0
        public async Task <Distributor> Get(int id)
        {
            var distributor = await _repository.GetById(id);

            if (distributor == null)
            {
                throw new NotFoundException("Distributor não encontrado", id);
            }

            return(distributor);
        }
Пример #7
0
        public Distributor Update(int id, string description, string contact, PriceList pl, Country c, decimal discount,
                                  Lookup paymentTerm, Lookup saleCondition, Lookup type, string alternativeEmail)
        {
            Distributor d = repository.GetById(id);

            return(Update(d, d.Name, description, d.Telephone, d.Email, contact, pl, d.Code, c, discount, paymentTerm, saleCondition, type, alternativeEmail));
        }
Пример #8
0
        public void ActivateDeactivate()
        {
            MockRepository         mock       = new MockRepository();
            IDistributorRepository repository = mock.CreateMock <IDistributorRepository>();
            Distributor            d          = new Distributor();

            d.DistributorStatus = DistributorStatus.Active;
            Expect.Call(repository.GetById(1)).Return(d);
            mock.ReplayAll();
            DistributorController distributorController = new DistributorController(repository);

            distributorController.ActivateDeactivate(1);
            Assert.AreEqual(DistributorStatus.Disable, d.DistributorStatus);
        }
Пример #9
0
        public void CanCreate()
        {
            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.GetById(123321)).Return(expDistributor);
            mock.ReplayAll();

            DistributorController dc = new DistributorController(mockedRepos);

            Distributor distributor = dc.GetById(123321);

            Assert.AreEqual(distributor.Code, "1234");
        }
Пример #10
0
        public void CanAddContactToDistributor()
        {
            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.GetById(666)).Return(expDistributor).Repeat.AtLeastOnce();
            Expect.Call(mockedRepos.Save(expDistributor)).Return(expDistributor);
            mock.ReplayAll();

            DistributorController dc = new DistributorController(mockedRepos);
            Contact     c            = dc.AddContact(666, "emi", "emi", "emi@mail");
            Distributor d            = dc.GetById(666);

            Assert.AreEqual(d.Contacts.Count, 1);
        }
Пример #11
0
        public Distributor GetDistributor(int userId)
        {
            Distributor distributor = distributorRepository.GetById((userId)) as Distributor;

            return(distributor);
        }
Пример #12
0
 public Distributor GetDistributors(int id)
 {
     return(_distributorRepository.GetById(id));
 }