Ejemplo n.º 1
0
        public void AddObject_UploadDataIsCalled()
        {
            var realm = GetRealm();

            var obj = new DbSyncClientObject
            {
                Text = "zxczxczxc",
            };

            realm.Write(() =>
            {
                realm.Add(obj);
            });
            _realmiusSyncService.Realm.Refresh();
            _realmiusSyncService.Realmius.Refresh();

            _uploadTask.Wait();

            _lastUploadRequest.Should().NotBeNull("UploadData should be called");
            string.Join(", ", _lastUploadRequest.ChangeNotifications)
            .Should().MatchEquivalentOf($"Type: DbSyncClientObject, PrimaryKey: {obj.Id}, SerializedObject: {{ \"Id\": \"{obj.Id}\", \"Text\": \"zxczxczxc\", \"Tags\": null, \"MobilePrimaryKey\": \"{obj.Id}\"}}");
            _apiClientMock.Verify(x => x.UploadData(It.IsAny <UploadDataRequest>()), Times.Once);
        }
Ejemplo n.º 2
0
        public void AddObject_Succeeded_Update_UploadDataIsCalled()
        {
            var realm = GetRealm();

            var obj = new DbSyncClientObject
            {
                Text = "444",
            };

            SetupCorrectUploadResponse();

            realm.Write(() =>
            {
                realm.Add(obj);
            });
            _realmiusSyncService.Realm.Refresh();
            _realmiusSyncService.Realmius.Refresh();

            _uploadTask.Wait();

            _uploadTask.Wait();
            _uploadTask        = null;
            _lastUploadRequest = null;
            Console.WriteLine("Before update");
            realm.Write(() =>
            {
                obj.Text = "555";
            });
            _realmiusSyncService.Realm.Refresh();
            _realmiusSyncService.Realmius.Refresh();

            Wait(() => _lastUploadRequest != null);

            _lastUploadRequest.Should().NotBeNull("UploadData should be called");
            string.Join(", ", _lastUploadRequest.ChangeNotifications)
            .Should().MatchEquivalentOf($"Type: DbSyncClientObject, PrimaryKey: {obj.Id}, SerializedObject: {{ \"Text\": \"555\"}}");
            _apiClientMock.Verify(x => x.UploadData(It.IsAny <UploadDataRequest>()), Times.AtLeast(2));
        }