Exemple #1
0
        public async void TestUpdateInstallationNormalNotLoggedIn()
        {
            // Signup & Login
            var user = await ITUtil.SignUpAndLogin();

            // Save Installation
            await ITUtil.UpsertInstallation();

            NbSsePushInstallation currentInstallation = NbSsePushInstallation.GetCurrentInstallation();

            Assert.AreEqual(user.UserId, currentInstallation.Owner);

            var preInstallationId = currentInstallation.InstallationId;
            var preUsername       = currentInstallation.Username;
            var prePassword       = currentInstallation.Password;
            var preUri            = currentInstallation.Uri;

            // Logout
            await ITUtil.Logout();

            // Change Channels, AllowedSenders and Options
            // Channels Set
            ISet <string> channels = new HashSet <string>();

            channels.Add("chan2");
            currentInstallation.Channels = channels;

            // AllowedSenders Set
            ISet <string> allowedSenders = new HashSet <string>();

            allowedSenders.Add("g:anonymous");
            currentInstallation.AllowedSenders = allowedSenders;

            // Options Set
            NbJsonObject options = new NbJsonObject();

            options.Add("email", "*****@*****.**");
            options.Add("test", "testValue2");
            currentInstallation.Options = options;

            // Main
            var result = await currentInstallation.Save();

            // Check Response
            ITUtil.CheckCommonResponse(result);
            Assert.AreEqual(preInstallationId, result.InstallationId);
            Assert.AreEqual(channels, result.Channels);
            Assert.AreEqual(allowedSenders, result.AllowedSenders);
            Assert.AreEqual(options, result.Options);
            // Check Owner is null
            Assert.IsNull(result.Owner);
            Assert.AreEqual(preUsername, result.Username);
            Assert.AreEqual(prePassword, result.Password);
            Assert.AreEqual(preUri, result.Uri);

            // Check Storage
            ITUtil.CheckSaveStorage(result);
        }
Exemple #2
0
        public async void TestSaveInstallationNormalLoggedIn()
        {
            // SignUp & Login
            NbUser user = await ITUtil.SignUpAndLogin();

            NbSsePushInstallation currentInstallation = NbSsePushInstallation.GetCurrentInstallation();

            // Channels Set
            ISet <string> channels = new HashSet <string>();

            channels.Add("chan1");
            currentInstallation.Channels = channels;

            // AllowedSenders Set
            ISet <string> allowedSenders = new HashSet <string>();

            allowedSenders.Add("g:authenticated");
            currentInstallation.AllowedSenders = allowedSenders;

            // Options Set
            NbJsonObject options = new NbJsonObject();

            options.Add("email", "*****@*****.**");
            options.Add("test", "testValue");
            currentInstallation.Options = options;

            // Main
            var result = await currentInstallation.Save();

            // Check Response
            ITUtil.CheckCommonResponse(result);
            Assert.AreEqual(channels, result.Channels);
            Assert.AreEqual(allowedSenders, result.AllowedSenders);
            Assert.AreEqual(user.UserId, result.Owner);
            Assert.AreEqual(options, result.Options);

            // Check Storage
            ITUtil.CheckSaveStorage(result);
        }