Exemplo n.º 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);
        }
        public void CanChangeContactStatus()
        {
            DistributorRepository dRepos = new DistributorRepository(Config.GrundfosFactoryConfigPath);

            DistributorController dc = new DistributorController(dRepos);

            Contact       c          = dc.FindContactInDistributor(2, 3);
            ContactStatus previousCs = c.Status;

            c = dc.ChangeStatus(2, 3);

            Assert.AreNotEqual(c.Status, previousCs);
        }