Beispiel #1
0
        public ActionResult UpdateAddress(CompanyAddress oldAddress, CompanyAddress newAddress, int userId)
        {
            var    res       = ActionResult.NoAction;
            string extradata = CompanyAddress.Differences(oldAddress, newAddress);

            if (!string.IsNullOrEmpty(extradata))
            {
                res = newAddress.Update(userId);
                if (res.Success)
                {
                    res = ActivityLog.Company(newAddress.Company.Id, userId, newAddress.Company.Id, CompanyLogActions.Update, extradata);
                }
            }
            else
            {
                res.SetSuccess();
            }

            if (res.Success)
            {
                var companySession = new Company(newAddress.Company.Id);
                HttpContext.Current.Session["Company"] = companySession;
            }

            return(res);
        }
Beispiel #2
0
        public void ThrowsExceptionDuringUpdate(string country, string state, string town,
                                                string street, int buildingNumber, int flatNumber, string zipCode)
        {
            //Arrange
            var companyMock = Mock.Of <Company>(x => x.Id == 1);
            var sut         = new CompanyAddress("Test Country", "Test State", "Test Town",
                                                 "Test Street", 87, 8, "00-000", companyMock);

            //Act and Assert
            Assert.Throws <ForbiddenValueException>(() => sut.Update(country, state, town,
                                                                     street, buildingNumber, flatNumber, zipCode));
        }
Beispiel #3
0
        public void UpdateItself(string country, string state, string town, string street,
                                 int buildingNumber, int flatNumber, string zipCode)
        {
            //Arrange
            var companyMock = Mock.Of <Company>(x => x.Id == 1);
            var sut         = new CompanyAddress("Test Country", "Test State", "Test Town",
                                                 "Test Street", 87, 8, "00-000", companyMock);

            //Act
            sut.Update(country, state, town, street, buildingNumber,
                       flatNumber, zipCode);

            //Assert
            Assert.Equal(country, sut.Country);
            Assert.Equal(state, sut.State);
            Assert.Equal(town, sut.Town);
            Assert.Equal(street, sut.Street);
            Assert.Equal(buildingNumber, sut.BuildingNumber);
            Assert.Equal(flatNumber, sut.FlatNumber);
            Assert.Equal(zipCode, sut.ZipCode);
        }