示例#1
0
        public void ShouldConvertServiceProjectIntoAProject()
        {
            var serviceProject = TranslatorHelper.CreateServiceProject();

            var project = DataServiceTranslator.ConvertToProject(serviceProject);

            TranslatorHelper.AssertProject(serviceProject, project);
        }
示例#2
0
        /// <summary>
        /// Loads the project asynchronously.
        /// </summary>
        /// <param name="projectUri">The project URI.</param>
        public void LoadProjectAsync(Uri projectUri)
        {
            this.OnLoadProjectCompleted(new DataEventArgs <Project>(null, null));

            if (projectUri == null)
            {
                return;
            }

            DataServiceClient client = this.CreateDataServiceClient();

            client.LoadProjectCompleted += (sender, args) =>
            {
                if (args.Error != null)
                {
                    client.Abort();
                    this.logger.Log(this.GetType().Name, args.Error);

                    if (args.Error.GetType() == typeof(Exception))
                    {
                        throw args.Error;
                    }

                    return;
                }

                try
                {
                    Project project = DataServiceTranslator.ConvertToProject(args.Result);
                    this.OnLoadProjectCompleted(new DataEventArgs <Project>(project));
                }
                catch (Exception e)
                {
                    client.Abort();
                    this.logger.Log(this.GetType().Name, e);
                    throw;
                }
            };

            client.LoadProjectAsync(projectUri);
        }
示例#3
0
        public void ShouldReturnNullIfProjectContainerIsNull()
        {
            var result = DataServiceTranslator.ConvertToProject(null);

            Assert.IsNull(result);
        }