Exemplo n.º 1
0
        public void RefreshPackagesTest()
        {
            Mock <Repository> repo_mock            = new Mock <Repository>();
            Mock <Upset>      package_dummy_old    = new Mock <Upset>();
            Mock <Upset>      package_dummy_recent = new Mock <Upset>();
            PackageRepo       old_pr = new PackageRepo
            {
                Package    = package_dummy_old.Object,
                Repository = repo_mock.Object
            };
            PackageRepo recent_pr = new PackageRepo
            {
                Package    = package_dummy_recent.Object,
                Repository = repo_mock.Object
            };

            repo_mock.Setup(repo => repo.ListPackages()).Returns(new Upset[] { package_dummy_recent.Object });

            (pl as PackageListTester).SetPackages(new List <PackageRepo> {
                old_pr
            });
            (pl as PackageListTester).SetRepositories(new Repository[] { repo_mock.Object });
            pl.RefreshPackages();
            List <PackageRepo> result = (pl as PackageListTester).GetPackages();

            CollectionAssert.DoesNotContain(result, old_pr);
            CollectionAssert.Contains(result, recent_pr);
        }