Beispiel #1
0
        private IEnumerable <Option> GetTransactionTypes()
        {
            var result = _transactionTypeService.GetAll();

            if (result.IsSuccess())
            {
                var list = from tt in result.GetPayload()
                           select new Option(tt.Id.ToString(), tt.Name);

                return(list.ToList());
            }

            return(new List <Option>());
        }
        public void GetAll_ReturnsAll()
        {
            string expectedTransactionTypesJson = File.ReadAllText(TestConfiguration.MockDataFolderPath + @"TransactionTypes.json");
            var    expectedTransactionTypes     = JsonConvert.DeserializeObject <List <TransactionType> >(expectedTransactionTypesJson);

            TransactionTypeRepository.Setup(r => r.GetAll()).Returns(expectedTransactionTypes);


            var actualTransactionTypes = TransactionTypeService.GetAll();


            Assert.NotNull(actualTransactionTypes);
            Assert.Equal(expectedTransactionTypes.Count, actualTransactionTypes.Count());
        }
        public IActionResult Index()
        {
            var result = _transactionTypeService.GetAll();

            IndexViewModel model;

            if (result.HasErrors())
            {
                model = new IndexViewModel()
                {
                    TransactionTypes = new List <TransactionType>(),
                    Message          = result.GetFailure()
                };

                return(View(model));
            }

            model = new IndexViewModel()
            {
                TransactionTypes = result.GetPayload()
            };

            return(View(model));
        }