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); } } }
public void TestCreateOrUpdate() { ManagedPlatform p = null; PlatformFrontEnd fe = null; PlatformDatabase db = null; try { // Arrange var ps = new PlatformService(); var pi = new RemotePlatformInfo { Id = TestPlatformId, FrontEndHost = "test", FrontEndDomain = "platform.co", Database = "db", DatabaseServer = "ds", Apps = new List <AvailableApplication>(), Tenants = new TenantList() }; var t = DateTime.UtcNow; // Act p = (ManagedPlatform)ps.CreateOrUpdate(pi); // Assert p.Should().NotBeNull(); p.DatabaseId.Should().Be(pi.Id); p.Name.Should().Be(pi.Id.ToLowerInvariant()); p.LastContact.Should().BeBefore(DateTime.UtcNow).And.BeAfter(t); p.ContainsTenants.Should().NotBeNull().And.BeEmpty(); p.AvailableAppVersions.Should().NotBeNull().And.BeEmpty(); p.FrontEndHistory.Should().NotBeNullOrEmpty(); p.FrontEndHistory.Count.Should().Be(1); fe = p.FrontEndHistory.First(); fe.Name.Should().Be("test.platform.co"); fe.Host.Should().Be("test"); fe.Domain.Should().Be("platform.co"); fe.LastContact.Should().BeBefore(DateTime.UtcNow).And.BeAfter(t); p.DatabaseHistory.Should().NotBeNullOrEmpty(); p.DatabaseHistory.Count.Should().Be(1); db = p.DatabaseHistory.First(); db.Name.Should().Be("ds (db)"); db.Catalog.Should().Be("db"); db.Server.Should().Be("ds"); db.LastContact.Should().BeBefore(DateTime.UtcNow).And.BeAfter(t); } finally { if (db != null) { Entity.Delete(db); } if (fe != null) { Entity.Delete(fe); } if (p != null) { Entity.Delete(p); } } }