Exemplo n.º 1
0
 public void RecalculateProjectByWeightTest()
 {
     var draws = new List<Drawing>
         {
             new Drawing {Id = 1, Count = 1, CountAll = 1, Weight = 1, WeightAll = 1},
             new Drawing {Id = 2, Count = 1, CountAll = 1, Weight = 1, WeightAll = 2},
             new Drawing {Id = 3, Count = 1, CountAll = 1, Weight = 7, WeightAll = 7},
             new Drawing {Id = 4, ParentId = 3, Count = 2, CountAll = 2, Weight = 2, WeightAll = 4},
             new Drawing {Id = 5, ParentId = 4, Count = 1, CountAll = 2, Weight = 1, WeightAll = 2},
             new Drawing {Id = 6, ParentId = 4, Count = 2, CountAll = 4, Weight = 5, WeightAll = 20},
             new Drawing {Id = 7, ParentId = 3, Count = 2, CountAll = 2, Weight = 5, WeightAll = 10},
         };
     var dm = new Mock<IClassDataManager<Drawing>>();
     dm.Setup(x => x.GetListCollection()).Returns(draws);
     dm.Setup(x => x.GetListCollection(It.IsAny<Func<Drawing, bool>>())).Returns<Func<Drawing, bool>>(x => draws.Where(x).ToList());
     dm.Setup(x => x.GetDocument(It.IsAny<int?>())).Returns<int?>(x => draws.FirstOrDefault(y => y.Id == x));
     var hellper = new DrawingsCalculateHelper();
     draws[4].Weight = 7;
     Assert.DoesNotThrow(() => hellper.RecalculateProjectByWeight(draws[4], dm.Object));
     Assert.AreEqual(44, draws[2].WeightAll);
     Assert.AreEqual(1, draws[0].WeightAll);
     Assert.AreEqual(34, draws[3].WeightAll);
 }
Exemplo n.º 2
0
 public void RecalculateProjectByCount(Drawing drawing, IClassDataManager<Drawing> classDataManager)
 {
     var drawingsCalculateHelper = new DrawingsCalculateHelper(classDataManager);
     drawingsCalculateHelper.RecalculateProjectByCount(drawing);
 }
Exemplo n.º 3
0
 public void RecalculateProjectByCount(Drawing drawing)
 {
     var drawingsCalculateHelper = new DrawingsCalculateHelper(_dataManagersFactory.GetDataManager<Drawing>());
     drawingsCalculateHelper.RecalculateProjectByCount(drawing);
 }