public void RemoveActivityFromCostsTest()
        {
            var travel = new Travel
            {
                Name = "My Travel"
            };
            var activityWithCost = new TravelActivityWithCost
            {
                Name = "My Activity",
                Cost = new MoneyValue
                {
                    Value    = 24.0,
                    Currency = null
                }
            };

            travel.CostList.Add(activityWithCost);
            _repository.AddTravel(travel);
            Assert.AreEqual(0, _repository.GetTravel(travel.Id).ActivityList.Count);
            Assert.AreEqual(1, _repository.GetTravel(travel.Id).CostList.Count);
            CollectionAssert.AreEqual(travel.CostList as ICollection, _repository.GetTravel(travel.Id).CostList as ICollection);

            _repository.RemoveActivityFromCosts(travel.Id, activityWithCost);
            Assert.AreEqual(1, _repository.GetTravel(travel.Id).ActivityList.Count);
            Assert.AreEqual(0, _repository.GetTravel(travel.Id).CostList.Count);
        }
Esempio n. 2
0
        public void RemoveActivityFromCosts(Guid travelId, TravelActivityWithCost activityWithCost)
        {
            var travel   = Session.Get <Travel>(travelId);
            var activity = new TravelActivity
            {
                Name          = activityWithCost.Name,
                Description   = activityWithCost.Description,
                IsCompleted   = activityWithCost.IsCompleted,
                DateCompleted = activityWithCost.DateCompleted,
                DueDate       = activityWithCost.DueDate
            };

            travel.ActivityList.Add(activity);
            travel.CostList.Remove(activityWithCost);

            Session.Update(travel);
        }
Esempio n. 3
0
        public void AddActivityToCosts(Guid travelId, TravelActivity activity, MoneyValue cost)
        {
            var travel           = Session.Get <Travel>(travelId);
            var activityWithCost = new TravelActivityWithCost
            {
                Name          = activity.Name,
                Description   = activity.Description,
                IsCompleted   = activity.IsCompleted,
                DateCompleted = activity.DateCompleted,
                DueDate       = activity.DueDate,
                Cost          = cost
            };

            travel.CostList.Add(activityWithCost);
            travel.ActivityList.Remove(activity);

            Session.Update(travel);
        }