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 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);
                }
            }
        }