public void CreateDirectory_CreateTestDirectory(string platformVersion, string[] expectedModuleVersions, bool includePrerelease)
        {
            //Mutex is required to synhronize access to the static  PlatformVersion.CurrentVersion for one thread
            _mutex.WaitOne();
            //Arrange
            PlatformVersion.CurrentVersion = SemanticVersion.Parse(platformVersion);
            var moduleA = new ExternalModuleManifest
            {
                Id       = "A",
                Versions = new[]
                {
                    new ExternalModuleManifestVersion
                    {
                        Version         = "1.5.0",
                        PlatformVersion = "2.14.0"
                    },
                    new ExternalModuleManifestVersion
                    {
                        Version         = "1.4.0",
                        PlatformVersion = "2.12.0"
                    },
                    new ExternalModuleManifestVersion
                    {
                        Version         = "1.3.0",
                        PlatformVersion = "2.12.0"
                    },
                    new ExternalModuleManifestVersion
                    {
                        Version         = "2.0.0",
                        PlatformVersion = "3.0.0"
                    },
                    new ExternalModuleManifestVersion
                    {
                        Version         = "2.1.0",
                        PlatformVersion = "3.2.0"
                    },
                    new ExternalModuleManifestVersion
                    {
                        Version         = "2.2.0",
                        PlatformVersion = "3.2.0",
                        VersionTag      = "beta"
                    },
                }
            };

            //Act
            var extCatalog = CreateExternalModuleCatalog(new[] { moduleA }, includePrerelease);

            extCatalog.Load();


            //Assert
            var actualVersions   = extCatalog.Modules.OfType <ManifestModuleInfo>().Where(x => x.Id == moduleA.Id).Select(x => x.Version);
            var expectedVersions = expectedModuleVersions.Select(x => SemanticVersion.Parse(x));

            Assert.Equal(expectedVersions, actualVersions);

            _mutex.ReleaseMutex();
        }
예제 #2
0
    /**
     * Save state to manifest
     */
    public HullManifest CreateManifest()
    {
        HullManifest manifest = new HullManifest(this);

        manifest.velocity        = rigidbody.velocity;
        manifest.angularVelocity = rigidbody.angularVelocity;

        // location
        if (constellation != null)
        {
            manifest.constellation = constellation.Manifest.position;
            if (star != null)
            {
                manifest.star = star.manifest.index;
                if (planet != null)
                {
                    manifest.planet = planet.index;
                }
            }
        }

        // ship modules
        foreach (var extMod in modules)
        {
            if (extMod is InternalCombatModule || extMod.hitPointsLeft == 0)
            {
                continue;
            }
            ExternalModuleManifest extModManifest = new ExternalModuleManifest(
                extMod.transform.localPosition,
                extMod.transform.localRotation
                );
            extModManifest.type          = (ModuleType)extMod.GetType().GetField("type").GetRawConstantValue();
            extModManifest.stats         = extMod.stats;
            extModManifest.hitPointsLeft = extMod.hitPointsLeft;

            // internal module
            manifest.modules.Add(extModManifest);
            if (extMod is HullCombatModule)
            {
                InternalCombatModule intMod = ((HullCombatModule)extMod).internalModule;
                if (intMod != null && intMod.hitPointsLeft > 0)
                {
                    InternalModuleManifest intModManifest = new InternalModuleManifest(extMod);
                    intModManifest.type           = (ModuleType)intMod.GetType().GetField("type").GetRawConstantValue();
                    intModManifest.stats          = intMod.stats;
                    intModManifest.hitPointsLeft  = intMod.hitPointsLeft;
                    intModManifest.contents       = intMod.GetContents();
                    extModManifest.internalModule = intModManifest;
                }
            }
        }
        this.manifest = manifest;
        return(manifest);
    }
예제 #3
0
    /**
     * Save state to manifest
     */
    public HullManifest CreateManifest()
    {
        HullManifest manifest = new HullManifest();

        manifest.position        = this.manifest.position;
        manifest.rotation        = this.manifest.rotation;
        manifest.velocity        = this.manifest.velocity;
        manifest.angularVelocity = this.manifest.angularVelocity;
        manifest.constellation   = this.manifest.constellation;
        manifest.star            = this.manifest.star;
        manifest.planet          = this.manifest.planet;
        foreach (KeyValuePair <Vector3, HullSlot> pair in slots)
        {
            // external module
            ExternalConstructionModule extMod = pair.Value.module;
            if (extMod == null)
            {
                continue;
            }
            ExternalModuleManifest extModManifest = new ExternalModuleManifest(
                extMod.hullSlot.transform.localPosition,
                extMod.transform.localRotation
                );
            extModManifest.name          = extMod.manifest.name;
            extModManifest.type          = (ModuleType)extMod.GetType().GetField("type").GetRawConstantValue();
            extModManifest.stats         = extMod.stats;
            extModManifest.hitPointsLeft = extMod.hitPointsLeft;

            // internal module
            manifest.modules.Add(extModManifest);
            if (extMod is HullConstructionModule)
            {
                InternalConstructionModule intMod = ((HullConstructionModule)extMod).internalModule;
                if (intMod != null)
                {
                    InternalModuleManifest intModManifest = new InternalModuleManifest(extMod.hullSlot);
                    intModManifest.name           = intMod.manifest.name;
                    intModManifest.type           = (ModuleType)intMod.GetType().GetField("type").GetRawConstantValue();
                    intModManifest.stats          = intMod.stats;
                    intModManifest.hitPointsLeft  = intMod.hitPointsLeft;
                    intModManifest.contents       = intMod.GetContents();
                    extModManifest.internalModule = intModManifest;
                }
            }
        }
        this.manifest = manifest;
        return(manifest);
    }
예제 #4
0
        /// <summary>
        /// Get the  new ManifestModuleInfo for module version that has exactly the same major version as the current platform
        /// </summary>
        private ManifestModuleInfo GetLatestCompatibleWithPlatformVersion(ExternalModuleManifest manifest, bool prerelease)
        {
            ManifestModuleInfo result    = null;
            var latestCompatibleManifest = manifest.Versions
                                           .OrderByDescending(x => x.SemanticVersion)
                                           .Where(x => x.PlatformSemanticVersion.Major == PlatformVersion.CurrentVersion.Major)
                                           .FirstOrDefault(x => string.IsNullOrEmpty(x.VersionTag) != prerelease);

            if (latestCompatibleManifest != null)
            {
                result = AbstractTypeFactory <ManifestModuleInfo> .TryCreateInstance();

                result.LoadFromExternalManifest(manifest, latestCompatibleManifest);
            }
            return(result);
        }
        public void PublishNewVersionTest()
        {
            //Arrange
            var v3_0_0_beta1 = new ModuleManifest
            {
                Version         = "3.0.0",
                VersionTag      = "beta1",
                PlatformVersion = "3.0.0"
            };
            var v3_0_0 = new ModuleManifest
            {
                Version         = "3.0.0",
                PlatformVersion = "3.0.0"
            };
            var v3_1_0_beta1 = new ModuleManifest
            {
                Version         = "3.1.0",
                VersionTag      = "beta1",
                PlatformVersion = "3.0.0"
            };
            var v3_1_0_beta2 = new ModuleManifest
            {
                Version         = "3.1.0",
                VersionTag      = "beta2",
                PlatformVersion = "3.0.0"
            };
            var v3_1_0 = new ModuleManifest
            {
                Version         = "3.1.0",
                PlatformVersion = "3.0.0"
            };

            var extModuleManifest = new ExternalModuleManifest
            {
                Id = "A"
            };

            //Act
            extModuleManifest.PublishNewVersion(v3_0_0_beta1);
            //Assert
            Assert.True(extModuleManifest.Versions.Count() == 1);
            Assert.True(extModuleManifest.Versions.Contains(ExternalModuleManifestVersion.FromManifest(v3_0_0_beta1)));

            //Act
            extModuleManifest.PublishNewVersion(v3_0_0);
            //Assert
            Assert.True(extModuleManifest.Versions.Count() == 1);
            Assert.True(extModuleManifest.Versions.Contains(ExternalModuleManifestVersion.FromManifest(v3_0_0)));

            //Act
            extModuleManifest.PublishNewVersion(v3_1_0_beta1);
            //Assert
            Assert.True(extModuleManifest.Versions.Count() == 2);
            Assert.True(extModuleManifest.Versions.Contains(ExternalModuleManifestVersion.FromManifest(v3_0_0)));
            Assert.True(extModuleManifest.Versions.Contains(ExternalModuleManifestVersion.FromManifest(v3_1_0_beta1)));

            //Act
            extModuleManifest.PublishNewVersion(v3_1_0_beta2);
            //Assert
            Assert.True(extModuleManifest.Versions.Count() == 2);
            Assert.True(extModuleManifest.Versions.Contains(ExternalModuleManifestVersion.FromManifest(v3_0_0)));
            Assert.True(extModuleManifest.Versions.Contains(ExternalModuleManifestVersion.FromManifest(v3_1_0_beta2)));

            //Act
            extModuleManifest.PublishNewVersion(v3_1_0);
            //Assert
            Assert.True(extModuleManifest.Versions.Count() == 1);
            Assert.True(extModuleManifest.Versions.Contains(ExternalModuleManifestVersion.FromManifest(v3_1_0)));
        }