public void NuGetModel_FindPackagesTest()
        {
            IPackageManagerMock packageManagerMock = new IPackageManagerMock();
            var model = new NuGetModel(this.Descriptor, new IWebMatrixHostMock(), this.FakeFeedSource, string.Empty, packageManagerMock, TaskScheduler.Default);

            // Setup the mock call
            var            ran      = new Random(DateTime.Now.Millisecond);
            IList <string> expected = new List <string>()
            {
                ran.Next().ToString(),
                           ran.Next().ToString(),
                           ran.Next().ToString(),
                           ran.Next().ToString(),
                           ran.Next().ToString(),
            };

            packageManagerMock.FindPackagesFunc = (ids) => from id in ids
                                                  select new IPackageMock(id);

            var result = model.FindPackages(expected).ToList();

            Assert.Equal(expected.Count, result.Count);

            for (int i = 0; i < expected.Count; i++)
            {
                Assert.Equal(expected[i], result[i].Id);
            }
        }
        public void NuGetModel_GetPackagesWithUpdatesTest()
        {
            IPackageManagerMock packageManagerMock = new IPackageManagerMock();
            var model = new NuGetModel(this.Descriptor, new IWebMatrixHostMock(), this.FakeFeedSource, string.Empty, packageManagerMock, TaskScheduler.Default);

            // Setup the mock call
            string expected = new Random(DateTime.Now.Millisecond).Next().ToString();

            packageManagerMock.GetPackagesWithUpdatesFunc = () => new List <IPackage>()
            {
                new IPackageMock(expected)
            };

            var result = model.GetPackagesWithUpdates();

            Assert.Equal(1, result.Count());
            Assert.Equal(expected, result.First().Id);
        }
        public void NuGetModel_UninstallPackageTest()
        {
            IPackageManagerMock packageManagerMock = new IPackageManagerMock();
            var model = new NuGetModel(this.Descriptor, new IWebMatrixHostMock(), this.FakeFeedSource, string.Empty, packageManagerMock, TaskScheduler.Default);

            // Setup the mock call
            string expected = new Random(DateTime.Now.Millisecond).Next().ToString();

            packageManagerMock.UninstallPackageFunc = (package) => new List <string>()
            {
                package.Id
            };

            var result = model.UninstallPackage(new IPackageMock(expected), false);

            Assert.Equal(1, result.Count());
            Assert.Equal(expected, result.First());
        }
        public void NuGetModel_IsPackageInstalledTest()
        {
            IPackageManagerMock packageManagerMock = new IPackageManagerMock();
            var model = new NuGetModel(this.Descriptor, new IWebMatrixHostMock(), this.FakeFeedSource, string.Empty, packageManagerMock, TaskScheduler.Default);

            // Setup the mock call
            bool expected = true;

            packageManagerMock.IsPackageInstalledFunc = (package) => expected;

            var result = model.IsPackageInstalled(new IPackageMock(string.Empty));

            Assert.Equal(expected, result);

            expected = true;
            result   = model.IsPackageInstalled(new IPackageMock(string.Empty));
            Assert.Equal(expected, result);
        }
        public void NuGetModel_FindDependencyTest()
        {
            IPackageManagerMock packageManagerMock = new IPackageManagerMock();
            var model = new NuGetModel(this.Descriptor, new IWebMatrixHostMock(), this.FakeFeedSource, string.Empty, packageManagerMock, TaskScheduler.Default);

            string expected = "test";

            // Setup the mock call
            packageManagerMock.FindDependenciesToBeInstalledFunc = (package) => new List <IPackage>()
            {
                new IPackageMock(expected)
            };

            var result = model.FindDependenciesToBeInstalled(new IPackageMock(expected)).ToList();

            Assert.Equal(1, result.Count);
            Assert.Equal(expected, result[0].Id);
        }
        public void GetInstalledPackages()
        {
            string siteRoot = @"c:\";

            IPackageManagerMock packageManagerMock = new IPackageManagerMock();
            var model = new NuGetModel(
                this.Descriptor,
                new IWebMatrixHostMock(),
                this.DefaultFeedSource,
                siteRoot,
                packageManagerMock,
                TaskScheduler.Default);

            // Setup the mock call to FindPackages
            packageManagerMock.FindPackagesFunc         = (ids) => Enumerable.Empty <IPackage>();
            packageManagerMock.GetInstalledPackagesFunc = () => (from id in fakePackageIds
                                                                 select new IPackageMock(id)).AsQueryable();

            Assert.Equal <int>(fakePackageIds.Count, model.GetInstalledPackages().Count());
        }
Пример #7
0
        public void GetInstalledPackages()
        {
            string siteRoot = @"c:\";

            IPackageManagerMock packageManagerMock = new IPackageManagerMock();
            var model = new NuGetModel(
                this.Descriptor,
                new IWebMatrixHostMock(),
                this.DefaultFeedSource,
                siteRoot,
                packageManagerMock,
                TaskScheduler.Default);

            // Setup the mock call to FindPackages
            packageManagerMock.FindPackagesFunc = (ids) => Enumerable.Empty<IPackage>();
            packageManagerMock.GetInstalledPackagesFunc = () => (from id in fakePackageIds
                                                                 select new IPackageMock(id)).AsQueryable();

            Assert.Equal<int>(fakePackageIds.Count, model.GetInstalledPackages().Count());
        }
Пример #8
0
        public void NuGetModel_FindPackagesTest()
        {
            IPackageManagerMock packageManagerMock = new IPackageManagerMock();
            var model = new NuGetModel(this.Descriptor, new IWebMatrixHostMock(), this.FakeFeedSource, string.Empty, packageManagerMock, TaskScheduler.Default);

            // Setup the mock call
            var ran = new Random(DateTime.Now.Millisecond);
            IList<string> expected = new List<string>()
            {
                ran.Next().ToString(),
                ran.Next().ToString(),
                ran.Next().ToString(),
                ran.Next().ToString(),
                ran.Next().ToString(),
            };

            packageManagerMock.FindPackagesFunc = (ids) => from id in ids
                                                           select new IPackageMock(id);

            var result = model.FindPackages(expected).ToList();

            Assert.Equal(expected.Count, result.Count);

            for (int i = 0; i < expected.Count; i++)
            {
                Assert.Equal(expected[i], result[i].Id);
            }
        }
Пример #9
0
        public void NuGetModel_GetPackagesWithUpdatesTest()
        {
            IPackageManagerMock packageManagerMock = new IPackageManagerMock();
            var model = new NuGetModel(this.Descriptor, new IWebMatrixHostMock(), this.FakeFeedSource, string.Empty, packageManagerMock, TaskScheduler.Default);

            // Setup the mock call
            string expected = new Random(DateTime.Now.Millisecond).Next().ToString();
            packageManagerMock.GetPackagesWithUpdatesFunc = () => new List<IPackage>() { new IPackageMock(expected) };

            var result = model.GetPackagesWithUpdates();

            Assert.Equal(1, result.Count());
            Assert.Equal(expected, result.First().Id);
        }
Пример #10
0
        public void NuGetModel_IsPackageInstalledTest()
        {
            IPackageManagerMock packageManagerMock = new IPackageManagerMock();
            var model = new NuGetModel(this.Descriptor, new IWebMatrixHostMock(), this.FakeFeedSource, string.Empty, packageManagerMock, TaskScheduler.Default);

            // Setup the mock call
            bool expected = true;
            packageManagerMock.IsPackageInstalledFunc = (package) => expected;

            var result = model.IsPackageInstalled(new IPackageMock(string.Empty));
            Assert.Equal(expected, result);

            expected = true;
            result = model.IsPackageInstalled(new IPackageMock(string.Empty));
            Assert.Equal(expected, result);
        }
Пример #11
0
        public void NuGetModel_UninstallPackageTest()
        {
            IPackageManagerMock packageManagerMock = new IPackageManagerMock();
            var model = new NuGetModel(this.Descriptor, new IWebMatrixHostMock(), this.FakeFeedSource, string.Empty, packageManagerMock, TaskScheduler.Default);

            // Setup the mock call
            string expected = new Random(DateTime.Now.Millisecond).Next().ToString();
            packageManagerMock.UninstallPackageFunc = (package) => new List<string>() { package.Id };

            var result = model.UninstallPackage(new IPackageMock(expected), false);

            Assert.Equal(1, result.Count());
            Assert.Equal(expected, result.First());
        }
Пример #12
0
        public void NuGetModel_FindDependencyTest()
        {
            IPackageManagerMock packageManagerMock = new IPackageManagerMock();
            var model = new NuGetModel(this.Descriptor, new IWebMatrixHostMock(), this.FakeFeedSource, string.Empty, packageManagerMock, TaskScheduler.Default);

            string expected = "test";

            // Setup the mock call
            packageManagerMock.FindDependenciesToBeInstalledFunc = (package) => new List<IPackage>() { new IPackageMock(expected) };

            var result = model.FindDependenciesToBeInstalled(new IPackageMock(expected)).ToList();

            Assert.Equal(1, result.Count);
            Assert.Equal(expected, result[0].Id);
        }