示例#1
0
        public void ShouldAdd()
        {
            Forage forage = new Forage();

            forage.Date      = DateTime.Today;
            forage.Forager   = ForagerRepositoryDouble.FORAGER;
            forage.Item      = ItemRepositoryDouble.ITEM;
            forage.Kilograms = 0.5M;

            Result <Forage> result = service.Add(forage);

            Assert.IsTrue(result.Success);
            Assert.NotNull(result.Value);
            Assert.AreEqual(36, result.Value.Id.Length);
        }
        private void AddForage()
        {
            view.DisplayHeader(MainMenuOption.AddForage.ToLabel());
            Forager forager = GetForager();

            if (forager == null)
            {
                return;
            }
            Item item = GetItem();

            if (item == null)
            {
                return;
            }
            Forage          forage = view.MakeForage(forager, item);
            Result <Forage> result = forageService.Add(forage);

            if (!result.Success)
            {
                view.DisplayStatus(false, result.Messages);
            }
            else
            {
                string successMessage = $"Forage {result.Value.Id} created.";
                view.DisplayStatus(true, successMessage);
            }
        }