Пример #1
0
        public ChadderDataSource CreateSource()
        {
            var source = new ChadderDataSource();

            _sources.Add(source);
            return(source);
        }
Пример #2
0
        protected override void OnCreate(Bundle bundle)
        {
            ChadderDataSource.InitInsight();
            UIThread.Activity = this;
            // tests can be inside the main assembly
            AddTest(Assembly.GetExecutingAssembly());
            // or in any reference assemblies
            // AddTest (typeof (Your.Library.TestClass).Assembly);

            // Once you called base.OnCreate(), you cannot add more assemblies.
            base.OnCreate(bundle);
        }
Пример #3
0
        public async void Groups()
        {
            var n       = 3;
            var sources = await CreateAccountsAndAdd(n);

            var result  = await sources[0].CreateGroup("Test");
            var s1group = result.Item2;

            Assert.AreEqual(ChadderError.OK, result.Item1);
            Assert.NotNull(s1group);

            for (var i = 1; i < n; ++i)
            {
                var user = sources[0].database.getContact(sources[i].database.profile.myId);
                Assert.NotNull(user);
                Assert.AreEqual(ChadderError.OK, await sources[0].AddUserToGroup(s1group, user));
            }

            Assert.AreEqual(n, s1group.Members.Count);
            await sources[0].GenerateNewSecretForGroup(s1group);

            ChadderDataSource.InsightTrack("Sending messages");

            foreach (var source in sources)
            {
                var group = source.database.GetGroup(s1group.GroupId);
                Assert.NotNull(group);
                var conversation = await source.database.GetConversationByGroup(group);

                Assert.NotNull(conversation);
                await source.SendNewMessage(conversation, source.database.profile.myDeviceId);
            }
            foreach (var source in sources)
            {
                while (source.HasPendingMessages())
                {
                    await Task.Delay(100);
                }
            }
            await Task.Delay(1000);

            foreach (var source in sources)
            {
                var group        = source.database.GetGroup(s1group.GroupId);
                var conversation = await source.database.GetConversationByGroup(group);

                await source.requestUpdates();

                Assert.AreEqual(n, conversation.messages.Count);
            }
        }