Exemplo n.º 1
0
 public CurrencyController(ILogger <CurrencyController> logger)
 {
     this._logger = logger;
     repo         = new USCurrencyRepo();
     vm           = new RepoViewModel(repo);
     //vm.Coins.Add(new Penny());
 }
        private void MakeChangeView1_Loaded(object sender, RoutedEventArgs e)
        {
            //USCurrencyRepo changeRepo = new USCurrencyRepo();
            RepoViewModel repoModel = new RepoViewModel(StaticInformation.MainRepo);

            this.MakeChangeView1.DataContext = new MakeChangeViewModel(StaticInformation.MainRepo, repoModel);
            this.MakeChangeView1.ChangeRepoView.DataContext = repoModel;
        }
Exemplo n.º 3
0
        public void Coins_For_ComboBoxCoins_Collections_AreSame()
        {
            //Arrange
            repo = new USCurrencyRepo();
            vm   = new RepoViewModel((USCurrencyRepo)repo);

            ObservableCollection <ICoin> testCoinsforcdCoins;

            //Act
            testCoinsforcdCoins = vm.CoinsForComboBox;
            var coinList = USCurrencyRepo.GetCoinList();

            //Assert
            CollectionAssert.AreEqual(coinList, testCoinsforcdCoins);
        }
Exemplo n.º 4
0
        //[OutputCache(CacheProfile = "Collaborator")]
        public async Task <ActionResult> Index(string repoOwner, string repoName)
        {
            var  user          = GitHubService.GetUser(repoOwner);
            var  repository    = GitHubService.GetRepository(repoOwner, repoName);
            var  collaborators = GitHubService.GetCollaborators(repoOwner, repoName);
            var  signers       = DataContext.Signatures.Where(repoOwner, repoName).ToList();
            var  repoSettings  = DataContext.Repositories.Where(repoOwner, repoName);
            bool requireCla    = repoSettings != null && repoSettings.RequireCla;

            var viewModel = new RepoViewModel(await user, await repository, await collaborators, User.Identity, signers, requireCla);

            // TODO: Move this data caching into a repo wrapper?
            HttpContext.SetCollaborators(viewModel.Collaborators.Select(c => c.Username).ToArray());

            return(View(viewModel));
        }
        public void RepoViewModel_NotifyPropertyChangedTest()
        {
            //Arrange
            RepoViewModel vm             = new RepoViewModel(new USCurrencyRepo());
            List <string> receivedEvents = new List <string>();

            vm.CoinViews.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e)
            {
                receivedEvents.Add(sender.GetType().ToString());
            };

            //Act
            vm.AddCoin(new Penny());

            //Assert
            Assert.IsTrue(receivedEvents.Count > 0);
        }
        public void MakeChangeViewModel_NotifyPropertyChangedTest()
        {
            //Arrange
            RepoViewModel       rpVM           = new RepoViewModel(new USCurrencyRepo());
            MakeChangeViewModel vm             = new MakeChangeViewModel(new USCurrencyRepo(), rpVM);
            List <string>       receivedEvents = new List <string>();

            vm.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                receivedEvents.Add(e.PropertyName);
            };

            //Act
            vm.RepoAmount = 1;

            //Assert
            Assert.AreEqual(receivedEvents[0], "RepoAmount");
        }
Exemplo n.º 7
0
        public IActionResult Index(string searchString, string own)
        {
            RepoViewModel repos = new RepoViewModel();

            if (string.IsNullOrEmpty(searchString))
            {
                Array  values     = Enum.GetValues(typeof(Langs));
                Random random     = new Random();
                Langs  randomLang = (Langs)values.GetValue(random.Next(values.Length));
                searchString = randomLang.ToString();
            }

            if (!string.IsNullOrEmpty(own))
            {
                repos = PrepareModelOwn(searchString);
                return(View(repos));
            }

            try
            {
                HttpResponseMessage response = _repoService.GetByDescription(searchString).Result;
                if (response.IsSuccessStatusCode)
                {
                    repos = response.Content.ReadAsAsync <RepoViewModel>().Result;
                }
                else
                {
                    RedirectToAction("Error");
                }
            }
            catch (Exception ex)
            {
                TempData["Message"] = ex.InnerException.Message;
            }

            return(View(repos));
        }
Exemplo n.º 8
0
        private RepoViewModel PrepareModelOwn(string searchString)
        {
            RepoViewModel model = new RepoViewModel();

            try
            {
                IList <Repo> repos = _repoService.Search(searchString);
                model.total_count = repos.Count();
                foreach (var item in repos)
                {
                    RepoItemDetails itemModel = new RepoItemDetails();
                    itemModel.created_at  = item.created_at;
                    itemModel.description = item.description;
                    itemModel.full_name   = item.full_name;
                    itemModel.git_url     = item.git_url;
                    itemModel.id          = item.id;
                    itemModel.name        = item.name;
                    Repo.Owner owner = _ownerService.Find(item.ownerid);
                    itemModel.owner = new Owner {
                        id = owner.id, avatar_url = owner.avatar_url, login = owner.login
                    };
                    itemModel.url = item.url;
                    model.items.Add(itemModel);
                }
            }
            catch (RepoNotFoundException ex)
            {
                TempData["Message"] = ex.Message;
            }
            catch (Exception)
            {
                RedirectToAction("Error");
            }

            return(model);
        }
Exemplo n.º 9
0
 public RepoWindow(USCurrencyRepo repo)
 {
     InitializeComponent();
     viewModel = new RepoViewModel(repo);
 }
 public MakeChangeViewModelTests()
 {
     repo = new USCurrencyRepo();
     rpVM = new RepoViewModel(repo);
     vm   = new MakeChangeViewModel(repo, rpVM);
 }
Exemplo n.º 11
0
 public CurrencyRepoController()
 {
     repo = new USCurrencyRepo(); //can we inject this?
     vm   = new RepoViewModel(repo);
 }