예제 #1
0
        public void TestGetPlatform()
        {
            // Arrange
            var ms = new MarketplaceService();

            // there should be no platforms in the system, normally
            var t  = DateTime.Now;
            var mp = new ManagedPlatform
            {
                Name        = "MyServer",
                DatabaseId  = "myserver.foo.con",
                LastContact = t
            };

            mp.Save();

            // Act
            Action a = () => ms.GetPlatform(null);

            a.ShouldNotThrow();

            // Should pull the most recently heard from platform... for now
            var p = ms.GetPlatform(null);

            // Assert
            p.Should().NotBeNull();
            p.Name.Should().Be(mp.Name);
            p.DatabaseId.Should().Be(mp.DatabaseId);
            p.LastContact.Should().Be(t);
        }
예제 #2
0
        public void TestDeleteUser()
        {
            ManagedPlatform p = null;
            ManagedTenant   t = null;
            ManagedUser     u = null;

            try
            {
                // Arrange
                var ps = new PlatformService();

                p = CreateTestPlatform();
                t = CreateTestTenant(p);
                u = CreateTestUser(t);
                p.Save();

                p.Should().NotBeNull();
                t.Should().NotBeNull();
                u.Should().NotBeNull();

                var pid = p.Id;
                var tid = t.Id;
                var uid = u.Id;

                // Act
                ps.DeleteUser(TestPlatformId, TestTenantName, TestUserName);

                // Assert
                var e1 = Entity.Get(pid);
                e1.Should().NotBeNull();

                var e2 = Entity.Get(tid);
                e2.Should().NotBeNull();

                var e3 = Entity.Get(uid);
                e3.Should().BeNull();
            }
            finally
            {
                if (u != null)
                {
                    Entity.Delete(u);
                }
                if (t != null)
                {
                    Entity.Delete(t);
                }
                if (p != null)
                {
                    Entity.Delete(p);
                }
            }
        }
예제 #3
0
        public void TestUpdateInstalledApplications()
        {
            ManagedPlatform   p = null;
            ManagedTenant     t = null;
            ManagedAppVersion v = null;

            try
            {
                // Arrange
                var ps = new PlatformService();

                // Act
                t = (ManagedTenant)ps.UpdateInstalledApplications(TestPlatformId, TestTenantName, new List <InstalledApplication>());

                // Assert
                t.Should().BeNull();

                p = CreateTestPlatform();
                t = CreateTestTenant(p);
                p.Save();

                t = (ManagedTenant)ps.UpdateInstalledApplications(TestPlatformId, TestTenantName, new List <InstalledApplication>());
                t.Should().NotBeNull();
                t.Name.Should().Be(TestTenantName);
                t.Platform.DatabaseId.Should().Be(TestPlatformId);
                t.HasAppsInstalled.Count.Should().Be(0);

                var tid = t.Id;

                t = (ManagedTenant)ps.UpdateInstalledApplications(TestPlatformId, TestTenantName, new List <InstalledApplication>
                {
                    new InstalledApplication {
                        ApplicationVersionId = TestAppVersionId
                    }
                });

                t.Should().NotBeNull();
                t.Id.Should().Be(tid);
                t.Name.Should().Be(TestTenantName);
                t.Platform.DatabaseId.Should().Be(TestPlatformId);
                t.HasAppsInstalled.Count.Should().Be(1);

                v = t.HasAppsInstalled.First();
                v.Name.Should().BeNull();
                v.PublishDate.Should().NotHaveValue();
                v.Version.Should().BeNull();
                v.VersionId.Should().Be(TestAppVersionId);
                v.Application.Should().BeNull();
                v.RequiredApps.Should().BeEmpty();
                v.RequiredAppVersions.Should().BeEmpty();

                var vid = v.Id;

                t = (ManagedTenant)ps.UpdateInstalledApplications(TestPlatformId, TestTenantName, new List <InstalledApplication>
                {
                    new InstalledApplication
                    {
                        ApplicationVersionId = TestAppVersionId,
                        Name            = "Test App Version",
                        ReleaseDate     = new DateTime(2000, 10, 24),
                        PackageVersion  = "2.3.3.0",
                        SolutionVersion = "1.7.7.0"
                    }
                });

                t.Should().NotBeNull();
                t.Id.Should().Be(tid);
                t.Name.Should().Be(TestTenantName);
                t.Platform.DatabaseId.Should().Be(TestPlatformId);
                t.HasAppsInstalled.Count.Should().Be(1);

                v = t.HasAppsInstalled.First();
                v.Id.Should().Be(vid);
                v.Name.Should().Be("Test App Version");
                v.PublishDate.Should().HaveValue().And.Be(new DateTime(2000, 10, 24));
                v.Version.Should().Be("1.7.7.0");
                v.VersionId.Should().Be(TestAppVersionId);
                v.Application.Should().BeNull();
                v.RequiredApps.Should().BeEmpty();
                v.RequiredAppVersions.Should().BeEmpty();
            }
            finally
            {
                if (v != null)
                {
                    Entity.Delete(v);
                }
                if (t != null)
                {
                    Entity.Delete(t);
                }
                if (p != null)
                {
                    Entity.Delete(p);
                }
            }
        }
예제 #4
0
        public void TestCreateOrUpdateUser()
        {
            ManagedPlatform p = null;
            ManagedTenant   t = null;
            ManagedUser     u = null;

            try
            {
                // Arrange
                var ps = new PlatformService();
                var ui = new RemoteUserInfo
                {
                    Name = TestUserName
                };

                // Act
                u = (ManagedUser)ps.CreateOrUpdateUser(TestPlatformId, TestTenantName, ui);

                // Assert
                u.Should().BeNull();

                p = CreateTestPlatform();
                t = CreateTestTenant(p);
                p.Save();

                u = (ManagedUser)ps.CreateOrUpdateUser(TestPlatformId, TestTenantName, ui);
                u.Should().BeNull();

                ui.RemoteId = TestUserRemoteId;

                u = (ManagedUser)ps.CreateOrUpdateUser(TestPlatformId, TestTenantName, ui);
                u.Should().NotBeNull();
                u.Name.Should().Be(TestUserName);
                u.RemoteId.Should().Be(TestUserRemoteId.ToString());
                u.Status_Enum.Should().Be(ManagedUserStatusEnumeration.Unknown);
                u.Tenant.Name.Should().Be(TestTenantName);
                u.Tenant.Platform.DatabaseId.Should().Be(TestPlatformId);

                var uid = u.Id;

                u = (ManagedUser)ps.CreateOrUpdateUser(TestPlatformId, TestTenantName, new RemoteUserInfo
                {
                    RemoteId = TestUserRemoteId,
                    Name     = "Another Name",
                    Status   = UserStatus.Expired
                });

                u.Should().NotBeNull();
                u.Id.Should().Be(uid);
                u.Name.Should().Be("Another Name");
                u.RemoteId.Should().Be(TestUserRemoteId.ToString());
                u.Status_Enum.Should().Be(ManagedUserStatusEnumeration.Expired);
                u.Tenant.Name.Should().Be(TestTenantName);
                u.Tenant.Platform.DatabaseId.Should().Be(TestPlatformId);
            }
            finally
            {
                if (u != null)
                {
                    Entity.Delete(u);
                }
                if (t != null)
                {
                    Entity.Delete(t);
                }
                if (p != null)
                {
                    Entity.Delete(p);
                }
            }
        }