public async Task OnRestoreCompleted_WhenRestoreFailed_IsUpToDate()
        {
            var restoreData = new RestoreData(string.Empty, DateTime.MinValue, succeeded: false);
            var snapshot    = IProjectSnapshot2Factory.Create();

            var result = await OnRestoreCompleted(snapshot, restoreData);

            Assert.True(result);
        }
Exemple #2
0
            private static bool IsRestoreUpToDate(IProjectSnapshot projectSnapshot, RestoreData restoreData)
            {
                // If restore failed, we treat as though it is up-to-date to avoid it forever being stuck out of date.
                if (!restoreData.Succeeded)
                {
                    return(true);
                }

                DateTime lastEvaluationWriteTime = GetLastWriteTimeUtc(restoreData.ProjectAssetsFilePath, projectSnapshot);

                return(lastEvaluationWriteTime >= restoreData.ProjectAssetsLastWriteTimeUtc);
            }
        public async Task OnRestoreCompleted_WhenEvaluationIsMissingProjectAssetsFile_IsUpToDate()
        {
            string projectAssetsFile = @"C:\Project\obj\project.assets.json";

            var currentTimestamp = DateTime.Now;

            var restoreData = new RestoreData(projectAssetsFile, currentTimestamp);
            var snapshot    = IProjectSnapshot2Factory.Create();

            var result = await OnRestoreCompleted(snapshot, restoreData);

            Assert.True(result);
        }
        public async Task OnRestoreCompleted_WhenEvaluationRanSameAssetsFile_IsUpToDate()
        {
            string projectAssetsFile = @"C:\Project\obj\project.assets.json";

            var currentTimestamp    = DateTime.Now;
            var evaluationTimestamp = currentTimestamp;

            var restoreData = new RestoreData(projectAssetsFile, currentTimestamp);
            var snapshot    = IProjectSnapshot2Factory.WithAdditionalDependentFileTime(
                projectAssetsFile,
                evaluationTimestamp);

            var result = await OnRestoreCompleted(snapshot, restoreData);

            Assert.True(result);
        }
        private async Task <bool> OnRestoreCompleted(IProjectSnapshot projectSnapshot, RestoreData restoreData)
        {
            bool result = false;
            var  dataProgressTrackerService = IDataProgressTrackerServiceFactory.ImplementNotifyOutputDataCalculated(_ => { result = true; });

            var instance = await CreateInitializedInstance(dataProgressTrackerService : dataProgressTrackerService);

            var tuple = ValueTuple.Create(projectSnapshot, restoreData);
            var value = IProjectVersionedValueFactory.Create(tuple);

            instance.OnRestoreCompleted(value);

            return(result);
        }