Example #1
0
        private BackendlessResponse <Assessment> SetFailedDeletion(Assessment assessment, string errorMessage)
        {
            var url  = Connection.GenerateTableUrl <Assessment>(assessment.ObjectId);
            var json = assessment.ObjectId;

            _restServiceCaller.Delete(url, Arg.Any <Dictionary <string, string> >())
            .Returns(Task.FromResult(json));
            _jsonSerializer.AsDictionary(json)
            .Returns(new Dictionary <string, string>());
            var backendlessResponse = BackendlessResponse <Assessment> .Failed("123", errorMessage);

            _responseParser.Parse <Assessment>(json).Returns(backendlessResponse);
            return(backendlessResponse);
        }
        private BackendlessResponse <Assessment> SetupFailedPost(Assessment localAssessment, string errorMessage)
        {
            var clonedLocalAssessment = new Assessment {
                ObjectId = localAssessment.ObjectId
            };
            var savedAssessment = CreateSavedAssessment();
            var url             = Connection.GenerateTableUrl <Assessment>();

            _jsonSerializer.Clone(localAssessment).Returns(clonedLocalAssessment);
            var serializedObject = $"{savedAssessment.ObjectId}-serialized";

            _jsonSerializer.Serialize(clonedLocalAssessment).Returns(serializedObject);
            var jsonResponse = $"{savedAssessment.ObjectId}-failedResponse";

            _restServiceCaller.Post(url, Arg.Any <Dictionary <string, string> >(), serializedObject)
            .Returns(Task.FromResult(jsonResponse));
            var backendlessResponse = BackendlessResponse <Assessment> .Failed("error", errorMessage);

            _responseParser.Parse <Assessment>(jsonResponse).Returns(backendlessResponse);
            return(backendlessResponse);
        }