상속: DomainEntity
        public decimal CalculateLbsPerUnit(InventoryProduct product)
        {
            if (product.UnitType == UnitType.Lbs.ToString())
            {
                return product.SizeOfUnit;
            }
            if (product.UnitType == UnitType.Oz.ToString())
            {
                return Math.Round(Convert.ToDecimal(Convert.ToDecimal(product.SizeOfUnit)/ 16), 2);
            }
            if (product.UnitType == UnitType.Tons.ToString())
            {
                return product.SizeOfUnit * 2000;
            }

            return 0;
        }
 public void Setup()
 {
     _field = ObjectMother.ValidField("raif").WithEntityId(1);
     _field.Size = 1000;
     _product = ObjectMother.ValidInventoryProductFertilizer("poop").WithEntityId(2);
     _product.SizeOfUnit = 100;
     _product.UnitType = UnitType.Lbs.ToString();
     var given = new SuperInputCalcViewModel
                     {
                         Field = _field.EntityId.ToString(),
                         Product = _product.EntityId.ToString(),
                         FertilizerRate = 100
                     };
     _repo = MockRepository.GenerateMock<IRepository>();
     _repo.Expect(x => x.Find<Field>(Int64.Parse(given.Field))).Return(_field);
     _repo.Expect(x => x.Find<InventoryProduct>(Int64.Parse(given.Product))).Return(_product);
     _SUT = new FertilizerNeededCalculator(_repo, new UnitSizeTimesQuantyCalculator(),null);
     _result = _SUT.Calculate(given);
 }
예제 #3
0
 public void CreateInventory()
 {
     _inventoryChemical1 = new InventoryProduct() { Product = _chemical1, Quantity = 10, UnitType = UnitType.Tons.Key, SizeOfUnit = 10};
     _inventoryChemical2 = new InventoryProduct() { Product = _chemical2, Quantity = 10, UnitType = UnitType.Tons.Key, SizeOfUnit = 10 };
     _inventoryFertilizer1 = new InventoryProduct() { Product = _fertilizer1, Quantity = 10, UnitType = UnitType.Tons.Key, SizeOfUnit = 10 };
     _inventoryFertilizer2 = new InventoryProduct() { Product = _fertilizer2, Quantity = 10, UnitType = UnitType.Tons.Key, SizeOfUnit = 10 };
     _invenotyMaterial1 = new InventoryProduct() { Product = _materials1, Quantity = 10, UnitType = UnitType.Tons.Key, SizeOfUnit = 10 };
     _inventoryMaterial2 = new InventoryProduct() { Product = _materials2, Quantity = 10, UnitType = UnitType.Tons.Key, SizeOfUnit = 10 };
     _inventorySeed1 = new InventoryProduct() { Product = _seed1, Quantity = 10, UnitType = UnitType.Tons.Key, SizeOfUnit = 10 };
     _inventorySeed2 = new InventoryProduct() { Product = _seed2, Quantity = 10, UnitType = UnitType.Tons.Key, SizeOfUnit = 10 };
     _repository.Save(_inventoryChemical1);
     _repository.Save(_inventoryChemical2);
     _repository.Save(_inventoryFertilizer1);
     _repository.Save(_inventoryFertilizer2);
     _repository.Save(_invenotyMaterial1);
     _repository.Save(_inventoryMaterial2);
     _repository.Save(_inventorySeed1);
     _repository.Save(_inventorySeed2);
 }