示例#1
0
        public FileStream Write(BtsApplication btsApplication, Resource[] resources)
        {
            BtsApplicationValidator.Validate(btsApplication);
            ResourceValidator.Validate(resources);

            var cabFileWriter = new CabFileWriter();
            var cabFolderPath = cabFileWriter.Write(resources);

            btsApplication.AddDefaultApplicationReference();

            var adfFileWriter = new AdfFileWriter();
            var adfFilePath   = adfFileWriter.Write(btsApplication, resources);

            var msiFilePath = MsiFileWriter.Write();

            var productCode = Guid.NewGuid();
            var upgradeCode = Guid.NewGuid();
            var properties  = MsiFileWriter.GetProperties(btsApplication.Name, productCode, upgradeCode);

            using (var db = new Database(msiFilePath, DatabaseOpenMode.Direct))
            {
                db.UpdateSummaryInfo();
                db.UpdateUpgradeTable(upgradeCode);
                db.UpdateProperties(properties);
                db.UpdateFileContent(cabFolderPath, adfFilePath, resources.Length);
                db.MakeCustomModifications(productCode, btsApplication.Name);
                db.Commit();
            }

            File.Delete(adfFilePath);
            Directory.Delete(cabFolderPath, true);

            return(File.OpenRead(msiFilePath));
        }
        public void AllActionsValidForResources(CRN resource, ResourceAction action)
        {
            // Arrange
            var storage           = new MockResourceStorage().Setup();
            var resourceValidator = new ResourceValidator(storage);

            // Act
            var result = resourceValidator.Validate(resource, action);

            // Assert
            result.IsValid.Should().BeTrue();
        }
        public void AllResourcesAreInvalid(CRN resource)
        {
            // Arrange
            var storage           = new MockResourceStorage().Setup();
            var resourceValidator = new ResourceValidator(storage);

            // Act
            var result = resourceValidator.Validate(resource);

            // Assert
            result.IsValid.Should().BeFalse();
        }
        public void AllResourcesAreValid(Resource resource)
        {
            // Arrange
            var storage           = new MockResourceStorage().Setup();
            var resourceValidator = new ResourceValidator(storage);

            // Act
            var result = resourceValidator.Validate(resource.Identifier);

            // Assert
            result.IsValid.Should().BeTrue();
        }
示例#5
0
        public void ValidateEntries(Profile profile, IEnumerable <Feed.Entry> entries, ReportMode mode)
        {
            ResourceValidator validator = new ResourceValidator(profile);

            foreach (Feed.Entry entry in entries)
            {
                printer.Title(string.Format("Validating resource '{0}'", entry.Title));
                Report report = validator.Validate(entry.ResourceNode);
                printer.Print(report, mode);
                Console.Write(".");
            }
        }
示例#6
0
        private void InsertProcedural(IProceduralEntityResource resource, ResourceValidator validator)
        {
            var attribute = new RESTableProceduralAttribute(resource.Methods)
            {
                Description = resource.Description
            };
            var type = resource.Type;

            validator.ValidateRuntimeInsertion(type, resource.Name, attribute);
            validator.Validate(type);
            var inserted = _InsertResource(type, resource.Name, attribute);

            ReceiveClaimed(new[] { inserted });
        }