Пример #1
0
        public void SetUp()
        {
            searchLog = new StringWriter();

            mockTarget            = Substitute.For <RemoteTarget>();
            moduleReplacedHandler = Substitute.For <EventHandler <LldbModuleReplacedEventArgs> >();

            mockModuleFileFinder = Substitute.For <IModuleFileFinder>();
            mockModuleFileFinder.FindFileAsync(BINARY_FILENAME, UUID, false, searchLog)
            .Returns(Task.FromResult(PATH_IN_STORE));

            placeholderModule = Substitute.For <SbModule>();
            placeholderModule.GetPlatformFileSpec().GetFilename().Returns(BINARY_FILENAME);
            placeholderModule.GetUUIDString().Returns(UUID.ToString());

            placeholderProperties =
                new PlaceholderModuleProperties(MODULE_SLIDE, Substitute.For <SbFileSpec>());

            mockModuleUtil = Substitute.For <ILldbModuleUtil>();
            mockModuleUtil.IsPlaceholderModule(placeholderModule).Returns(true);
            mockModuleUtil.GetPlaceholderProperties(Arg.Any <SbModule>(), Arg.Any <RemoteTarget>())
            .ReturnsForAnyArgs(placeholderProperties);
            mockModuleUtil.ApplyPlaceholderProperties(
                Arg.Any <SbModule>(), Arg.Any <PlaceholderModuleProperties>(),
                Arg.Any <RemoteTarget>())
            .ReturnsForAnyArgs(true);


            binaryLoader = new BinaryLoader(mockModuleUtil, mockModuleFileFinder,
                                            mockTarget);
            binaryLoader.LldbModuleReplaced += moduleReplacedHandler;
        }
Пример #2
0
        public ActionResult Edit(int id)
        {
            var hevm    = CreateViewModel <HolidayEditViewModel>();
            var Holiday = _holidayRepository.FindById(id);

            Mapper.Map(Holiday, hevm.Holiday);

            var building_ids = GetUserBuildings(_buildingRepository, _userRepository);
            var buildings    = _buildingRepository.FindAll().Where(x => !x.IsDeleted && building_ids.Contains(x.Id));

            Mapper.Map(buildings, hevm.BuildingItems);

            var ActiveBuildings = GetUserHolidayBuildings(id);

            foreach (int BuildId in ActiveBuildings)
            {
                hevm.BuildingItems.Where(x => x.Value == BuildId.ToString()).First().Selected = true;
            }

            if (!hevm.BuildingItems.Where(x => x.Selected).Any())
            {
                hevm.AllBuildings = true;
            }
            hevm.Holiday.EventStartStr = hevm.Holiday.EventStart.ToString("dd.MM.yyyy");
            return(PartialView(hevm));
        }
Пример #3
0
        public async Task VerifySymbolFileAsync(string filepath, bool isDebugInfoFile)
        {
            BuildId buildId = await ReadBuildIdAsync(filepath);

            if (_verificationFailures.TryGetValue(buildId.ToString(), out string errorString))
            {
                throw new BinaryFileUtilException(errorString);
            }
        }
Пример #4
0
        SbModule CreateMockModule()
        {
            var mockModule = Substitute.For <SbModule>();

            mockModule.GetPlatformFileSpec().Returns(mockPlatformFileSpec);
            mockModule.GetSymbolFileSpec().Returns(mockSymbolFileSpec);
            mockModule.GetFileSpec().Returns(mockBinaryFileSpec);
            mockModule.GetUUIDString().Returns(UUID.ToString());
            mockModuleUtil.HasSymbolsLoaded(mockModule).Returns(false);
            return(mockModule);
        }
        public override async Task <IFileReference> FindFileAsync(string filename, BuildId buildId,
                                                                  bool isDebugInfoFile,
                                                                  TextWriter log)
        {
            if (string.IsNullOrEmpty(filename))
            {
                throw new ArgumentException(Strings.FilenameNullOrEmpty, "filename");
            }
            if (buildId == BuildId.Empty)
            {
                Trace.WriteLine(
                    Strings.FailedToSearchStructuredStore(_path, filename, Strings.EmptyBuildId));
                await log.WriteLineAsync(
                    Strings.FailedToSearchStructuredStore(_path, filename, Strings.EmptyBuildId));

                return(null);
            }

            string filepath;

            try
            {
                filepath = Path.Combine(_path, filename, buildId.ToString(), filename);
            }
            catch (ArgumentException e)
            {
                Trace.WriteLine(Strings.FailedToSearchStructuredStore(_path, filename, e.Message));
                await log.WriteLineAsync(
                    Strings.FailedToSearchStructuredStore(_path, filename, e.Message));

                return(null);
            }
            if (!_fileSystem.File.Exists(filepath))
            {
                Trace.WriteLine(Strings.FileNotFound(filepath));
                await log.WriteLineAsync(Strings.FileNotFound(filepath));

                return(null);
            }

            Trace.WriteLine(Strings.FileFound(filepath));
            await log.WriteLineAsync(Strings.FileFound(filepath));

            return(new FileReference(_fileSystem, filepath));
        }
        public override async Task <IFileReference> AddFileAsync(IFileReference source,
                                                                 string filename, BuildId buildId,
                                                                 TextWriter log)
        {
            if (source == null)
            {
                throw new ArgumentException(Strings.FailedToCopyToStructuredStore(
                                                _path, filename, Strings.SourceFileReferenceNull),
                                            nameof(source));
            }
            if (string.IsNullOrEmpty(filename))
            {
                throw new ArgumentException(Strings.FailedToCopyToStructuredStore(
                                                _path, filename, Strings.FilenameNullOrEmpty),
                                            nameof(filename));
            }
            if (buildId == BuildId.Empty)
            {
                throw new ArgumentException(
                          Strings.FailedToCopyToStructuredStore(_path, filename, Strings.EmptyBuildId),
                          nameof(buildId));
            }

            try
            {
                AddMarkerFileIfNeeded();

                string filepath = Path.Combine(_path, filename, buildId.ToString(), filename);
                await source.CopyToAsync(filepath);

                Trace.WriteLine(Strings.CopiedFile(filename, filepath));
                await log.WriteLineAsync(Strings.CopiedFile(filename, filepath));

                return(new FileReference(_fileSystem, filepath));
            }
            catch (Exception e) when(e is SymbolStoreException || e is IOException ||
                                     e is UnauthorizedAccessException ||
                                     e is NotSupportedException || e is ArgumentException)
            {
                throw new SymbolStoreException(
                          Strings.FailedToCopyToStructuredStore(_path, filename, e.Message), e);
            }
        }
Пример #7
0
 public void AddVerificationFailureFor(BuildId buildId, string errorString)
 {
     _verificationFailures.Add(buildId.ToString(), errorString);
 }
Пример #8
0
        public override async Task <IFileReference> FindFileAsync(string filename, BuildId buildId,
                                                                  bool isDebugInfoFile,
                                                                  TextWriter log)
        {
            if (string.IsNullOrEmpty(filename))
            {
                throw new ArgumentException(Strings.FilenameNullOrEmpty, nameof(filename));
            }

            if (buildId == BuildId.Empty)
            {
                Trace.WriteLine(
                    Strings.FailedToSearchHttpStore(_url, filename, Strings.EmptyBuildId));
                await log.WriteLineAsync(
                    Strings.FailedToSearchHttpStore(_url, filename, Strings.EmptyBuildId));

                return(null);
            }

            try
            {
                string encodedFilename = Uri.EscapeDataString(filename);
                string fileUrl         = string.Join("/", _url.TrimEnd('/'), encodedFilename,
                                                     buildId.ToString(), encodedFilename);

                // Send a HEAD request to check if the file exists at the given url without
                // downloading it.
                var response =
                    await _httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Head, fileUrl),
                                                HttpCompletionOption.ResponseHeadersRead);

                // If HEAD requests are not supported by the server, fall back to GET requests.
                // The vast majority of servers are expected to support HEAD requests.
                if (response.StatusCode == HttpStatusCode.MethodNotAllowed &&
                    response.Content.Headers.Allow.Contains("GET"))
                {
                    response.Dispose();
                    response = await _httpClient.GetAsync(fileUrl,
                                                          HttpCompletionOption.ResponseHeadersRead);
                }

                using (response)
                {
                    Uri connectionUri = response.RequestMessage.RequestUri;
                    if (connectionUri.Scheme != Uri.UriSchemeHttps)
                    {
                        Trace.WriteLine(Strings.ConnectionIsUnencrypted(connectionUri.Host));
                        await log.WriteLineAsync(
                            Strings.ConnectionIsUnencrypted(connectionUri.Host));
                    }

                    if (!response.IsSuccessStatusCode)
                    {
                        Trace.WriteLine(Strings.FileNotFoundInHttpStore(
                                            fileUrl, (int)response.StatusCode, response.ReasonPhrase));
                        await log.WriteLineAsync(Strings.FileNotFoundInHttpStore(
                                                     fileUrl, (int)response.StatusCode, response.ReasonPhrase));

                        return(null);
                    }
                    else
                    {
                        Trace.WriteLine(Strings.FileFound(fileUrl));
                        await log.WriteLineAsync(Strings.FileFound(fileUrl));

                        return(new HttpFileReference(_fileSystem, _httpClient, fileUrl));
                    }
                }
            }
            catch (HttpRequestException e)
            {
                Trace.WriteLine(Strings.FailedToSearchHttpStore(_url, filename, e.ToString()));
                await log.WriteLineAsync(
                    Strings.FailedToSearchHttpStore(_url, filename, e.Message));

                return(null);
            }
        }